]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.1-201311252310.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.1-201311252310.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index fcbb736..5508d8c 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -1031,6 +1031,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -1999,6 +2003,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 noexec=on: enable non-executable mappings (default)
248 noexec=off: disable non-executable mappings
249
250 + nopcid [X86-64]
251 + Disable PCID (Process-Context IDentifier) even if it
252 + is supported by the processor.
253 +
254 nosmap [X86]
255 Disable SMAP (Supervisor Mode Access Prevention)
256 even if it is supported by processor.
257 @@ -2266,6 +2274,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
258 the specified number of seconds. This is to be used if
259 your oopses keep scrolling off the screen.
260
261 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
262 + virtualization environments that don't cope well with the
263 + expand down segment used by UDEREF on X86-32 or the frequent
264 + page table updates on X86-64.
265 +
266 + pax_sanitize_slab=
267 + 0/1 to disable/enable slab object sanitization (enabled by
268 + default).
269 +
270 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
271 +
272 + pax_extra_latent_entropy
273 + Enable a very simple form of latent entropy extraction
274 + from the first 4GB of memory as the bootmem allocator
275 + passes the memory pages to the buddy allocator.
276 +
277 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
278 + when the processor supports PCID.
279 +
280 pcbit= [HW,ISDN]
281
282 pcd. [PARIDE]
283 diff --git a/Makefile b/Makefile
284 index eb29ec7..876409e 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 define filechk_kernel.release
403 @@ -838,6 +900,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -945,6 +1008,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -960,7 +1025,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1026,7 +1091,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1066,6 +1131,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1227,6 +1293,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1366,17 +1434,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1386,11 +1458,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 98838a0..b304fb4 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 1ad6fb6..4e7fae5 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1832,7 +1832,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 15f2d5b..43ffa53 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index f4b46d3..abc9b2b 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -114,7 +114,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -124,10 +131,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index f94784f..41c7f61 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __do_const;
1803
1804 extern struct outer_cache_fns outer_cache;
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index be956db..c8f25e2 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2095 index df5e13d..97efb82 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -88,9 +88,9 @@ struct thread_info {
2099 .flags = 0, \
2100 .preempt_count = INIT_PREEMPT_COUNT, \
2101 .addr_limit = KERNEL_DS, \
2102 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2103 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2104 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2105 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2106 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2107 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2108 .restart_block = { \
2109 .fn = do_no_restart_syscall, \
2110 }, \
2111 @@ -163,7 +163,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2112 #define TIF_SYSCALL_AUDIT 9
2113 #define TIF_SYSCALL_TRACEPOINT 10
2114 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2115 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2116 +/* within 8 bits of TIF_SYSCALL_TRACE
2117 + * to meet flexible second operand requirements
2118 + */
2119 +#define TIF_GRSEC_SETXID 12
2120 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2121 #define TIF_USING_IWMMXT 17
2122 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2123 #define TIF_RESTORE_SIGMASK 20
2124 @@ -176,10 +180,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2125 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2126 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2127 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2128 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2129
2130 /* Checks for any syscall work in entry-common.S */
2131 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2132 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2133 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2134
2135 /*
2136 * Change these and you break ASM code in entry-common.S
2137 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2138 index 72abdc5..9eba222 100644
2139 --- a/arch/arm/include/asm/uaccess.h
2140 +++ b/arch/arm/include/asm/uaccess.h
2141 @@ -18,6 +18,7 @@
2142 #include <asm/domain.h>
2143 #include <asm/unified.h>
2144 #include <asm/compiler.h>
2145 +#include <asm/pgtable.h>
2146
2147 #if __LINUX_ARM_ARCH__ < 6
2148 #include <asm-generic/uaccess-unaligned.h>
2149 @@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2150 static inline void set_fs(mm_segment_t fs)
2151 {
2152 current_thread_info()->addr_limit = fs;
2153 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2154 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2155 }
2156
2157 #define segment_eq(a,b) ((a) == (b))
2158
2159 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2160 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2161 +
2162 +static inline void pax_open_userland(void)
2163 +{
2164 +
2165 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2166 + if (segment_eq(get_fs(), USER_DS)) {
2167 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2168 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2169 + }
2170 +#endif
2171 +
2172 +}
2173 +
2174 +static inline void pax_close_userland(void)
2175 +{
2176 +
2177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2178 + if (segment_eq(get_fs(), USER_DS)) {
2179 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2180 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2181 + }
2182 +#endif
2183 +
2184 +}
2185 +
2186 #define __addr_ok(addr) ({ \
2187 unsigned long flag; \
2188 __asm__("cmp %2, %0; movlo %0, #0" \
2189 @@ -150,8 +178,12 @@ extern int __get_user_4(void *);
2190
2191 #define get_user(x,p) \
2192 ({ \
2193 + int __e; \
2194 might_fault(); \
2195 - __get_user_check(x,p); \
2196 + pax_open_userland(); \
2197 + __e = __get_user_check(x,p); \
2198 + pax_close_userland(); \
2199 + __e; \
2200 })
2201
2202 extern int __put_user_1(void *, unsigned int);
2203 @@ -195,8 +227,12 @@ extern int __put_user_8(void *, unsigned long long);
2204
2205 #define put_user(x,p) \
2206 ({ \
2207 + int __e; \
2208 might_fault(); \
2209 - __put_user_check(x,p); \
2210 + pax_open_userland(); \
2211 + __e = __put_user_check(x,p); \
2212 + pax_close_userland(); \
2213 + __e; \
2214 })
2215
2216 #else /* CONFIG_MMU */
2217 @@ -237,13 +273,17 @@ static inline void set_fs(mm_segment_t fs)
2218 #define __get_user(x,ptr) \
2219 ({ \
2220 long __gu_err = 0; \
2221 + pax_open_userland(); \
2222 __get_user_err((x),(ptr),__gu_err); \
2223 + pax_close_userland(); \
2224 __gu_err; \
2225 })
2226
2227 #define __get_user_error(x,ptr,err) \
2228 ({ \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),err); \
2231 + pax_close_userland(); \
2232 (void) 0; \
2233 })
2234
2235 @@ -319,13 +359,17 @@ do { \
2236 #define __put_user(x,ptr) \
2237 ({ \
2238 long __pu_err = 0; \
2239 + pax_open_userland(); \
2240 __put_user_err((x),(ptr),__pu_err); \
2241 + pax_close_userland(); \
2242 __pu_err; \
2243 })
2244
2245 #define __put_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -425,11 +469,44 @@ do { \
2254
2255
2256 #ifdef CONFIG_MMU
2257 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2258 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2259 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2261 +
2262 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2263 +{
2264 + unsigned long ret;
2265 +
2266 + check_object_size(to, n, false);
2267 + pax_open_userland();
2268 + ret = ___copy_from_user(to, from, n);
2269 + pax_close_userland();
2270 + return ret;
2271 +}
2272 +
2273 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2274 +{
2275 + unsigned long ret;
2276 +
2277 + check_object_size(from, n, true);
2278 + pax_open_userland();
2279 + ret = ___copy_to_user(to, from, n);
2280 + pax_close_userland();
2281 + return ret;
2282 +}
2283 +
2284 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2285 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2286 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2287 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2288 +
2289 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2290 +{
2291 + unsigned long ret;
2292 + pax_open_userland();
2293 + ret = ___clear_user(addr, n);
2294 + pax_close_userland();
2295 + return ret;
2296 +}
2297 +
2298 #else
2299 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2300 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2301 @@ -438,6 +515,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2302
2303 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2304 {
2305 + if ((long)n < 0)
2306 + return n;
2307 +
2308 if (access_ok(VERIFY_READ, from, n))
2309 n = __copy_from_user(to, from, n);
2310 else /* security hole - plug it */
2311 @@ -447,6 +527,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2312
2313 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_WRITE, to, n))
2319 n = __copy_to_user(to, from, n);
2320 return n;
2321 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2322 index 5af0ed1..cea83883 100644
2323 --- a/arch/arm/include/uapi/asm/ptrace.h
2324 +++ b/arch/arm/include/uapi/asm/ptrace.h
2325 @@ -92,7 +92,7 @@
2326 * ARMv7 groups of PSR bits
2327 */
2328 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2329 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2330 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2331 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2332 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2333
2334 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2335 index 60d3b73..e5a0f22 100644
2336 --- a/arch/arm/kernel/armksyms.c
2337 +++ b/arch/arm/kernel/armksyms.c
2338 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2339
2340 /* networking */
2341 EXPORT_SYMBOL(csum_partial);
2342 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2343 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2344 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2345 EXPORT_SYMBOL(__csum_ipv6_magic);
2346
2347 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2348 #ifdef CONFIG_MMU
2349 EXPORT_SYMBOL(copy_page);
2350
2351 -EXPORT_SYMBOL(__copy_from_user);
2352 -EXPORT_SYMBOL(__copy_to_user);
2353 -EXPORT_SYMBOL(__clear_user);
2354 +EXPORT_SYMBOL(___copy_from_user);
2355 +EXPORT_SYMBOL(___copy_to_user);
2356 +EXPORT_SYMBOL(___clear_user);
2357
2358 EXPORT_SYMBOL(__get_user_1);
2359 EXPORT_SYMBOL(__get_user_2);
2360 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2361 index 9cbe70c..a7b5e34 100644
2362 --- a/arch/arm/kernel/entry-armv.S
2363 +++ b/arch/arm/kernel/entry-armv.S
2364 @@ -47,6 +47,87 @@
2365 9997:
2366 .endm
2367
2368 + .macro pax_enter_kernel
2369 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2370 + @ make aligned space for saved DACR
2371 + sub sp, sp, #8
2372 + @ save regs
2373 + stmdb sp!, {r1, r2}
2374 + @ read DACR from cpu_domain into r1
2375 + mov r2, sp
2376 + @ assume 8K pages, since we have to split the immediate in two
2377 + bic r2, r2, #(0x1fc0)
2378 + bic r2, r2, #(0x3f)
2379 + ldr r1, [r2, #TI_CPU_DOMAIN]
2380 + @ store old DACR on stack
2381 + str r1, [sp, #8]
2382 +#ifdef CONFIG_PAX_KERNEXEC
2383 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2384 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2385 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2386 +#endif
2387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2388 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2389 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2390 +#endif
2391 + @ write r1 to current_thread_info()->cpu_domain
2392 + str r1, [r2, #TI_CPU_DOMAIN]
2393 + @ write r1 to DACR
2394 + mcr p15, 0, r1, c3, c0, 0
2395 + @ instruction sync
2396 + instr_sync
2397 + @ restore regs
2398 + ldmia sp!, {r1, r2}
2399 +#endif
2400 + .endm
2401 +
2402 + .macro pax_open_userland
2403 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2404 + @ save regs
2405 + stmdb sp!, {r0, r1}
2406 + @ read DACR from cpu_domain into r1
2407 + mov r0, sp
2408 + @ assume 8K pages, since we have to split the immediate in two
2409 + bic r0, r0, #(0x1fc0)
2410 + bic r0, r0, #(0x3f)
2411 + ldr r1, [r0, #TI_CPU_DOMAIN]
2412 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r0, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r0, r1}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_close_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + @ write r1 to current_thread_info()->cpu_domain
2439 + str r1, [r0, #TI_CPU_DOMAIN]
2440 + @ write r1 to DACR
2441 + mcr p15, 0, r1, c3, c0, 0
2442 + @ instruction sync
2443 + instr_sync
2444 + @ restore regs
2445 + ldmia sp!, {r0, r1}
2446 +#endif
2447 + .endm
2448 +
2449 .macro pabt_helper
2450 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2451 #ifdef MULTI_PABORT
2452 @@ -89,11 +170,15 @@
2453 * Invalid mode handlers
2454 */
2455 .macro inv_entry, reason
2456 +
2457 + pax_enter_kernel
2458 +
2459 sub sp, sp, #S_FRAME_SIZE
2460 ARM( stmib sp, {r1 - lr} )
2461 THUMB( stmia sp, {r0 - r12} )
2462 THUMB( str sp, [sp, #S_SP] )
2463 THUMB( str lr, [sp, #S_LR] )
2464 +
2465 mov r1, #\reason
2466 .endm
2467
2468 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2469 .macro svc_entry, stack_hole=0
2470 UNWIND(.fnstart )
2471 UNWIND(.save {r0 - pc} )
2472 +
2473 + pax_enter_kernel
2474 +
2475 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2476 +
2477 #ifdef CONFIG_THUMB2_KERNEL
2478 SPFIX( str r0, [sp] ) @ temporarily saved
2479 SPFIX( mov r0, sp )
2480 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2481 ldmia r0, {r3 - r5}
2482 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2483 mov r6, #-1 @ "" "" "" ""
2484 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2485 + @ offset sp by 8 as done in pax_enter_kernel
2486 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2487 +#else
2488 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2489 +#endif
2490 SPFIX( addeq r2, r2, #4 )
2491 str r3, [sp, #-4]! @ save the "real" r0 copied
2492 @ from the exception stack
2493 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2494 .macro usr_entry
2495 UNWIND(.fnstart )
2496 UNWIND(.cantunwind ) @ don't unwind the user space
2497 +
2498 + pax_enter_kernel_user
2499 +
2500 sub sp, sp, #S_FRAME_SIZE
2501 ARM( stmib sp, {r1 - r12} )
2502 THUMB( stmia sp, {r0 - r12} )
2503 @@ -415,7 +512,9 @@ __und_usr:
2504 tst r3, #PSR_T_BIT @ Thumb mode?
2505 bne __und_usr_thumb
2506 sub r4, r2, #4 @ ARM instr at LR - 4
2507 + pax_open_userland
2508 1: ldrt r0, [r4]
2509 + pax_close_userland
2510 #ifdef CONFIG_CPU_ENDIAN_BE8
2511 rev r0, r0 @ little endian instruction
2512 #endif
2513 @@ -450,10 +549,14 @@ __und_usr_thumb:
2514 */
2515 .arch armv6t2
2516 #endif
2517 + pax_open_userland
2518 2: ldrht r5, [r4]
2519 + pax_close_userland
2520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2521 blo __und_usr_fault_16 @ 16bit undefined instruction
2522 + pax_open_userland
2523 3: ldrht r0, [r2]
2524 + pax_close_userland
2525 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2526 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2527 orr r0, r0, r5, lsl #16
2528 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2529 */
2530 .pushsection .fixup, "ax"
2531 .align 2
2532 -4: mov pc, r9
2533 +4: pax_close_userland
2534 + mov pc, r9
2535 .popsection
2536 .pushsection __ex_table,"a"
2537 .long 1b, 4b
2538 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2539 THUMB( str lr, [ip], #4 )
2540 ldr r4, [r2, #TI_TP_VALUE]
2541 ldr r5, [r2, #TI_TP_VALUE + 4]
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 switch_tls r1, r4, r5, r3, r7
2547 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index bc6bd96..bd026cb 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index 39f89fb..d612bd9 100644
2625 --- a/arch/arm/kernel/entry-header.S
2626 +++ b/arch/arm/kernel/entry-header.S
2627 @@ -184,6 +184,60 @@
2628 msr cpsr_c, \rtemp @ switch back to the SVC mode
2629 .endm
2630
2631 + .macro pax_enter_kernel_user
2632 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2633 + @ save regs
2634 + stmdb sp!, {r0, r1}
2635 + @ read DACR from cpu_domain into r1
2636 + mov r0, sp
2637 + @ assume 8K pages, since we have to split the immediate in two
2638 + bic r0, r0, #(0x1fc0)
2639 + bic r0, r0, #(0x3f)
2640 + ldr r1, [r0, #TI_CPU_DOMAIN]
2641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2642 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2643 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2644 +#endif
2645 +#ifdef CONFIG_PAX_KERNEXEC
2646 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2647 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2648 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2649 +#endif
2650 + @ write r1 to current_thread_info()->cpu_domain
2651 + str r1, [r0, #TI_CPU_DOMAIN]
2652 + @ write r1 to DACR
2653 + mcr p15, 0, r1, c3, c0, 0
2654 + @ instruction sync
2655 + instr_sync
2656 + @ restore regs
2657 + ldmia sp!, {r0, r1}
2658 +#endif
2659 + .endm
2660 +
2661 + .macro pax_exit_kernel
2662 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2663 + @ save regs
2664 + stmdb sp!, {r0, r1}
2665 + @ read old DACR from stack into r1
2666 + ldr r1, [sp, #(8 + S_SP)]
2667 + sub r1, r1, #8
2668 + ldr r1, [r1]
2669 +
2670 + @ write r1 to current_thread_info()->cpu_domain
2671 + mov r0, sp
2672 + @ assume 8K pages, since we have to split the immediate in two
2673 + bic r0, r0, #(0x1fc0)
2674 + bic r0, r0, #(0x3f)
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 #ifndef CONFIG_THUMB2_KERNEL
2686 .macro svc_exit, rpsr, irq = 0
2687 .if \irq != 0
2688 @@ -203,6 +257,9 @@
2689 blne trace_hardirqs_off
2690 #endif
2691 .endif
2692 +
2693 + pax_exit_kernel
2694 +
2695 msr spsr_cxsf, \rpsr
2696 #if defined(CONFIG_CPU_V6)
2697 ldr r0, [sp]
2698 @@ -266,6 +323,9 @@
2699 blne trace_hardirqs_off
2700 #endif
2701 .endif
2702 +
2703 + pax_exit_kernel
2704 +
2705 ldr lr, [sp, #S_SP] @ top of the stack
2706 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2707 clrex @ clear the exclusive monitor
2708 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2709 index 918875d..cd5fa27 100644
2710 --- a/arch/arm/kernel/fiq.c
2711 +++ b/arch/arm/kernel/fiq.c
2712 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2713 void *base = vectors_page;
2714 unsigned offset = FIQ_OFFSET;
2715
2716 + pax_open_kernel();
2717 memcpy(base + offset, start, length);
2718 + pax_close_kernel();
2719 +
2720 if (!cache_is_vipt_nonaliasing())
2721 flush_icache_range((unsigned long)base + offset, offset +
2722 length);
2723 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2724 index 476de57..4857a76 100644
2725 --- a/arch/arm/kernel/head.S
2726 +++ b/arch/arm/kernel/head.S
2727 @@ -52,7 +52,9 @@
2728 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2729
2730 .macro pgtbl, rd, phys
2731 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2732 + mov \rd, #TEXT_OFFSET
2733 + sub \rd, #PG_DIR_SIZE
2734 + add \rd, \rd, \phys
2735 .endm
2736
2737 /*
2738 @@ -432,7 +434,7 @@ __enable_mmu:
2739 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2740 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2741 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2742 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2743 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2744 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2745 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2746 #endif
2747 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2748 index 084dc88..fce4e68 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index 0e1e2b3..c0e821d 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 72024ea..ae302dd 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index 8fcda14..4512b9d 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -628,7 +633,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -885,7 +892,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 9c697db..115237f 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -396,7 +396,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -429,7 +429,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -446,7 +446,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index 1767611..d2e7e24 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -156,7 +156,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -190,14 +199,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index 579697a..1d5a3b2 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static int gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index b69dd9a..70e5409 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index d9ee0ff..24f224a 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index b82dcae..44ee5b6 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index 656324a..0beba28 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -40,13 +40,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..4dd9b67 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 84e6f77..0b52f31 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -180,7 +180,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -198,7 +198,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -227,14 +227,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index eb8830a..5360ce7 100644
3786 --- a/arch/arm/mm/fault.c
3787 +++ b/arch/arm/mm/fault.c
3788 @@ -25,6 +25,7 @@
3789 #include <asm/system_misc.h>
3790 #include <asm/system_info.h>
3791 #include <asm/tlbflush.h>
3792 +#include <asm/sections.h>
3793
3794 #include "fault.h"
3795
3796 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3797 if (fixup_exception(regs))
3798 return;
3799
3800 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3801 + if (addr < TASK_SIZE) {
3802 + if (current->signal->curr_ip)
3803 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3804 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3805 + else
3806 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3808 + }
3809 +#endif
3810 +
3811 +#ifdef CONFIG_PAX_KERNEXEC
3812 + if ((fsr & FSR_WRITE) &&
3813 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3814 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3815 + {
3816 + if (current->signal->curr_ip)
3817 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3818 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3819 + else
3820 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3821 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3822 + }
3823 +#endif
3824 +
3825 /*
3826 * No handler, we'll have to terminate things with extreme prejudice.
3827 */
3828 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3829 }
3830 #endif
3831
3832 +#ifdef CONFIG_PAX_PAGEEXEC
3833 + if (fsr & FSR_LNX_PF) {
3834 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3835 + do_group_exit(SIGKILL);
3836 + }
3837 +#endif
3838 +
3839 tsk->thread.address = addr;
3840 tsk->thread.error_code = fsr;
3841 tsk->thread.trap_no = 14;
3842 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3843 }
3844 #endif /* CONFIG_MMU */
3845
3846 +#ifdef CONFIG_PAX_PAGEEXEC
3847 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3848 +{
3849 + long i;
3850 +
3851 + printk(KERN_ERR "PAX: bytes at PC: ");
3852 + for (i = 0; i < 20; i++) {
3853 + unsigned char c;
3854 + if (get_user(c, (__force unsigned char __user *)pc+i))
3855 + printk(KERN_CONT "?? ");
3856 + else
3857 + printk(KERN_CONT "%02x ", c);
3858 + }
3859 + printk("\n");
3860 +
3861 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3862 + for (i = -1; i < 20; i++) {
3863 + unsigned long c;
3864 + if (get_user(c, (__force unsigned long __user *)sp+i))
3865 + printk(KERN_CONT "???????? ");
3866 + else
3867 + printk(KERN_CONT "%08lx ", c);
3868 + }
3869 + printk("\n");
3870 +}
3871 +#endif
3872 +
3873 /*
3874 * First Level Translation Fault Handler
3875 *
3876 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3877 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3878 struct siginfo info;
3879
3880 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3881 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3882 + if (current->signal->curr_ip)
3883 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3884 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3885 + else
3886 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3887 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3888 + goto die;
3889 + }
3890 +#endif
3891 +
3892 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3893 return;
3894
3895 +die:
3896 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3897 inf->name, fsr, addr);
3898
3899 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3900 ifsr_info[nr].name = name;
3901 }
3902
3903 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3904 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3905 +
3906 asmlinkage void __exception
3907 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3908 {
3909 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3910 struct siginfo info;
3911 + unsigned long pc = instruction_pointer(regs);
3912 +
3913 + if (user_mode(regs)) {
3914 + unsigned long sigpage = current->mm->context.sigpage;
3915 +
3916 + if (sigpage <= pc && pc < sigpage + 7*4) {
3917 + if (pc < sigpage + 3*4)
3918 + sys_sigreturn(regs);
3919 + else
3920 + sys_rt_sigreturn(regs);
3921 + return;
3922 + }
3923 + if (pc == 0xffff0f60UL) {
3924 + /*
3925 + * PaX: __kuser_cmpxchg64 emulation
3926 + */
3927 + // TODO
3928 + //regs->ARM_pc = regs->ARM_lr;
3929 + //return;
3930 + }
3931 + if (pc == 0xffff0fa0UL) {
3932 + /*
3933 + * PaX: __kuser_memory_barrier emulation
3934 + */
3935 + // dmb(); implied by the exception
3936 + regs->ARM_pc = regs->ARM_lr;
3937 + return;
3938 + }
3939 + if (pc == 0xffff0fc0UL) {
3940 + /*
3941 + * PaX: __kuser_cmpxchg emulation
3942 + */
3943 + // TODO
3944 + //long new;
3945 + //int op;
3946 +
3947 + //op = FUTEX_OP_SET << 28;
3948 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
3949 + //regs->ARM_r0 = old != new;
3950 + //regs->ARM_pc = regs->ARM_lr;
3951 + //return;
3952 + }
3953 + if (pc == 0xffff0fe0UL) {
3954 + /*
3955 + * PaX: __kuser_get_tls emulation
3956 + */
3957 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3958 + regs->ARM_pc = regs->ARM_lr;
3959 + return;
3960 + }
3961 + }
3962 +
3963 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3964 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3965 + if (current->signal->curr_ip)
3966 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3967 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3968 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3969 + else
3970 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3971 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3972 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3973 + goto die;
3974 + }
3975 +#endif
3976 +
3977 +#ifdef CONFIG_PAX_REFCOUNT
3978 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3979 + unsigned int bkpt;
3980 +
3981 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3982 + current->thread.error_code = ifsr;
3983 + current->thread.trap_no = 0;
3984 + pax_report_refcount_overflow(regs);
3985 + fixup_exception(regs);
3986 + return;
3987 + }
3988 + }
3989 +#endif
3990
3991 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3992 return;
3993
3994 +die:
3995 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3996 inf->name, ifsr, addr);
3997
3998 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3999 index cf08bdf..772656c 100644
4000 --- a/arch/arm/mm/fault.h
4001 +++ b/arch/arm/mm/fault.h
4002 @@ -3,6 +3,7 @@
4003
4004 /*
4005 * Fault status register encodings. We steal bit 31 for our own purposes.
4006 + * Set when the FSR value is from an instruction fault.
4007 */
4008 #define FSR_LNX_PF (1 << 31)
4009 #define FSR_WRITE (1 << 11)
4010 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4011 }
4012 #endif
4013
4014 +/* valid for LPAE and !LPAE */
4015 +static inline int is_xn_fault(unsigned int fsr)
4016 +{
4017 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4018 +}
4019 +
4020 +static inline int is_domain_fault(unsigned int fsr)
4021 +{
4022 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4023 +}
4024 +
4025 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4026 unsigned long search_exception_table(unsigned long addr);
4027
4028 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4029 index 18ec4c5..479bb6a 100644
4030 --- a/arch/arm/mm/init.c
4031 +++ b/arch/arm/mm/init.c
4032 @@ -30,6 +30,8 @@
4033 #include <asm/setup.h>
4034 #include <asm/tlb.h>
4035 #include <asm/fixmap.h>
4036 +#include <asm/system_info.h>
4037 +#include <asm/cp15.h>
4038
4039 #include <asm/mach/arch.h>
4040 #include <asm/mach/map.h>
4041 @@ -684,7 +686,46 @@ void free_initmem(void)
4042 {
4043 #ifdef CONFIG_HAVE_TCM
4044 extern char __tcm_start, __tcm_end;
4045 +#endif
4046
4047 +#ifdef CONFIG_PAX_KERNEXEC
4048 + unsigned long addr;
4049 + pgd_t *pgd;
4050 + pud_t *pud;
4051 + pmd_t *pmd;
4052 + int cpu_arch = cpu_architecture();
4053 + unsigned int cr = get_cr();
4054 +
4055 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4056 + /* make pages tables, etc before .text NX */
4057 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4058 + pgd = pgd_offset_k(addr);
4059 + pud = pud_offset(pgd, addr);
4060 + pmd = pmd_offset(pud, addr);
4061 + __section_update(pmd, addr, PMD_SECT_XN);
4062 + }
4063 + /* make init NX */
4064 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4065 + pgd = pgd_offset_k(addr);
4066 + pud = pud_offset(pgd, addr);
4067 + pmd = pmd_offset(pud, addr);
4068 + __section_update(pmd, addr, PMD_SECT_XN);
4069 + }
4070 + /* make kernel code/rodata RX */
4071 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4072 + pgd = pgd_offset_k(addr);
4073 + pud = pud_offset(pgd, addr);
4074 + pmd = pmd_offset(pud, addr);
4075 +#ifdef CONFIG_ARM_LPAE
4076 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4077 +#else
4078 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4079 +#endif
4080 + }
4081 + }
4082 +#endif
4083 +
4084 +#ifdef CONFIG_HAVE_TCM
4085 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4086 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4087 #endif
4088 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4089 index f123d6e..04bf569 100644
4090 --- a/arch/arm/mm/ioremap.c
4091 +++ b/arch/arm/mm/ioremap.c
4092 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4093 unsigned int mtype;
4094
4095 if (cached)
4096 - mtype = MT_MEMORY;
4097 + mtype = MT_MEMORY_RX;
4098 else
4099 - mtype = MT_MEMORY_NONCACHED;
4100 + mtype = MT_MEMORY_NONCACHED_RX;
4101
4102 return __arm_ioremap_caller(phys_addr, size, mtype,
4103 __builtin_return_address(0));
4104 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4105 index 0c63562..7128a90 100644
4106 --- a/arch/arm/mm/mmap.c
4107 +++ b/arch/arm/mm/mmap.c
4108 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4109 struct vm_area_struct *vma;
4110 int do_align = 0;
4111 int aliasing = cache_is_vipt_aliasing();
4112 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4113 struct vm_unmapped_area_info info;
4114
4115 /*
4116 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4117 if (len > TASK_SIZE)
4118 return -ENOMEM;
4119
4120 +#ifdef CONFIG_PAX_RANDMMAP
4121 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4122 +#endif
4123 +
4124 if (addr) {
4125 if (do_align)
4126 addr = COLOUR_ALIGN(addr, pgoff);
4127 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4128 addr = PAGE_ALIGN(addr);
4129
4130 vma = find_vma(mm, addr);
4131 - if (TASK_SIZE - len >= addr &&
4132 - (!vma || addr + len <= vma->vm_start))
4133 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4134 return addr;
4135 }
4136
4137 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 info.high_limit = TASK_SIZE;
4139 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4140 info.align_offset = pgoff << PAGE_SHIFT;
4141 + info.threadstack_offset = offset;
4142 return vm_unmapped_area(&info);
4143 }
4144
4145 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4146 unsigned long addr = addr0;
4147 int do_align = 0;
4148 int aliasing = cache_is_vipt_aliasing();
4149 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4150 struct vm_unmapped_area_info info;
4151
4152 /*
4153 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4154 return addr;
4155 }
4156
4157 +#ifdef CONFIG_PAX_RANDMMAP
4158 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4159 +#endif
4160 +
4161 /* requesting a specific address */
4162 if (addr) {
4163 if (do_align)
4164 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4165 else
4166 addr = PAGE_ALIGN(addr);
4167 vma = find_vma(mm, addr);
4168 - if (TASK_SIZE - len >= addr &&
4169 - (!vma || addr + len <= vma->vm_start))
4170 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4171 return addr;
4172 }
4173
4174 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4175 info.high_limit = mm->mmap_base;
4176 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4177 info.align_offset = pgoff << PAGE_SHIFT;
4178 + info.threadstack_offset = offset;
4179 addr = vm_unmapped_area(&info);
4180
4181 /*
4182 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4183 {
4184 unsigned long random_factor = 0UL;
4185
4186 +#ifdef CONFIG_PAX_RANDMMAP
4187 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4188 +#endif
4189 +
4190 /* 8 bits of randomness in 20 address space bits */
4191 if ((current->flags & PF_RANDOMIZE) &&
4192 !(current->personality & ADDR_NO_RANDOMIZE))
4193 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4194
4195 if (mmap_is_legacy()) {
4196 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4197 +
4198 +#ifdef CONFIG_PAX_RANDMMAP
4199 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4200 + mm->mmap_base += mm->delta_mmap;
4201 +#endif
4202 +
4203 mm->get_unmapped_area = arch_get_unmapped_area;
4204 } else {
4205 mm->mmap_base = mmap_base(random_factor);
4206 +
4207 +#ifdef CONFIG_PAX_RANDMMAP
4208 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4209 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4210 +#endif
4211 +
4212 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4213 }
4214 }
4215 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4216 index b1d17ee..7a6f4d3 100644
4217 --- a/arch/arm/mm/mmu.c
4218 +++ b/arch/arm/mm/mmu.c
4219 @@ -36,6 +36,22 @@
4220 #include "mm.h"
4221 #include "tcm.h"
4222
4223 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4224 +void modify_domain(unsigned int dom, unsigned int type)
4225 +{
4226 + struct thread_info *thread = current_thread_info();
4227 + unsigned int domain = thread->cpu_domain;
4228 + /*
4229 + * DOMAIN_MANAGER might be defined to some other value,
4230 + * use the arch-defined constant
4231 + */
4232 + domain &= ~domain_val(dom, 3);
4233 + thread->cpu_domain = domain | domain_val(dom, type);
4234 + set_domain(thread->cpu_domain);
4235 +}
4236 +EXPORT_SYMBOL(modify_domain);
4237 +#endif
4238 +
4239 /*
4240 * empty_zero_page is a special page that is used for
4241 * zero-initialized data and COW.
4242 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4243
4244 #endif /* ifdef CONFIG_CPU_CP15 / else */
4245
4246 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4247 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4248 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4249
4250 -static struct mem_type mem_types[] = {
4251 +#ifdef CONFIG_PAX_KERNEXEC
4252 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4253 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4254 +#else
4255 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4256 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4257 +#endif
4258 +
4259 +static struct mem_type mem_types[] __read_only = {
4260 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4261 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4262 L_PTE_SHARED,
4263 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4264 [MT_UNCACHED] = {
4265 .prot_pte = PROT_PTE_DEVICE,
4266 .prot_l1 = PMD_TYPE_TABLE,
4267 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4268 + .prot_sect = PROT_SECT_DEVICE,
4269 .domain = DOMAIN_IO,
4270 },
4271 [MT_CACHECLEAN] = {
4272 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4273 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4274 .domain = DOMAIN_KERNEL,
4275 },
4276 #ifndef CONFIG_ARM_LPAE
4277 [MT_MINICLEAN] = {
4278 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4279 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4280 .domain = DOMAIN_KERNEL,
4281 },
4282 #endif
4283 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4284 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4285 L_PTE_RDONLY,
4286 .prot_l1 = PMD_TYPE_TABLE,
4287 - .domain = DOMAIN_USER,
4288 + .domain = DOMAIN_VECTORS,
4289 },
4290 [MT_HIGH_VECTORS] = {
4291 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4292 L_PTE_USER | L_PTE_RDONLY,
4293 .prot_l1 = PMD_TYPE_TABLE,
4294 - .domain = DOMAIN_USER,
4295 + .domain = DOMAIN_VECTORS,
4296 },
4297 - [MT_MEMORY] = {
4298 + [MT_MEMORY_RWX] = {
4299 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4300 .prot_l1 = PMD_TYPE_TABLE,
4301 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4302 .domain = DOMAIN_KERNEL,
4303 },
4304 + [MT_MEMORY_RW] = {
4305 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4306 + .prot_l1 = PMD_TYPE_TABLE,
4307 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4308 + .domain = DOMAIN_KERNEL,
4309 + },
4310 + [MT_MEMORY_RX] = {
4311 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4312 + .prot_l1 = PMD_TYPE_TABLE,
4313 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4314 + .domain = DOMAIN_KERNEL,
4315 + },
4316 [MT_ROM] = {
4317 - .prot_sect = PMD_TYPE_SECT,
4318 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4319 .domain = DOMAIN_KERNEL,
4320 },
4321 - [MT_MEMORY_NONCACHED] = {
4322 + [MT_MEMORY_NONCACHED_RW] = {
4323 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4324 L_PTE_MT_BUFFERABLE,
4325 .prot_l1 = PMD_TYPE_TABLE,
4326 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4327 .domain = DOMAIN_KERNEL,
4328 },
4329 + [MT_MEMORY_NONCACHED_RX] = {
4330 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4331 + L_PTE_MT_BUFFERABLE,
4332 + .prot_l1 = PMD_TYPE_TABLE,
4333 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4334 + .domain = DOMAIN_KERNEL,
4335 + },
4336 [MT_MEMORY_DTCM] = {
4337 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4338 - L_PTE_XN,
4339 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4340 .prot_l1 = PMD_TYPE_TABLE,
4341 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4342 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4343 .domain = DOMAIN_KERNEL,
4344 },
4345 [MT_MEMORY_ITCM] = {
4346 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4347 },
4348 [MT_MEMORY_SO] = {
4349 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4350 - L_PTE_MT_UNCACHED | L_PTE_XN,
4351 + L_PTE_MT_UNCACHED,
4352 .prot_l1 = PMD_TYPE_TABLE,
4353 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4354 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4355 + PMD_SECT_UNCACHED,
4356 .domain = DOMAIN_KERNEL,
4357 },
4358 [MT_MEMORY_DMA_READY] = {
4359 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4360 * to prevent speculative instruction fetches.
4361 */
4362 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4364 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4365 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4366 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4367 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4368 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4369 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4370 +
4371 + /* Mark other regions on ARMv6+ as execute-never */
4372 +
4373 +#ifdef CONFIG_PAX_KERNEXEC
4374 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4375 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4376 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4378 +#ifndef CONFIG_ARM_LPAE
4379 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4380 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4381 +#endif
4382 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4383 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4384 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4386 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4388 +#endif
4389 +
4390 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4391 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4392 }
4393 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4394 /*
4395 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4396 * from SVC mode and no access from userspace.
4397 */
4398 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4399 +#ifdef CONFIG_PAX_KERNEXEC
4400 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4401 +#endif
4402 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4403 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4404 #endif
4405 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4406 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4407 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4408 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4409 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4410 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4411 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4412 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4413 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4414 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4415 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4416 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4417 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4418 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4419 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4420 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4421 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4422 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4423 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4424 }
4425 }
4426
4427 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4428 if (cpu_arch >= CPU_ARCH_ARMv6) {
4429 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4430 /* Non-cacheable Normal is XCB = 001 */
4431 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4432 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4433 + PMD_SECT_BUFFERED;
4434 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4435 PMD_SECT_BUFFERED;
4436 } else {
4437 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4438 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4439 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4440 + PMD_SECT_TEX(1);
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4442 PMD_SECT_TEX(1);
4443 }
4444 } else {
4445 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4446 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4447 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4448 }
4449
4450 #ifdef CONFIG_ARM_LPAE
4451 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4452 vecs_pgprot |= PTE_EXT_AF;
4453 #endif
4454
4455 + user_pgprot |= __supported_pte_mask;
4456 +
4457 for (i = 0; i < 16; i++) {
4458 pteval_t v = pgprot_val(protection_map[i]);
4459 protection_map[i] = __pgprot(v | user_pgprot);
4460 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4461
4462 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4463 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4464 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4465 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4466 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4467 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4468 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4469 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4470 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4471 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4472 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4473 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4474 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4475 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4476 mem_types[MT_ROM].prot_sect |= cp->pmd;
4477
4478 switch (cp->pmd) {
4479 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4480 * called function. This means you can't use any function or debugging
4481 * method which may touch any device, otherwise the kernel _will_ crash.
4482 */
4483 +
4484 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4485 +
4486 static void __init devicemaps_init(const struct machine_desc *mdesc)
4487 {
4488 struct map_desc map;
4489 unsigned long addr;
4490 - void *vectors;
4491
4492 - /*
4493 - * Allocate the vector page early.
4494 - */
4495 - vectors = early_alloc(PAGE_SIZE * 2);
4496 -
4497 - early_trap_init(vectors);
4498 + early_trap_init(&vectors);
4499
4500 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4501 pmd_clear(pmd_off_k(addr));
4502 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4503 * location (0xffff0000). If we aren't using high-vectors, also
4504 * create a mapping at the low-vectors virtual address.
4505 */
4506 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4507 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4508 map.virtual = 0xffff0000;
4509 map.length = PAGE_SIZE;
4510 #ifdef CONFIG_KUSER_HELPERS
4511 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4512 map.pfn = __phys_to_pfn(start);
4513 map.virtual = __phys_to_virt(start);
4514 map.length = end - start;
4515 - map.type = MT_MEMORY;
4516
4517 +#ifdef CONFIG_PAX_KERNEXEC
4518 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4519 + struct map_desc kernel;
4520 + struct map_desc initmap;
4521 +
4522 + /* when freeing initmem we will make this RW */
4523 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4524 + initmap.virtual = (unsigned long)__init_begin;
4525 + initmap.length = _sdata - __init_begin;
4526 + initmap.type = MT_MEMORY_RWX;
4527 + create_mapping(&initmap);
4528 +
4529 + /* when freeing initmem we will make this RX */
4530 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4531 + kernel.virtual = (unsigned long)_stext;
4532 + kernel.length = __init_begin - _stext;
4533 + kernel.type = MT_MEMORY_RWX;
4534 + create_mapping(&kernel);
4535 +
4536 + if (map.virtual < (unsigned long)_stext) {
4537 + map.length = (unsigned long)_stext - map.virtual;
4538 + map.type = MT_MEMORY_RWX;
4539 + create_mapping(&map);
4540 + }
4541 +
4542 + map.pfn = __phys_to_pfn(__pa(_sdata));
4543 + map.virtual = (unsigned long)_sdata;
4544 + map.length = end - __pa(_sdata);
4545 + }
4546 +#endif
4547 +
4548 + map.type = MT_MEMORY_RW;
4549 create_mapping(&map);
4550 }
4551 }
4552 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4553 index a5bc92d..0bb4730 100644
4554 --- a/arch/arm/plat-omap/sram.c
4555 +++ b/arch/arm/plat-omap/sram.c
4556 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4557 * Looks like we need to preserve some bootloader code at the
4558 * beginning of SRAM for jumping to flash for reboot to work...
4559 */
4560 + pax_open_kernel();
4561 memset_io(omap_sram_base + omap_sram_skip, 0,
4562 omap_sram_size - omap_sram_skip);
4563 + pax_close_kernel();
4564 }
4565 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4566 index ce6d763..cfea917 100644
4567 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4568 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4569 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4570 int (*started)(unsigned ch);
4571 int (*flush)(unsigned ch);
4572 int (*stop)(unsigned ch);
4573 -};
4574 +} __no_const;
4575
4576 extern void *samsung_dmadev_get_ops(void);
4577 extern void *s3c_dma_get_ops(void);
4578 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4579 index c3a58a1..78fbf54 100644
4580 --- a/arch/avr32/include/asm/cache.h
4581 +++ b/arch/avr32/include/asm/cache.h
4582 @@ -1,8 +1,10 @@
4583 #ifndef __ASM_AVR32_CACHE_H
4584 #define __ASM_AVR32_CACHE_H
4585
4586 +#include <linux/const.h>
4587 +
4588 #define L1_CACHE_SHIFT 5
4589 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4590 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4591
4592 /*
4593 * Memory returned by kmalloc() may be used for DMA, so we must make
4594 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4595 index d232888..87c8df1 100644
4596 --- a/arch/avr32/include/asm/elf.h
4597 +++ b/arch/avr32/include/asm/elf.h
4598 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4599 the loader. We need to make sure that it is out of the way of the program
4600 that it will "exec", and that there is sufficient room for the brk. */
4601
4602 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4603 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4604
4605 +#ifdef CONFIG_PAX_ASLR
4606 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4607 +
4608 +#define PAX_DELTA_MMAP_LEN 15
4609 +#define PAX_DELTA_STACK_LEN 15
4610 +#endif
4611
4612 /* This yields a mask that user programs can use to figure out what
4613 instruction set this CPU supports. This could be done in user space,
4614 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4615 index 479330b..53717a8 100644
4616 --- a/arch/avr32/include/asm/kmap_types.h
4617 +++ b/arch/avr32/include/asm/kmap_types.h
4618 @@ -2,9 +2,9 @@
4619 #define __ASM_AVR32_KMAP_TYPES_H
4620
4621 #ifdef CONFIG_DEBUG_HIGHMEM
4622 -# define KM_TYPE_NR 29
4623 +# define KM_TYPE_NR 30
4624 #else
4625 -# define KM_TYPE_NR 14
4626 +# define KM_TYPE_NR 15
4627 #endif
4628
4629 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4630 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4631 index 0eca933..eb78c7b 100644
4632 --- a/arch/avr32/mm/fault.c
4633 +++ b/arch/avr32/mm/fault.c
4634 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4635
4636 int exception_trace = 1;
4637
4638 +#ifdef CONFIG_PAX_PAGEEXEC
4639 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4640 +{
4641 + unsigned long i;
4642 +
4643 + printk(KERN_ERR "PAX: bytes at PC: ");
4644 + for (i = 0; i < 20; i++) {
4645 + unsigned char c;
4646 + if (get_user(c, (unsigned char *)pc+i))
4647 + printk(KERN_CONT "???????? ");
4648 + else
4649 + printk(KERN_CONT "%02x ", c);
4650 + }
4651 + printk("\n");
4652 +}
4653 +#endif
4654 +
4655 /*
4656 * This routine handles page faults. It determines the address and the
4657 * problem, and then passes it off to one of the appropriate routines.
4658 @@ -176,6 +193,16 @@ bad_area:
4659 up_read(&mm->mmap_sem);
4660
4661 if (user_mode(regs)) {
4662 +
4663 +#ifdef CONFIG_PAX_PAGEEXEC
4664 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4665 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4666 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4667 + do_group_exit(SIGKILL);
4668 + }
4669 + }
4670 +#endif
4671 +
4672 if (exception_trace && printk_ratelimit())
4673 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4674 "sp %08lx ecr %lu\n",
4675 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4676 index 568885a..f8008df 100644
4677 --- a/arch/blackfin/include/asm/cache.h
4678 +++ b/arch/blackfin/include/asm/cache.h
4679 @@ -7,6 +7,7 @@
4680 #ifndef __ARCH_BLACKFIN_CACHE_H
4681 #define __ARCH_BLACKFIN_CACHE_H
4682
4683 +#include <linux/const.h>
4684 #include <linux/linkage.h> /* for asmlinkage */
4685
4686 /*
4687 @@ -14,7 +15,7 @@
4688 * Blackfin loads 32 bytes for cache
4689 */
4690 #define L1_CACHE_SHIFT 5
4691 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4692 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4693 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4694
4695 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4696 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4697 index aea2718..3639a60 100644
4698 --- a/arch/cris/include/arch-v10/arch/cache.h
4699 +++ b/arch/cris/include/arch-v10/arch/cache.h
4700 @@ -1,8 +1,9 @@
4701 #ifndef _ASM_ARCH_CACHE_H
4702 #define _ASM_ARCH_CACHE_H
4703
4704 +#include <linux/const.h>
4705 /* Etrax 100LX have 32-byte cache-lines. */
4706 -#define L1_CACHE_BYTES 32
4707 #define L1_CACHE_SHIFT 5
4708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4709
4710 #endif /* _ASM_ARCH_CACHE_H */
4711 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4712 index 7caf25d..ee65ac5 100644
4713 --- a/arch/cris/include/arch-v32/arch/cache.h
4714 +++ b/arch/cris/include/arch-v32/arch/cache.h
4715 @@ -1,11 +1,12 @@
4716 #ifndef _ASM_CRIS_ARCH_CACHE_H
4717 #define _ASM_CRIS_ARCH_CACHE_H
4718
4719 +#include <linux/const.h>
4720 #include <arch/hwregs/dma.h>
4721
4722 /* A cache-line is 32 bytes. */
4723 -#define L1_CACHE_BYTES 32
4724 #define L1_CACHE_SHIFT 5
4725 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4726
4727 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4728
4729 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4730 index b86329d..6709906 100644
4731 --- a/arch/frv/include/asm/atomic.h
4732 +++ b/arch/frv/include/asm/atomic.h
4733 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4734 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4735 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4736
4737 +#define atomic64_read_unchecked(v) atomic64_read(v)
4738 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4739 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4740 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4741 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4742 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4743 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4744 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4745 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4746 +
4747 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4748 {
4749 int c, old;
4750 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4751 index 2797163..c2a401d 100644
4752 --- a/arch/frv/include/asm/cache.h
4753 +++ b/arch/frv/include/asm/cache.h
4754 @@ -12,10 +12,11 @@
4755 #ifndef __ASM_CACHE_H
4756 #define __ASM_CACHE_H
4757
4758 +#include <linux/const.h>
4759
4760 /* bytes per L1 cache line */
4761 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4762 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4763 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4764
4765 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4766 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4767 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4768 index 43901f2..0d8b865 100644
4769 --- a/arch/frv/include/asm/kmap_types.h
4770 +++ b/arch/frv/include/asm/kmap_types.h
4771 @@ -2,6 +2,6 @@
4772 #ifndef _ASM_KMAP_TYPES_H
4773 #define _ASM_KMAP_TYPES_H
4774
4775 -#define KM_TYPE_NR 17
4776 +#define KM_TYPE_NR 18
4777
4778 #endif
4779 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4780 index 836f147..4cf23f5 100644
4781 --- a/arch/frv/mm/elf-fdpic.c
4782 +++ b/arch/frv/mm/elf-fdpic.c
4783 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4784 {
4785 struct vm_area_struct *vma;
4786 struct vm_unmapped_area_info info;
4787 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4788
4789 if (len > TASK_SIZE)
4790 return -ENOMEM;
4791 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4792 if (addr) {
4793 addr = PAGE_ALIGN(addr);
4794 vma = find_vma(current->mm, addr);
4795 - if (TASK_SIZE - len >= addr &&
4796 - (!vma || addr + len <= vma->vm_start))
4797 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4798 goto success;
4799 }
4800
4801 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4802 info.high_limit = (current->mm->start_stack - 0x00200000);
4803 info.align_mask = 0;
4804 info.align_offset = 0;
4805 + info.threadstack_offset = offset;
4806 addr = vm_unmapped_area(&info);
4807 if (!(addr & ~PAGE_MASK))
4808 goto success;
4809 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4810 index f4ca594..adc72fd6 100644
4811 --- a/arch/hexagon/include/asm/cache.h
4812 +++ b/arch/hexagon/include/asm/cache.h
4813 @@ -21,9 +21,11 @@
4814 #ifndef __ASM_CACHE_H
4815 #define __ASM_CACHE_H
4816
4817 +#include <linux/const.h>
4818 +
4819 /* Bytes per L1 cache line */
4820 -#define L1_CACHE_SHIFT (5)
4821 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4822 +#define L1_CACHE_SHIFT 5
4823 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4824
4825 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4826 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4827 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4828 index 6e6fe18..a6ae668 100644
4829 --- a/arch/ia64/include/asm/atomic.h
4830 +++ b/arch/ia64/include/asm/atomic.h
4831 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4832 #define atomic64_inc(v) atomic64_add(1, (v))
4833 #define atomic64_dec(v) atomic64_sub(1, (v))
4834
4835 +#define atomic64_read_unchecked(v) atomic64_read(v)
4836 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4837 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4838 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4839 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4840 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4841 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4842 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4843 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4844 +
4845 /* Atomic operations are already serializing */
4846 #define smp_mb__before_atomic_dec() barrier()
4847 #define smp_mb__after_atomic_dec() barrier()
4848 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4849 index 988254a..e1ee885 100644
4850 --- a/arch/ia64/include/asm/cache.h
4851 +++ b/arch/ia64/include/asm/cache.h
4852 @@ -1,6 +1,7 @@
4853 #ifndef _ASM_IA64_CACHE_H
4854 #define _ASM_IA64_CACHE_H
4855
4856 +#include <linux/const.h>
4857
4858 /*
4859 * Copyright (C) 1998-2000 Hewlett-Packard Co
4860 @@ -9,7 +10,7 @@
4861
4862 /* Bytes per L1 (data) cache line. */
4863 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4864 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4865 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4866
4867 #ifdef CONFIG_SMP
4868 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4869 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4870 index 5a83c5c..4d7f553 100644
4871 --- a/arch/ia64/include/asm/elf.h
4872 +++ b/arch/ia64/include/asm/elf.h
4873 @@ -42,6 +42,13 @@
4874 */
4875 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4876
4877 +#ifdef CONFIG_PAX_ASLR
4878 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4879 +
4880 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4881 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4882 +#endif
4883 +
4884 #define PT_IA_64_UNWIND 0x70000001
4885
4886 /* IA-64 relocations: */
4887 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4888 index 96a8d92..617a1cf 100644
4889 --- a/arch/ia64/include/asm/pgalloc.h
4890 +++ b/arch/ia64/include/asm/pgalloc.h
4891 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4892 pgd_val(*pgd_entry) = __pa(pud);
4893 }
4894
4895 +static inline void
4896 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4897 +{
4898 + pgd_populate(mm, pgd_entry, pud);
4899 +}
4900 +
4901 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4902 {
4903 return quicklist_alloc(0, GFP_KERNEL, NULL);
4904 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4905 pud_val(*pud_entry) = __pa(pmd);
4906 }
4907
4908 +static inline void
4909 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4910 +{
4911 + pud_populate(mm, pud_entry, pmd);
4912 +}
4913 +
4914 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4915 {
4916 return quicklist_alloc(0, GFP_KERNEL, NULL);
4917 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4918 index 7935115..c0eca6a 100644
4919 --- a/arch/ia64/include/asm/pgtable.h
4920 +++ b/arch/ia64/include/asm/pgtable.h
4921 @@ -12,7 +12,7 @@
4922 * David Mosberger-Tang <davidm@hpl.hp.com>
4923 */
4924
4925 -
4926 +#include <linux/const.h>
4927 #include <asm/mman.h>
4928 #include <asm/page.h>
4929 #include <asm/processor.h>
4930 @@ -142,6 +142,17 @@
4931 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4932 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4933 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4934 +
4935 +#ifdef CONFIG_PAX_PAGEEXEC
4936 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4937 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4938 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4939 +#else
4940 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4941 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4942 +# define PAGE_COPY_NOEXEC PAGE_COPY
4943 +#endif
4944 +
4945 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4946 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4947 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4948 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4949 index 45698cd..e8e2dbc 100644
4950 --- a/arch/ia64/include/asm/spinlock.h
4951 +++ b/arch/ia64/include/asm/spinlock.h
4952 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4953 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4954
4955 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4956 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4957 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4958 }
4959
4960 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4961 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4962 index 449c8c0..18965fb 100644
4963 --- a/arch/ia64/include/asm/uaccess.h
4964 +++ b/arch/ia64/include/asm/uaccess.h
4965 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4966 static inline unsigned long
4967 __copy_to_user (void __user *to, const void *from, unsigned long count)
4968 {
4969 + if (count > INT_MAX)
4970 + return count;
4971 +
4972 + if (!__builtin_constant_p(count))
4973 + check_object_size(from, count, true);
4974 +
4975 return __copy_user(to, (__force void __user *) from, count);
4976 }
4977
4978 static inline unsigned long
4979 __copy_from_user (void *to, const void __user *from, unsigned long count)
4980 {
4981 + if (count > INT_MAX)
4982 + return count;
4983 +
4984 + if (!__builtin_constant_p(count))
4985 + check_object_size(to, count, false);
4986 +
4987 return __copy_user((__force void __user *) to, from, count);
4988 }
4989
4990 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4991 ({ \
4992 void __user *__cu_to = (to); \
4993 const void *__cu_from = (from); \
4994 - long __cu_len = (n); \
4995 + unsigned long __cu_len = (n); \
4996 \
4997 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4998 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4999 + if (!__builtin_constant_p(n)) \
5000 + check_object_size(__cu_from, __cu_len, true); \
5001 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5002 + } \
5003 __cu_len; \
5004 })
5005
5006 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5007 ({ \
5008 void *__cu_to = (to); \
5009 const void __user *__cu_from = (from); \
5010 - long __cu_len = (n); \
5011 + unsigned long __cu_len = (n); \
5012 \
5013 __chk_user_ptr(__cu_from); \
5014 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5015 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5016 + if (!__builtin_constant_p(n)) \
5017 + check_object_size(__cu_to, __cu_len, false); \
5018 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5019 + } \
5020 __cu_len; \
5021 })
5022
5023 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5024 index 24603be..948052d 100644
5025 --- a/arch/ia64/kernel/module.c
5026 +++ b/arch/ia64/kernel/module.c
5027 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5028 void
5029 module_free (struct module *mod, void *module_region)
5030 {
5031 - if (mod && mod->arch.init_unw_table &&
5032 - module_region == mod->module_init) {
5033 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5034 unw_remove_unwind_table(mod->arch.init_unw_table);
5035 mod->arch.init_unw_table = NULL;
5036 }
5037 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5038 }
5039
5040 static inline int
5041 +in_init_rx (const struct module *mod, uint64_t addr)
5042 +{
5043 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5044 +}
5045 +
5046 +static inline int
5047 +in_init_rw (const struct module *mod, uint64_t addr)
5048 +{
5049 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5050 +}
5051 +
5052 +static inline int
5053 in_init (const struct module *mod, uint64_t addr)
5054 {
5055 - return addr - (uint64_t) mod->module_init < mod->init_size;
5056 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5057 +}
5058 +
5059 +static inline int
5060 +in_core_rx (const struct module *mod, uint64_t addr)
5061 +{
5062 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5063 +}
5064 +
5065 +static inline int
5066 +in_core_rw (const struct module *mod, uint64_t addr)
5067 +{
5068 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5069 }
5070
5071 static inline int
5072 in_core (const struct module *mod, uint64_t addr)
5073 {
5074 - return addr - (uint64_t) mod->module_core < mod->core_size;
5075 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5076 }
5077
5078 static inline int
5079 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5080 break;
5081
5082 case RV_BDREL:
5083 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5084 + if (in_init_rx(mod, val))
5085 + val -= (uint64_t) mod->module_init_rx;
5086 + else if (in_init_rw(mod, val))
5087 + val -= (uint64_t) mod->module_init_rw;
5088 + else if (in_core_rx(mod, val))
5089 + val -= (uint64_t) mod->module_core_rx;
5090 + else if (in_core_rw(mod, val))
5091 + val -= (uint64_t) mod->module_core_rw;
5092 break;
5093
5094 case RV_LTV:
5095 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5096 * addresses have been selected...
5097 */
5098 uint64_t gp;
5099 - if (mod->core_size > MAX_LTOFF)
5100 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5101 /*
5102 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5103 * at the end of the module.
5104 */
5105 - gp = mod->core_size - MAX_LTOFF / 2;
5106 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5107 else
5108 - gp = mod->core_size / 2;
5109 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5110 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5111 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5112 mod->arch.gp = gp;
5113 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5114 }
5115 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5116 index ab33328..f39506c 100644
5117 --- a/arch/ia64/kernel/palinfo.c
5118 +++ b/arch/ia64/kernel/palinfo.c
5119 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5120 return NOTIFY_OK;
5121 }
5122
5123 -static struct notifier_block __refdata palinfo_cpu_notifier =
5124 +static struct notifier_block palinfo_cpu_notifier =
5125 {
5126 .notifier_call = palinfo_cpu_callback,
5127 .priority = 0,
5128 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5129 index 41e33f8..65180b2 100644
5130 --- a/arch/ia64/kernel/sys_ia64.c
5131 +++ b/arch/ia64/kernel/sys_ia64.c
5132 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5133 unsigned long align_mask = 0;
5134 struct mm_struct *mm = current->mm;
5135 struct vm_unmapped_area_info info;
5136 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5137
5138 if (len > RGN_MAP_LIMIT)
5139 return -ENOMEM;
5140 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5141 if (REGION_NUMBER(addr) == RGN_HPAGE)
5142 addr = 0;
5143 #endif
5144 +
5145 +#ifdef CONFIG_PAX_RANDMMAP
5146 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5147 + addr = mm->free_area_cache;
5148 + else
5149 +#endif
5150 +
5151 if (!addr)
5152 addr = TASK_UNMAPPED_BASE;
5153
5154 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5155 info.high_limit = TASK_SIZE;
5156 info.align_mask = align_mask;
5157 info.align_offset = 0;
5158 + info.threadstack_offset = offset;
5159 return vm_unmapped_area(&info);
5160 }
5161
5162 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5163 index 0ccb28f..8992469 100644
5164 --- a/arch/ia64/kernel/vmlinux.lds.S
5165 +++ b/arch/ia64/kernel/vmlinux.lds.S
5166 @@ -198,7 +198,7 @@ SECTIONS {
5167 /* Per-cpu data: */
5168 . = ALIGN(PERCPU_PAGE_SIZE);
5169 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5170 - __phys_per_cpu_start = __per_cpu_load;
5171 + __phys_per_cpu_start = per_cpu_load;
5172 /*
5173 * ensure percpu data fits
5174 * into percpu page size
5175 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5176 index 7225dad..2a7c8256 100644
5177 --- a/arch/ia64/mm/fault.c
5178 +++ b/arch/ia64/mm/fault.c
5179 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5180 return pte_present(pte);
5181 }
5182
5183 +#ifdef CONFIG_PAX_PAGEEXEC
5184 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5185 +{
5186 + unsigned long i;
5187 +
5188 + printk(KERN_ERR "PAX: bytes at PC: ");
5189 + for (i = 0; i < 8; i++) {
5190 + unsigned int c;
5191 + if (get_user(c, (unsigned int *)pc+i))
5192 + printk(KERN_CONT "???????? ");
5193 + else
5194 + printk(KERN_CONT "%08x ", c);
5195 + }
5196 + printk("\n");
5197 +}
5198 +#endif
5199 +
5200 # define VM_READ_BIT 0
5201 # define VM_WRITE_BIT 1
5202 # define VM_EXEC_BIT 2
5203 @@ -151,8 +168,21 @@ retry:
5204 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5205 goto bad_area;
5206
5207 - if ((vma->vm_flags & mask) != mask)
5208 + if ((vma->vm_flags & mask) != mask) {
5209 +
5210 +#ifdef CONFIG_PAX_PAGEEXEC
5211 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5212 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5213 + goto bad_area;
5214 +
5215 + up_read(&mm->mmap_sem);
5216 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5217 + do_group_exit(SIGKILL);
5218 + }
5219 +#endif
5220 +
5221 goto bad_area;
5222 + }
5223
5224 /*
5225 * If for any reason at all we couldn't handle the fault, make
5226 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5227 index 68232db..6ca80af 100644
5228 --- a/arch/ia64/mm/hugetlbpage.c
5229 +++ b/arch/ia64/mm/hugetlbpage.c
5230 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5231 unsigned long pgoff, unsigned long flags)
5232 {
5233 struct vm_unmapped_area_info info;
5234 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5235
5236 if (len > RGN_MAP_LIMIT)
5237 return -ENOMEM;
5238 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5239 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5240 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5241 info.align_offset = 0;
5242 + info.threadstack_offset = offset;
5243 return vm_unmapped_area(&info);
5244 }
5245
5246 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5247 index b6f7f43..c04320d 100644
5248 --- a/arch/ia64/mm/init.c
5249 +++ b/arch/ia64/mm/init.c
5250 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5251 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5252 vma->vm_end = vma->vm_start + PAGE_SIZE;
5253 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5254 +
5255 +#ifdef CONFIG_PAX_PAGEEXEC
5256 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5257 + vma->vm_flags &= ~VM_EXEC;
5258 +
5259 +#ifdef CONFIG_PAX_MPROTECT
5260 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5261 + vma->vm_flags &= ~VM_MAYEXEC;
5262 +#endif
5263 +
5264 + }
5265 +#endif
5266 +
5267 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5268 down_write(&current->mm->mmap_sem);
5269 if (insert_vm_struct(current->mm, vma)) {
5270 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5271 index 40b3ee9..8c2c112 100644
5272 --- a/arch/m32r/include/asm/cache.h
5273 +++ b/arch/m32r/include/asm/cache.h
5274 @@ -1,8 +1,10 @@
5275 #ifndef _ASM_M32R_CACHE_H
5276 #define _ASM_M32R_CACHE_H
5277
5278 +#include <linux/const.h>
5279 +
5280 /* L1 cache line size */
5281 #define L1_CACHE_SHIFT 4
5282 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5283 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5284
5285 #endif /* _ASM_M32R_CACHE_H */
5286 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5287 index 82abd15..d95ae5d 100644
5288 --- a/arch/m32r/lib/usercopy.c
5289 +++ b/arch/m32r/lib/usercopy.c
5290 @@ -14,6 +14,9 @@
5291 unsigned long
5292 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5293 {
5294 + if ((long)n < 0)
5295 + return n;
5296 +
5297 prefetch(from);
5298 if (access_ok(VERIFY_WRITE, to, n))
5299 __copy_user(to,from,n);
5300 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5301 unsigned long
5302 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5303 {
5304 + if ((long)n < 0)
5305 + return n;
5306 +
5307 prefetchw(to);
5308 if (access_ok(VERIFY_READ, from, n))
5309 __copy_user_zeroing(to,from,n);
5310 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5311 index 0395c51..5f26031 100644
5312 --- a/arch/m68k/include/asm/cache.h
5313 +++ b/arch/m68k/include/asm/cache.h
5314 @@ -4,9 +4,11 @@
5315 #ifndef __ARCH_M68K_CACHE_H
5316 #define __ARCH_M68K_CACHE_H
5317
5318 +#include <linux/const.h>
5319 +
5320 /* bytes per L1 cache line */
5321 #define L1_CACHE_SHIFT 4
5322 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5323 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5324
5325 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5326
5327 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5328 index 0424315..defcca9 100644
5329 --- a/arch/metag/mm/hugetlbpage.c
5330 +++ b/arch/metag/mm/hugetlbpage.c
5331 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5332 info.high_limit = TASK_SIZE;
5333 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5334 info.align_offset = 0;
5335 + info.threadstack_offset = 0;
5336 return vm_unmapped_area(&info);
5337 }
5338
5339 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5340 index 4efe96a..60e8699 100644
5341 --- a/arch/microblaze/include/asm/cache.h
5342 +++ b/arch/microblaze/include/asm/cache.h
5343 @@ -13,11 +13,12 @@
5344 #ifndef _ASM_MICROBLAZE_CACHE_H
5345 #define _ASM_MICROBLAZE_CACHE_H
5346
5347 +#include <linux/const.h>
5348 #include <asm/registers.h>
5349
5350 #define L1_CACHE_SHIFT 5
5351 /* word-granular cache in microblaze */
5352 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5353 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5354
5355 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5356
5357 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5358 index 08b6079..8b554d2 100644
5359 --- a/arch/mips/include/asm/atomic.h
5360 +++ b/arch/mips/include/asm/atomic.h
5361 @@ -21,15 +21,39 @@
5362 #include <asm/cmpxchg.h>
5363 #include <asm/war.h>
5364
5365 +#ifdef CONFIG_GENERIC_ATOMIC64
5366 +#include <asm-generic/atomic64.h>
5367 +#endif
5368 +
5369 #define ATOMIC_INIT(i) { (i) }
5370
5371 +#ifdef CONFIG_64BIT
5372 +#define _ASM_EXTABLE(from, to) \
5373 +" .section __ex_table,\"a\"\n" \
5374 +" .dword " #from ", " #to"\n" \
5375 +" .previous\n"
5376 +#else
5377 +#define _ASM_EXTABLE(from, to) \
5378 +" .section __ex_table,\"a\"\n" \
5379 +" .word " #from ", " #to"\n" \
5380 +" .previous\n"
5381 +#endif
5382 +
5383 /*
5384 * atomic_read - read atomic variable
5385 * @v: pointer of type atomic_t
5386 *
5387 * Atomically reads the value of @v.
5388 */
5389 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5390 +static inline int atomic_read(const atomic_t *v)
5391 +{
5392 + return (*(volatile const int *) &v->counter);
5393 +}
5394 +
5395 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5396 +{
5397 + return (*(volatile const int *) &v->counter);
5398 +}
5399
5400 /*
5401 * atomic_set - set atomic variable
5402 @@ -38,7 +62,15 @@
5403 *
5404 * Atomically sets the value of @v to @i.
5405 */
5406 -#define atomic_set(v, i) ((v)->counter = (i))
5407 +static inline void atomic_set(atomic_t *v, int i)
5408 +{
5409 + v->counter = i;
5410 +}
5411 +
5412 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5413 +{
5414 + v->counter = i;
5415 +}
5416
5417 /*
5418 * atomic_add - add integer to atomic variable
5419 @@ -47,7 +79,67 @@
5420 *
5421 * Atomically adds @i to @v.
5422 */
5423 -static __inline__ void atomic_add(int i, atomic_t * v)
5424 +static __inline__ void atomic_add(int i, atomic_t *v)
5425 +{
5426 + int temp;
5427 +
5428 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5429 + __asm__ __volatile__(
5430 + " .set mips3 \n"
5431 + "1: ll %0, %1 # atomic_add \n"
5432 +#ifdef CONFIG_PAX_REFCOUNT
5433 + /* Exception on overflow. */
5434 + "2: add %0, %2 \n"
5435 +#else
5436 + " addu %0, %2 \n"
5437 +#endif
5438 + " sc %0, %1 \n"
5439 + " beqzl %0, 1b \n"
5440 +#ifdef CONFIG_PAX_REFCOUNT
5441 + "3: \n"
5442 + _ASM_EXTABLE(2b, 3b)
5443 +#endif
5444 + " .set mips0 \n"
5445 + : "=&r" (temp), "+m" (v->counter)
5446 + : "Ir" (i));
5447 + } else if (kernel_uses_llsc) {
5448 + __asm__ __volatile__(
5449 + " .set mips3 \n"
5450 + "1: ll %0, %1 # atomic_add \n"
5451 +#ifdef CONFIG_PAX_REFCOUNT
5452 + /* Exception on overflow. */
5453 + "2: add %0, %2 \n"
5454 +#else
5455 + " addu %0, %2 \n"
5456 +#endif
5457 + " sc %0, %1 \n"
5458 + " beqz %0, 1b \n"
5459 +#ifdef CONFIG_PAX_REFCOUNT
5460 + "3: \n"
5461 + _ASM_EXTABLE(2b, 3b)
5462 +#endif
5463 + " .set mips0 \n"
5464 + : "=&r" (temp), "+m" (v->counter)
5465 + : "Ir" (i));
5466 + } else {
5467 + unsigned long flags;
5468 +
5469 + raw_local_irq_save(flags);
5470 + __asm__ __volatile__(
5471 +#ifdef CONFIG_PAX_REFCOUNT
5472 + /* Exception on overflow. */
5473 + "1: add %0, %1 \n"
5474 + "2: \n"
5475 + _ASM_EXTABLE(1b, 2b)
5476 +#else
5477 + " addu %0, %1 \n"
5478 +#endif
5479 + : "+r" (v->counter) : "Ir" (i));
5480 + raw_local_irq_restore(flags);
5481 + }
5482 +}
5483 +
5484 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5485 {
5486 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5487 int temp;
5488 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5489 *
5490 * Atomically subtracts @i from @v.
5491 */
5492 -static __inline__ void atomic_sub(int i, atomic_t * v)
5493 +static __inline__ void atomic_sub(int i, atomic_t *v)
5494 +{
5495 + int temp;
5496 +
5497 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5498 + __asm__ __volatile__(
5499 + " .set mips3 \n"
5500 + "1: ll %0, %1 # atomic64_sub \n"
5501 +#ifdef CONFIG_PAX_REFCOUNT
5502 + /* Exception on overflow. */
5503 + "2: sub %0, %2 \n"
5504 +#else
5505 + " subu %0, %2 \n"
5506 +#endif
5507 + " sc %0, %1 \n"
5508 + " beqzl %0, 1b \n"
5509 +#ifdef CONFIG_PAX_REFCOUNT
5510 + "3: \n"
5511 + _ASM_EXTABLE(2b, 3b)
5512 +#endif
5513 + " .set mips0 \n"
5514 + : "=&r" (temp), "+m" (v->counter)
5515 + : "Ir" (i));
5516 + } else if (kernel_uses_llsc) {
5517 + __asm__ __volatile__(
5518 + " .set mips3 \n"
5519 + "1: ll %0, %1 # atomic64_sub \n"
5520 +#ifdef CONFIG_PAX_REFCOUNT
5521 + /* Exception on overflow. */
5522 + "2: sub %0, %2 \n"
5523 +#else
5524 + " subu %0, %2 \n"
5525 +#endif
5526 + " sc %0, %1 \n"
5527 + " beqz %0, 1b \n"
5528 +#ifdef CONFIG_PAX_REFCOUNT
5529 + "3: \n"
5530 + _ASM_EXTABLE(2b, 3b)
5531 +#endif
5532 + " .set mips0 \n"
5533 + : "=&r" (temp), "+m" (v->counter)
5534 + : "Ir" (i));
5535 + } else {
5536 + unsigned long flags;
5537 +
5538 + raw_local_irq_save(flags);
5539 + __asm__ __volatile__(
5540 +#ifdef CONFIG_PAX_REFCOUNT
5541 + /* Exception on overflow. */
5542 + "1: sub %0, %1 \n"
5543 + "2: \n"
5544 + _ASM_EXTABLE(1b, 2b)
5545 +#else
5546 + " subu %0, %1 \n"
5547 +#endif
5548 + : "+r" (v->counter) : "Ir" (i));
5549 + raw_local_irq_restore(flags);
5550 + }
5551 +}
5552 +
5553 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5554 {
5555 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5556 int temp;
5557 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5558 /*
5559 * Same as above, but return the result value
5560 */
5561 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5562 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5563 +{
5564 + int result;
5565 + int temp;
5566 +
5567 + smp_mb__before_llsc();
5568 +
5569 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5570 + __asm__ __volatile__(
5571 + " .set mips3 \n"
5572 + "1: ll %1, %2 # atomic_add_return \n"
5573 +#ifdef CONFIG_PAX_REFCOUNT
5574 + "2: add %0, %1, %3 \n"
5575 +#else
5576 + " addu %0, %1, %3 \n"
5577 +#endif
5578 + " sc %0, %2 \n"
5579 + " beqzl %0, 1b \n"
5580 +#ifdef CONFIG_PAX_REFCOUNT
5581 + " b 4f \n"
5582 + " .set noreorder \n"
5583 + "3: b 5f \n"
5584 + " move %0, %1 \n"
5585 + " .set reorder \n"
5586 + _ASM_EXTABLE(2b, 3b)
5587 +#endif
5588 + "4: addu %0, %1, %3 \n"
5589 +#ifdef CONFIG_PAX_REFCOUNT
5590 + "5: \n"
5591 +#endif
5592 + " .set mips0 \n"
5593 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5594 + : "Ir" (i));
5595 + } else if (kernel_uses_llsc) {
5596 + __asm__ __volatile__(
5597 + " .set mips3 \n"
5598 + "1: ll %1, %2 # atomic_add_return \n"
5599 +#ifdef CONFIG_PAX_REFCOUNT
5600 + "2: add %0, %1, %3 \n"
5601 +#else
5602 + " addu %0, %1, %3 \n"
5603 +#endif
5604 + " sc %0, %2 \n"
5605 + " bnez %0, 4f \n"
5606 + " b 1b \n"
5607 +#ifdef CONFIG_PAX_REFCOUNT
5608 + " .set noreorder \n"
5609 + "3: b 5f \n"
5610 + " move %0, %1 \n"
5611 + " .set reorder \n"
5612 + _ASM_EXTABLE(2b, 3b)
5613 +#endif
5614 + "4: addu %0, %1, %3 \n"
5615 +#ifdef CONFIG_PAX_REFCOUNT
5616 + "5: \n"
5617 +#endif
5618 + " .set mips0 \n"
5619 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5620 + : "Ir" (i));
5621 + } else {
5622 + unsigned long flags;
5623 +
5624 + raw_local_irq_save(flags);
5625 + __asm__ __volatile__(
5626 + " lw %0, %1 \n"
5627 +#ifdef CONFIG_PAX_REFCOUNT
5628 + /* Exception on overflow. */
5629 + "1: add %0, %2 \n"
5630 +#else
5631 + " addu %0, %2 \n"
5632 +#endif
5633 + " sw %0, %1 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + /* Note: Dest reg is not modified on overflow */
5636 + "2: \n"
5637 + _ASM_EXTABLE(1b, 2b)
5638 +#endif
5639 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5640 + raw_local_irq_restore(flags);
5641 + }
5642 +
5643 + smp_llsc_mb();
5644 +
5645 + return result;
5646 +}
5647 +
5648 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5649 {
5650 int result;
5651
5652 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5653 return result;
5654 }
5655
5656 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5657 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5658 +{
5659 + int result;
5660 + int temp;
5661 +
5662 + smp_mb__before_llsc();
5663 +
5664 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5665 + __asm__ __volatile__(
5666 + " .set mips3 \n"
5667 + "1: ll %1, %2 # atomic_sub_return \n"
5668 +#ifdef CONFIG_PAX_REFCOUNT
5669 + "2: sub %0, %1, %3 \n"
5670 +#else
5671 + " subu %0, %1, %3 \n"
5672 +#endif
5673 + " sc %0, %2 \n"
5674 + " beqzl %0, 1b \n"
5675 +#ifdef CONFIG_PAX_REFCOUNT
5676 + " b 4f \n"
5677 + " .set noreorder \n"
5678 + "3: b 5f \n"
5679 + " move %0, %1 \n"
5680 + " .set reorder \n"
5681 + _ASM_EXTABLE(2b, 3b)
5682 +#endif
5683 + "4: subu %0, %1, %3 \n"
5684 +#ifdef CONFIG_PAX_REFCOUNT
5685 + "5: \n"
5686 +#endif
5687 + " .set mips0 \n"
5688 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5689 + : "Ir" (i), "m" (v->counter)
5690 + : "memory");
5691 + } else if (kernel_uses_llsc) {
5692 + __asm__ __volatile__(
5693 + " .set mips3 \n"
5694 + "1: ll %1, %2 # atomic_sub_return \n"
5695 +#ifdef CONFIG_PAX_REFCOUNT
5696 + "2: sub %0, %1, %3 \n"
5697 +#else
5698 + " subu %0, %1, %3 \n"
5699 +#endif
5700 + " sc %0, %2 \n"
5701 + " bnez %0, 4f \n"
5702 + " b 1b \n"
5703 +#ifdef CONFIG_PAX_REFCOUNT
5704 + " .set noreorder \n"
5705 + "3: b 5f \n"
5706 + " move %0, %1 \n"
5707 + " .set reorder \n"
5708 + _ASM_EXTABLE(2b, 3b)
5709 +#endif
5710 + "4: subu %0, %1, %3 \n"
5711 +#ifdef CONFIG_PAX_REFCOUNT
5712 + "5: \n"
5713 +#endif
5714 + " .set mips0 \n"
5715 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5716 + : "Ir" (i));
5717 + } else {
5718 + unsigned long flags;
5719 +
5720 + raw_local_irq_save(flags);
5721 + __asm__ __volatile__(
5722 + " lw %0, %1 \n"
5723 +#ifdef CONFIG_PAX_REFCOUNT
5724 + /* Exception on overflow. */
5725 + "1: sub %0, %2 \n"
5726 +#else
5727 + " subu %0, %2 \n"
5728 +#endif
5729 + " sw %0, %1 \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + /* Note: Dest reg is not modified on overflow */
5732 + "2: \n"
5733 + _ASM_EXTABLE(1b, 2b)
5734 +#endif
5735 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5736 + raw_local_irq_restore(flags);
5737 + }
5738 +
5739 + smp_llsc_mb();
5740 +
5741 + return result;
5742 +}
5743 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5744 {
5745 int result;
5746
5747 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5748 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5749 * The function returns the old value of @v minus @i.
5750 */
5751 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5752 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5753 {
5754 int result;
5755
5756 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5757 return result;
5758 }
5759
5760 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5761 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5762 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5763 +{
5764 + return cmpxchg(&v->counter, old, new);
5765 +}
5766 +
5767 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5768 + int new)
5769 +{
5770 + return cmpxchg(&(v->counter), old, new);
5771 +}
5772 +
5773 +static inline int atomic_xchg(atomic_t *v, int new)
5774 +{
5775 + return xchg(&v->counter, new);
5776 +}
5777 +
5778 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5779 +{
5780 + return xchg(&(v->counter), new);
5781 +}
5782
5783 /**
5784 * __atomic_add_unless - add unless the number is a given value
5785 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5786
5787 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5788 #define atomic_inc_return(v) atomic_add_return(1, (v))
5789 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5790 +{
5791 + return atomic_add_return_unchecked(1, v);
5792 +}
5793
5794 /*
5795 * atomic_sub_and_test - subtract value from variable and test result
5796 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5797 * other cases.
5798 */
5799 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5800 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5801 +{
5802 + return atomic_add_return_unchecked(1, v) == 0;
5803 +}
5804
5805 /*
5806 * atomic_dec_and_test - decrement by 1 and test
5807 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5808 * Atomically increments @v by 1.
5809 */
5810 #define atomic_inc(v) atomic_add(1, (v))
5811 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5812 +{
5813 + atomic_add_unchecked(1, v);
5814 +}
5815
5816 /*
5817 * atomic_dec - decrement and test
5818 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5819 * Atomically decrements @v by 1.
5820 */
5821 #define atomic_dec(v) atomic_sub(1, (v))
5822 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5823 +{
5824 + atomic_sub_unchecked(1, v);
5825 +}
5826
5827 /*
5828 * atomic_add_negative - add and test if negative
5829 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5830 * @v: pointer of type atomic64_t
5831 *
5832 */
5833 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5834 +static inline long atomic64_read(const atomic64_t *v)
5835 +{
5836 + return (*(volatile const long *) &v->counter);
5837 +}
5838 +
5839 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5840 +{
5841 + return (*(volatile const long *) &v->counter);
5842 +}
5843
5844 /*
5845 * atomic64_set - set atomic variable
5846 * @v: pointer of type atomic64_t
5847 * @i: required value
5848 */
5849 -#define atomic64_set(v, i) ((v)->counter = (i))
5850 +static inline void atomic64_set(atomic64_t *v, long i)
5851 +{
5852 + v->counter = i;
5853 +}
5854 +
5855 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5856 +{
5857 + v->counter = i;
5858 +}
5859
5860 /*
5861 * atomic64_add - add integer to atomic variable
5862 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5863 *
5864 * Atomically adds @i to @v.
5865 */
5866 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5867 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5868 +{
5869 + long temp;
5870 +
5871 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5872 + __asm__ __volatile__(
5873 + " .set mips3 \n"
5874 + "1: lld %0, %1 # atomic64_add \n"
5875 +#ifdef CONFIG_PAX_REFCOUNT
5876 + /* Exception on overflow. */
5877 + "2: dadd %0, %2 \n"
5878 +#else
5879 + " daddu %0, %2 \n"
5880 +#endif
5881 + " scd %0, %1 \n"
5882 + " beqzl %0, 1b \n"
5883 +#ifdef CONFIG_PAX_REFCOUNT
5884 + "3: \n"
5885 + _ASM_EXTABLE(2b, 3b)
5886 +#endif
5887 + " .set mips0 \n"
5888 + : "=&r" (temp), "+m" (v->counter)
5889 + : "Ir" (i));
5890 + } else if (kernel_uses_llsc) {
5891 + __asm__ __volatile__(
5892 + " .set mips3 \n"
5893 + "1: lld %0, %1 # atomic64_add \n"
5894 +#ifdef CONFIG_PAX_REFCOUNT
5895 + /* Exception on overflow. */
5896 + "2: dadd %0, %2 \n"
5897 +#else
5898 + " daddu %0, %2 \n"
5899 +#endif
5900 + " scd %0, %1 \n"
5901 + " beqz %0, 1b \n"
5902 +#ifdef CONFIG_PAX_REFCOUNT
5903 + "3: \n"
5904 + _ASM_EXTABLE(2b, 3b)
5905 +#endif
5906 + " .set mips0 \n"
5907 + : "=&r" (temp), "+m" (v->counter)
5908 + : "Ir" (i));
5909 + } else {
5910 + unsigned long flags;
5911 +
5912 + raw_local_irq_save(flags);
5913 + __asm__ __volatile__(
5914 +#ifdef CONFIG_PAX_REFCOUNT
5915 + /* Exception on overflow. */
5916 + "1: dadd %0, %1 \n"
5917 + "2: \n"
5918 + _ASM_EXTABLE(1b, 2b)
5919 +#else
5920 + " daddu %0, %1 \n"
5921 +#endif
5922 + : "+r" (v->counter) : "Ir" (i));
5923 + raw_local_irq_restore(flags);
5924 + }
5925 +}
5926 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5927 {
5928 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5929 long temp;
5930 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5931 *
5932 * Atomically subtracts @i from @v.
5933 */
5934 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5935 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5936 +{
5937 + long temp;
5938 +
5939 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5940 + __asm__ __volatile__(
5941 + " .set mips3 \n"
5942 + "1: lld %0, %1 # atomic64_sub \n"
5943 +#ifdef CONFIG_PAX_REFCOUNT
5944 + /* Exception on overflow. */
5945 + "2: dsub %0, %2 \n"
5946 +#else
5947 + " dsubu %0, %2 \n"
5948 +#endif
5949 + " scd %0, %1 \n"
5950 + " beqzl %0, 1b \n"
5951 +#ifdef CONFIG_PAX_REFCOUNT
5952 + "3: \n"
5953 + _ASM_EXTABLE(2b, 3b)
5954 +#endif
5955 + " .set mips0 \n"
5956 + : "=&r" (temp), "+m" (v->counter)
5957 + : "Ir" (i));
5958 + } else if (kernel_uses_llsc) {
5959 + __asm__ __volatile__(
5960 + " .set mips3 \n"
5961 + "1: lld %0, %1 # atomic64_sub \n"
5962 +#ifdef CONFIG_PAX_REFCOUNT
5963 + /* Exception on overflow. */
5964 + "2: dsub %0, %2 \n"
5965 +#else
5966 + " dsubu %0, %2 \n"
5967 +#endif
5968 + " scd %0, %1 \n"
5969 + " beqz %0, 1b \n"
5970 +#ifdef CONFIG_PAX_REFCOUNT
5971 + "3: \n"
5972 + _ASM_EXTABLE(2b, 3b)
5973 +#endif
5974 + " .set mips0 \n"
5975 + : "=&r" (temp), "+m" (v->counter)
5976 + : "Ir" (i));
5977 + } else {
5978 + unsigned long flags;
5979 +
5980 + raw_local_irq_save(flags);
5981 + __asm__ __volatile__(
5982 +#ifdef CONFIG_PAX_REFCOUNT
5983 + /* Exception on overflow. */
5984 + "1: dsub %0, %1 \n"
5985 + "2: \n"
5986 + _ASM_EXTABLE(1b, 2b)
5987 +#else
5988 + " dsubu %0, %1 \n"
5989 +#endif
5990 + : "+r" (v->counter) : "Ir" (i));
5991 + raw_local_irq_restore(flags);
5992 + }
5993 +}
5994 +
5995 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5996 {
5997 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5998 long temp;
5999 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6000 /*
6001 * Same as above, but return the result value
6002 */
6003 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6004 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6005 +{
6006 + long result;
6007 + long temp;
6008 +
6009 + smp_mb__before_llsc();
6010 +
6011 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6012 + __asm__ __volatile__(
6013 + " .set mips3 \n"
6014 + "1: lld %1, %2 # atomic64_add_return \n"
6015 +#ifdef CONFIG_PAX_REFCOUNT
6016 + "2: dadd %0, %1, %3 \n"
6017 +#else
6018 + " daddu %0, %1, %3 \n"
6019 +#endif
6020 + " scd %0, %2 \n"
6021 + " beqzl %0, 1b \n"
6022 +#ifdef CONFIG_PAX_REFCOUNT
6023 + " b 4f \n"
6024 + " .set noreorder \n"
6025 + "3: b 5f \n"
6026 + " move %0, %1 \n"
6027 + " .set reorder \n"
6028 + _ASM_EXTABLE(2b, 3b)
6029 +#endif
6030 + "4: daddu %0, %1, %3 \n"
6031 +#ifdef CONFIG_PAX_REFCOUNT
6032 + "5: \n"
6033 +#endif
6034 + " .set mips0 \n"
6035 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6036 + : "Ir" (i));
6037 + } else if (kernel_uses_llsc) {
6038 + __asm__ __volatile__(
6039 + " .set mips3 \n"
6040 + "1: lld %1, %2 # atomic64_add_return \n"
6041 +#ifdef CONFIG_PAX_REFCOUNT
6042 + "2: dadd %0, %1, %3 \n"
6043 +#else
6044 + " daddu %0, %1, %3 \n"
6045 +#endif
6046 + " scd %0, %2 \n"
6047 + " bnez %0, 4f \n"
6048 + " b 1b \n"
6049 +#ifdef CONFIG_PAX_REFCOUNT
6050 + " .set noreorder \n"
6051 + "3: b 5f \n"
6052 + " move %0, %1 \n"
6053 + " .set reorder \n"
6054 + _ASM_EXTABLE(2b, 3b)
6055 +#endif
6056 + "4: daddu %0, %1, %3 \n"
6057 +#ifdef CONFIG_PAX_REFCOUNT
6058 + "5: \n"
6059 +#endif
6060 + " .set mips0 \n"
6061 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6062 + : "Ir" (i), "m" (v->counter)
6063 + : "memory");
6064 + } else {
6065 + unsigned long flags;
6066 +
6067 + raw_local_irq_save(flags);
6068 + __asm__ __volatile__(
6069 + " ld %0, %1 \n"
6070 +#ifdef CONFIG_PAX_REFCOUNT
6071 + /* Exception on overflow. */
6072 + "1: dadd %0, %2 \n"
6073 +#else
6074 + " daddu %0, %2 \n"
6075 +#endif
6076 + " sd %0, %1 \n"
6077 +#ifdef CONFIG_PAX_REFCOUNT
6078 + /* Note: Dest reg is not modified on overflow */
6079 + "2: \n"
6080 + _ASM_EXTABLE(1b, 2b)
6081 +#endif
6082 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6083 + raw_local_irq_restore(flags);
6084 + }
6085 +
6086 + smp_llsc_mb();
6087 +
6088 + return result;
6089 +}
6090 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6091 {
6092 long result;
6093
6094 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6095 return result;
6096 }
6097
6098 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6099 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6100 +{
6101 + long result;
6102 + long temp;
6103 +
6104 + smp_mb__before_llsc();
6105 +
6106 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6107 + long temp;
6108 +
6109 + __asm__ __volatile__(
6110 + " .set mips3 \n"
6111 + "1: lld %1, %2 # atomic64_sub_return \n"
6112 +#ifdef CONFIG_PAX_REFCOUNT
6113 + "2: dsub %0, %1, %3 \n"
6114 +#else
6115 + " dsubu %0, %1, %3 \n"
6116 +#endif
6117 + " scd %0, %2 \n"
6118 + " beqzl %0, 1b \n"
6119 +#ifdef CONFIG_PAX_REFCOUNT
6120 + " b 4f \n"
6121 + " .set noreorder \n"
6122 + "3: b 5f \n"
6123 + " move %0, %1 \n"
6124 + " .set reorder \n"
6125 + _ASM_EXTABLE(2b, 3b)
6126 +#endif
6127 + "4: dsubu %0, %1, %3 \n"
6128 +#ifdef CONFIG_PAX_REFCOUNT
6129 + "5: \n"
6130 +#endif
6131 + " .set mips0 \n"
6132 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6133 + : "Ir" (i), "m" (v->counter)
6134 + : "memory");
6135 + } else if (kernel_uses_llsc) {
6136 + __asm__ __volatile__(
6137 + " .set mips3 \n"
6138 + "1: lld %1, %2 # atomic64_sub_return \n"
6139 +#ifdef CONFIG_PAX_REFCOUNT
6140 + "2: dsub %0, %1, %3 \n"
6141 +#else
6142 + " dsubu %0, %1, %3 \n"
6143 +#endif
6144 + " scd %0, %2 \n"
6145 + " bnez %0, 4f \n"
6146 + " b 1b \n"
6147 +#ifdef CONFIG_PAX_REFCOUNT
6148 + " .set noreorder \n"
6149 + "3: b 5f \n"
6150 + " move %0, %1 \n"
6151 + " .set reorder \n"
6152 + _ASM_EXTABLE(2b, 3b)
6153 +#endif
6154 + "4: dsubu %0, %1, %3 \n"
6155 +#ifdef CONFIG_PAX_REFCOUNT
6156 + "5: \n"
6157 +#endif
6158 + " .set mips0 \n"
6159 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6160 + : "Ir" (i), "m" (v->counter)
6161 + : "memory");
6162 + } else {
6163 + unsigned long flags;
6164 +
6165 + raw_local_irq_save(flags);
6166 + __asm__ __volatile__(
6167 + " ld %0, %1 \n"
6168 +#ifdef CONFIG_PAX_REFCOUNT
6169 + /* Exception on overflow. */
6170 + "1: dsub %0, %2 \n"
6171 +#else
6172 + " dsubu %0, %2 \n"
6173 +#endif
6174 + " sd %0, %1 \n"
6175 +#ifdef CONFIG_PAX_REFCOUNT
6176 + /* Note: Dest reg is not modified on overflow */
6177 + "2: \n"
6178 + _ASM_EXTABLE(1b, 2b)
6179 +#endif
6180 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6181 + raw_local_irq_restore(flags);
6182 + }
6183 +
6184 + smp_llsc_mb();
6185 +
6186 + return result;
6187 +}
6188 +
6189 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6190 {
6191 long result;
6192
6193 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6194 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6195 * The function returns the old value of @v minus @i.
6196 */
6197 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6198 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6199 {
6200 long result;
6201
6202 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6203 return result;
6204 }
6205
6206 -#define atomic64_cmpxchg(v, o, n) \
6207 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6208 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6209 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6210 +{
6211 + return cmpxchg(&v->counter, old, new);
6212 +}
6213 +
6214 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6215 + long new)
6216 +{
6217 + return cmpxchg(&(v->counter), old, new);
6218 +}
6219 +
6220 +static inline long atomic64_xchg(atomic64_t *v, long new)
6221 +{
6222 + return xchg(&v->counter, new);
6223 +}
6224 +
6225 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6226 +{
6227 + return xchg(&(v->counter), new);
6228 +}
6229
6230 /**
6231 * atomic64_add_unless - add unless the number is a given value
6232 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6233
6234 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6235 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6236 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6237
6238 /*
6239 * atomic64_sub_and_test - subtract value from variable and test result
6240 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6241 * other cases.
6242 */
6243 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6244 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6245
6246 /*
6247 * atomic64_dec_and_test - decrement by 1 and test
6248 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6249 * Atomically increments @v by 1.
6250 */
6251 #define atomic64_inc(v) atomic64_add(1, (v))
6252 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6253
6254 /*
6255 * atomic64_dec - decrement and test
6256 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6257 * Atomically decrements @v by 1.
6258 */
6259 #define atomic64_dec(v) atomic64_sub(1, (v))
6260 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6261
6262 /*
6263 * atomic64_add_negative - add and test if negative
6264 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6265 index b4db69f..8f3b093 100644
6266 --- a/arch/mips/include/asm/cache.h
6267 +++ b/arch/mips/include/asm/cache.h
6268 @@ -9,10 +9,11 @@
6269 #ifndef _ASM_CACHE_H
6270 #define _ASM_CACHE_H
6271
6272 +#include <linux/const.h>
6273 #include <kmalloc.h>
6274
6275 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6276 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6277 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6278
6279 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6280 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6281 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6282 index cf3ae24..238d22f 100644
6283 --- a/arch/mips/include/asm/elf.h
6284 +++ b/arch/mips/include/asm/elf.h
6285 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6286 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6287 #endif
6288
6289 +#ifdef CONFIG_PAX_ASLR
6290 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6291 +
6292 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6293 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6294 +#endif
6295 +
6296 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6297 struct linux_binprm;
6298 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6299 int uses_interp);
6300
6301 -struct mm_struct;
6302 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6303 -#define arch_randomize_brk arch_randomize_brk
6304 -
6305 #endif /* _ASM_ELF_H */
6306 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6307 index c1f6afa..38cc6e9 100644
6308 --- a/arch/mips/include/asm/exec.h
6309 +++ b/arch/mips/include/asm/exec.h
6310 @@ -12,6 +12,6 @@
6311 #ifndef _ASM_EXEC_H
6312 #define _ASM_EXEC_H
6313
6314 -extern unsigned long arch_align_stack(unsigned long sp);
6315 +#define arch_align_stack(x) ((x) & ~0xfUL)
6316
6317 #endif /* _ASM_EXEC_H */
6318 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6319 index d44622c..64990d2 100644
6320 --- a/arch/mips/include/asm/local.h
6321 +++ b/arch/mips/include/asm/local.h
6322 @@ -12,15 +12,25 @@ typedef struct
6323 atomic_long_t a;
6324 } local_t;
6325
6326 +typedef struct {
6327 + atomic_long_unchecked_t a;
6328 +} local_unchecked_t;
6329 +
6330 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6331
6332 #define local_read(l) atomic_long_read(&(l)->a)
6333 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6334 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6335 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6336
6337 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6338 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6339 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6340 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6341 #define local_inc(l) atomic_long_inc(&(l)->a)
6342 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6343 #define local_dec(l) atomic_long_dec(&(l)->a)
6344 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6345
6346 /*
6347 * Same as above, but return the result value
6348 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6349 return result;
6350 }
6351
6352 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6353 +{
6354 + unsigned long result;
6355 +
6356 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6357 + unsigned long temp;
6358 +
6359 + __asm__ __volatile__(
6360 + " .set mips3 \n"
6361 + "1:" __LL "%1, %2 # local_add_return \n"
6362 + " addu %0, %1, %3 \n"
6363 + __SC "%0, %2 \n"
6364 + " beqzl %0, 1b \n"
6365 + " addu %0, %1, %3 \n"
6366 + " .set mips0 \n"
6367 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6368 + : "Ir" (i), "m" (l->a.counter)
6369 + : "memory");
6370 + } else if (kernel_uses_llsc) {
6371 + unsigned long temp;
6372 +
6373 + __asm__ __volatile__(
6374 + " .set mips3 \n"
6375 + "1:" __LL "%1, %2 # local_add_return \n"
6376 + " addu %0, %1, %3 \n"
6377 + __SC "%0, %2 \n"
6378 + " beqz %0, 1b \n"
6379 + " addu %0, %1, %3 \n"
6380 + " .set mips0 \n"
6381 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6382 + : "Ir" (i), "m" (l->a.counter)
6383 + : "memory");
6384 + } else {
6385 + unsigned long flags;
6386 +
6387 + local_irq_save(flags);
6388 + result = l->a.counter;
6389 + result += i;
6390 + l->a.counter = result;
6391 + local_irq_restore(flags);
6392 + }
6393 +
6394 + return result;
6395 +}
6396 +
6397 static __inline__ long local_sub_return(long i, local_t * l)
6398 {
6399 unsigned long result;
6400 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6401
6402 #define local_cmpxchg(l, o, n) \
6403 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6404 +#define local_cmpxchg_unchecked(l, o, n) \
6405 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6406 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6407
6408 /**
6409 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6410 index f6be474..12ad554 100644
6411 --- a/arch/mips/include/asm/page.h
6412 +++ b/arch/mips/include/asm/page.h
6413 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6414 #ifdef CONFIG_CPU_MIPS32
6415 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6416 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6417 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6418 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6419 #else
6420 typedef struct { unsigned long long pte; } pte_t;
6421 #define pte_val(x) ((x).pte)
6422 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6423 index 881d18b..cea38bc 100644
6424 --- a/arch/mips/include/asm/pgalloc.h
6425 +++ b/arch/mips/include/asm/pgalloc.h
6426 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6427 {
6428 set_pud(pud, __pud((unsigned long)pmd));
6429 }
6430 +
6431 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6432 +{
6433 + pud_populate(mm, pud, pmd);
6434 +}
6435 #endif
6436
6437 /*
6438 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6439 index 25da651..ae2a259 100644
6440 --- a/arch/mips/include/asm/smtc_proc.h
6441 +++ b/arch/mips/include/asm/smtc_proc.h
6442 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6443
6444 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6445
6446 -extern atomic_t smtc_fpu_recoveries;
6447 +extern atomic_unchecked_t smtc_fpu_recoveries;
6448
6449 #endif /* __ASM_SMTC_PROC_H */
6450 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6451 index 61215a3..213ee0e 100644
6452 --- a/arch/mips/include/asm/thread_info.h
6453 +++ b/arch/mips/include/asm/thread_info.h
6454 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6455 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6456 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6457 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6458 +/* li takes a 32bit immediate */
6459 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6460 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6461
6462 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6463 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6464 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6465 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6466 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6467 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6468
6469 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6470 - _TIF_SYSCALL_AUDIT)
6471 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6472
6473 /* work to do in syscall_trace_leave() */
6474 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6475 - _TIF_SYSCALL_AUDIT)
6476 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6477
6478 /* work to do on interrupt/exception return */
6479 #define _TIF_WORK_MASK \
6480 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6481 /* work to do on any return to u-space */
6482 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6483 - _TIF_WORK_SYSCALL_EXIT)
6484 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6485
6486 #endif /* __KERNEL__ */
6487
6488 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6489 index 1188e00..41cf144 100644
6490 --- a/arch/mips/kernel/binfmt_elfn32.c
6491 +++ b/arch/mips/kernel/binfmt_elfn32.c
6492 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6493 #undef ELF_ET_DYN_BASE
6494 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6495
6496 +#ifdef CONFIG_PAX_ASLR
6497 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6498 +
6499 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6500 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6501 +#endif
6502 +
6503 #include <asm/processor.h>
6504 #include <linux/module.h>
6505 #include <linux/elfcore.h>
6506 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6507 index 202e581..689ca79 100644
6508 --- a/arch/mips/kernel/binfmt_elfo32.c
6509 +++ b/arch/mips/kernel/binfmt_elfo32.c
6510 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6511 #undef ELF_ET_DYN_BASE
6512 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6513
6514 +#ifdef CONFIG_PAX_ASLR
6515 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6516 +
6517 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6518 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6519 +#endif
6520 +
6521 #include <asm/processor.h>
6522
6523 /*
6524 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6525 index d1fea7a..45602ea 100644
6526 --- a/arch/mips/kernel/irq.c
6527 +++ b/arch/mips/kernel/irq.c
6528 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6529 printk("unexpected IRQ # %d\n", irq);
6530 }
6531
6532 -atomic_t irq_err_count;
6533 +atomic_unchecked_t irq_err_count;
6534
6535 int arch_show_interrupts(struct seq_file *p, int prec)
6536 {
6537 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6538 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6539 return 0;
6540 }
6541
6542 asmlinkage void spurious_interrupt(void)
6543 {
6544 - atomic_inc(&irq_err_count);
6545 + atomic_inc_unchecked(&irq_err_count);
6546 }
6547
6548 void __init init_IRQ(void)
6549 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6550 index ddc7610..8c58f17 100644
6551 --- a/arch/mips/kernel/process.c
6552 +++ b/arch/mips/kernel/process.c
6553 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6554 out:
6555 return pc;
6556 }
6557 -
6558 -/*
6559 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6560 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6561 - */
6562 -unsigned long arch_align_stack(unsigned long sp)
6563 -{
6564 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6565 - sp -= get_random_int() & ~PAGE_MASK;
6566 -
6567 - return sp & ALMASK;
6568 -}
6569 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6570 index 8ae1ebe..1bcbf47 100644
6571 --- a/arch/mips/kernel/ptrace.c
6572 +++ b/arch/mips/kernel/ptrace.c
6573 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6574 return arch;
6575 }
6576
6577 +#ifdef CONFIG_GRKERNSEC_SETXID
6578 +extern void gr_delayed_cred_worker(void);
6579 +#endif
6580 +
6581 /*
6582 * Notification of system call entry/exit
6583 * - triggered by current->work.syscall_trace
6584 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6585 /* do the secure computing check first */
6586 secure_computing_strict(regs->regs[2]);
6587
6588 +#ifdef CONFIG_GRKERNSEC_SETXID
6589 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6590 + gr_delayed_cred_worker();
6591 +#endif
6592 +
6593 if (!(current->ptrace & PT_PTRACED))
6594 goto out;
6595
6596 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6597 index c10aa84..9ec2e60 100644
6598 --- a/arch/mips/kernel/smtc-proc.c
6599 +++ b/arch/mips/kernel/smtc-proc.c
6600 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6601
6602 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6603
6604 -atomic_t smtc_fpu_recoveries;
6605 +atomic_unchecked_t smtc_fpu_recoveries;
6606
6607 static int smtc_proc_show(struct seq_file *m, void *v)
6608 {
6609 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6610 for(i = 0; i < NR_CPUS; i++)
6611 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6612 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6613 - atomic_read(&smtc_fpu_recoveries));
6614 + atomic_read_unchecked(&smtc_fpu_recoveries));
6615 return 0;
6616 }
6617
6618 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6619 smtc_cpu_stats[i].selfipis = 0;
6620 }
6621
6622 - atomic_set(&smtc_fpu_recoveries, 0);
6623 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6624
6625 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6626 }
6627 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6628 index dfc1b91..11a2c07 100644
6629 --- a/arch/mips/kernel/smtc.c
6630 +++ b/arch/mips/kernel/smtc.c
6631 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6632 }
6633 smtc_ipi_qdump();
6634 printk("%d Recoveries of \"stolen\" FPU\n",
6635 - atomic_read(&smtc_fpu_recoveries));
6636 + atomic_read_unchecked(&smtc_fpu_recoveries));
6637 }
6638
6639
6640 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6641 index 84536bf..79caa4d 100644
6642 --- a/arch/mips/kernel/sync-r4k.c
6643 +++ b/arch/mips/kernel/sync-r4k.c
6644 @@ -21,8 +21,8 @@
6645 #include <asm/mipsregs.h>
6646
6647 static atomic_t count_start_flag = ATOMIC_INIT(0);
6648 -static atomic_t count_count_start = ATOMIC_INIT(0);
6649 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6650 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6651 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6652 static atomic_t count_reference = ATOMIC_INIT(0);
6653
6654 #define COUNTON 100
6655 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6656
6657 for (i = 0; i < NR_LOOPS; i++) {
6658 /* slaves loop on '!= 2' */
6659 - while (atomic_read(&count_count_start) != 1)
6660 + while (atomic_read_unchecked(&count_count_start) != 1)
6661 mb();
6662 - atomic_set(&count_count_stop, 0);
6663 + atomic_set_unchecked(&count_count_stop, 0);
6664 smp_wmb();
6665
6666 /* this lets the slaves write their count register */
6667 - atomic_inc(&count_count_start);
6668 + atomic_inc_unchecked(&count_count_start);
6669
6670 /*
6671 * Everyone initialises count in the last loop:
6672 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6673 /*
6674 * Wait for all slaves to leave the synchronization point:
6675 */
6676 - while (atomic_read(&count_count_stop) != 1)
6677 + while (atomic_read_unchecked(&count_count_stop) != 1)
6678 mb();
6679 - atomic_set(&count_count_start, 0);
6680 + atomic_set_unchecked(&count_count_start, 0);
6681 smp_wmb();
6682 - atomic_inc(&count_count_stop);
6683 + atomic_inc_unchecked(&count_count_stop);
6684 }
6685 /* Arrange for an interrupt in a short while */
6686 write_c0_compare(read_c0_count() + COUNTON);
6687 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6688 initcount = atomic_read(&count_reference);
6689
6690 for (i = 0; i < NR_LOOPS; i++) {
6691 - atomic_inc(&count_count_start);
6692 - while (atomic_read(&count_count_start) != 2)
6693 + atomic_inc_unchecked(&count_count_start);
6694 + while (atomic_read_unchecked(&count_count_start) != 2)
6695 mb();
6696
6697 /*
6698 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6699 if (i == NR_LOOPS-1)
6700 write_c0_count(initcount);
6701
6702 - atomic_inc(&count_count_stop);
6703 - while (atomic_read(&count_count_stop) != 2)
6704 + atomic_inc_unchecked(&count_count_stop);
6705 + while (atomic_read_unchecked(&count_count_stop) != 2)
6706 mb();
6707 }
6708 /* Arrange for an interrupt in a short while */
6709 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6710 index 524841f..3eef41e 100644
6711 --- a/arch/mips/kernel/traps.c
6712 +++ b/arch/mips/kernel/traps.c
6713 @@ -684,7 +684,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6714 siginfo_t info;
6715
6716 prev_state = exception_enter();
6717 - die_if_kernel("Integer overflow", regs);
6718 + if (unlikely(!user_mode(regs))) {
6719 +
6720 +#ifdef CONFIG_PAX_REFCOUNT
6721 + if (fixup_exception(regs)) {
6722 + pax_report_refcount_overflow(regs);
6723 + exception_exit(prev_state);
6724 + return;
6725 + }
6726 +#endif
6727 +
6728 + die("Integer overflow", regs);
6729 + }
6730
6731 info.si_code = FPE_INTOVF;
6732 info.si_signo = SIGFPE;
6733 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6734 index becc42b..9e43d4b 100644
6735 --- a/arch/mips/mm/fault.c
6736 +++ b/arch/mips/mm/fault.c
6737 @@ -28,6 +28,23 @@
6738 #include <asm/highmem.h> /* For VMALLOC_END */
6739 #include <linux/kdebug.h>
6740
6741 +#ifdef CONFIG_PAX_PAGEEXEC
6742 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6743 +{
6744 + unsigned long i;
6745 +
6746 + printk(KERN_ERR "PAX: bytes at PC: ");
6747 + for (i = 0; i < 5; i++) {
6748 + unsigned int c;
6749 + if (get_user(c, (unsigned int *)pc+i))
6750 + printk(KERN_CONT "???????? ");
6751 + else
6752 + printk(KERN_CONT "%08x ", c);
6753 + }
6754 + printk("\n");
6755 +}
6756 +#endif
6757 +
6758 /*
6759 * This routine handles page faults. It determines the address,
6760 * and the problem, and then passes it off to one of the appropriate
6761 @@ -199,6 +216,14 @@ bad_area:
6762 bad_area_nosemaphore:
6763 /* User mode accesses just cause a SIGSEGV */
6764 if (user_mode(regs)) {
6765 +
6766 +#ifdef CONFIG_PAX_PAGEEXEC
6767 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6768 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6769 + do_group_exit(SIGKILL);
6770 + }
6771 +#endif
6772 +
6773 tsk->thread.cp0_badvaddr = address;
6774 tsk->thread.error_code = write;
6775 #if 0
6776 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6777 index f1baadd..8537544 100644
6778 --- a/arch/mips/mm/mmap.c
6779 +++ b/arch/mips/mm/mmap.c
6780 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6781 struct vm_area_struct *vma;
6782 unsigned long addr = addr0;
6783 int do_color_align;
6784 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6785 struct vm_unmapped_area_info info;
6786
6787 if (unlikely(len > TASK_SIZE))
6788 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6789 do_color_align = 1;
6790
6791 /* requesting a specific address */
6792 +
6793 +#ifdef CONFIG_PAX_RANDMMAP
6794 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6795 +#endif
6796 +
6797 if (addr) {
6798 if (do_color_align)
6799 addr = COLOUR_ALIGN(addr, pgoff);
6800 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6801 addr = PAGE_ALIGN(addr);
6802
6803 vma = find_vma(mm, addr);
6804 - if (TASK_SIZE - len >= addr &&
6805 - (!vma || addr + len <= vma->vm_start))
6806 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6807 return addr;
6808 }
6809
6810 info.length = len;
6811 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6812 info.align_offset = pgoff << PAGE_SHIFT;
6813 + info.threadstack_offset = offset;
6814
6815 if (dir == DOWN) {
6816 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6817 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6818 {
6819 unsigned long random_factor = 0UL;
6820
6821 +#ifdef CONFIG_PAX_RANDMMAP
6822 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6823 +#endif
6824 +
6825 if (current->flags & PF_RANDOMIZE) {
6826 random_factor = get_random_int();
6827 random_factor = random_factor << PAGE_SHIFT;
6828 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6829
6830 if (mmap_is_legacy()) {
6831 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6832 +
6833 +#ifdef CONFIG_PAX_RANDMMAP
6834 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6835 + mm->mmap_base += mm->delta_mmap;
6836 +#endif
6837 +
6838 mm->get_unmapped_area = arch_get_unmapped_area;
6839 } else {
6840 mm->mmap_base = mmap_base(random_factor);
6841 +
6842 +#ifdef CONFIG_PAX_RANDMMAP
6843 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6844 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6845 +#endif
6846 +
6847 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6848 }
6849 }
6850
6851 -static inline unsigned long brk_rnd(void)
6852 -{
6853 - unsigned long rnd = get_random_int();
6854 -
6855 - rnd = rnd << PAGE_SHIFT;
6856 - /* 8MB for 32bit, 256MB for 64bit */
6857 - if (TASK_IS_32BIT_ADDR)
6858 - rnd = rnd & 0x7ffffful;
6859 - else
6860 - rnd = rnd & 0xffffffful;
6861 -
6862 - return rnd;
6863 -}
6864 -
6865 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6866 -{
6867 - unsigned long base = mm->brk;
6868 - unsigned long ret;
6869 -
6870 - ret = PAGE_ALIGN(base + brk_rnd());
6871 -
6872 - if (ret < mm->brk)
6873 - return mm->brk;
6874 -
6875 - return ret;
6876 -}
6877 -
6878 int __virt_addr_valid(const volatile void *kaddr)
6879 {
6880 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6881 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6882 index a2358b4..7cead4f 100644
6883 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6884 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6885 @@ -187,9 +187,9 @@ void
6886 cont_nmi_dump(void)
6887 {
6888 #ifndef REAL_NMI_SIGNAL
6889 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6890 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6891
6892 - atomic_inc(&nmied_cpus);
6893 + atomic_inc_unchecked(&nmied_cpus);
6894 #endif
6895 /*
6896 * Only allow 1 cpu to proceed
6897 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6898 udelay(10000);
6899 }
6900 #else
6901 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6902 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6903 #endif
6904
6905 /*
6906 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6907 index 967d144..db12197 100644
6908 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6909 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6910 @@ -11,12 +11,14 @@
6911 #ifndef _ASM_PROC_CACHE_H
6912 #define _ASM_PROC_CACHE_H
6913
6914 +#include <linux/const.h>
6915 +
6916 /* L1 cache */
6917
6918 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6919 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6920 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6921 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6922 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6923 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6924
6925 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6926 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6927 index bcb5df2..84fabd2 100644
6928 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6929 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6930 @@ -16,13 +16,15 @@
6931 #ifndef _ASM_PROC_CACHE_H
6932 #define _ASM_PROC_CACHE_H
6933
6934 +#include <linux/const.h>
6935 +
6936 /*
6937 * L1 cache
6938 */
6939 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6940 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6941 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6942 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6943 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6944 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6945
6946 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6947 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6948 index 4ce7a01..449202a 100644
6949 --- a/arch/openrisc/include/asm/cache.h
6950 +++ b/arch/openrisc/include/asm/cache.h
6951 @@ -19,11 +19,13 @@
6952 #ifndef __ASM_OPENRISC_CACHE_H
6953 #define __ASM_OPENRISC_CACHE_H
6954
6955 +#include <linux/const.h>
6956 +
6957 /* FIXME: How can we replace these with values from the CPU...
6958 * they shouldn't be hard-coded!
6959 */
6960
6961 -#define L1_CACHE_BYTES 16
6962 #define L1_CACHE_SHIFT 4
6963 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6964
6965 #endif /* __ASM_OPENRISC_CACHE_H */
6966 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6967 index 472886c..00e7df9 100644
6968 --- a/arch/parisc/include/asm/atomic.h
6969 +++ b/arch/parisc/include/asm/atomic.h
6970 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6971 return dec;
6972 }
6973
6974 +#define atomic64_read_unchecked(v) atomic64_read(v)
6975 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6976 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6977 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6978 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6979 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6980 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6981 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6982 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6983 +
6984 #endif /* !CONFIG_64BIT */
6985
6986
6987 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6988 index 47f11c7..3420df2 100644
6989 --- a/arch/parisc/include/asm/cache.h
6990 +++ b/arch/parisc/include/asm/cache.h
6991 @@ -5,6 +5,7 @@
6992 #ifndef __ARCH_PARISC_CACHE_H
6993 #define __ARCH_PARISC_CACHE_H
6994
6995 +#include <linux/const.h>
6996
6997 /*
6998 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6999 @@ -15,13 +16,13 @@
7000 * just ruin performance.
7001 */
7002 #ifdef CONFIG_PA20
7003 -#define L1_CACHE_BYTES 64
7004 #define L1_CACHE_SHIFT 6
7005 #else
7006 -#define L1_CACHE_BYTES 32
7007 #define L1_CACHE_SHIFT 5
7008 #endif
7009
7010 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7011 +
7012 #ifndef __ASSEMBLY__
7013
7014 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7015 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7016 index ad2b503..bdf1651 100644
7017 --- a/arch/parisc/include/asm/elf.h
7018 +++ b/arch/parisc/include/asm/elf.h
7019 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7020
7021 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7022
7023 +#ifdef CONFIG_PAX_ASLR
7024 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7025 +
7026 +#define PAX_DELTA_MMAP_LEN 16
7027 +#define PAX_DELTA_STACK_LEN 16
7028 +#endif
7029 +
7030 /* This yields a mask that user programs can use to figure out what
7031 instruction set this CPU supports. This could be done in user space,
7032 but it's not easy, and we've already done it here. */
7033 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7034 index fc987a1..6e068ef 100644
7035 --- a/arch/parisc/include/asm/pgalloc.h
7036 +++ b/arch/parisc/include/asm/pgalloc.h
7037 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7038 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7039 }
7040
7041 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7042 +{
7043 + pgd_populate(mm, pgd, pmd);
7044 +}
7045 +
7046 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7047 {
7048 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7049 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7050 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7051 #define pmd_free(mm, x) do { } while (0)
7052 #define pgd_populate(mm, pmd, pte) BUG()
7053 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7054
7055 #endif
7056
7057 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7058 index 34899b5..02dd060 100644
7059 --- a/arch/parisc/include/asm/pgtable.h
7060 +++ b/arch/parisc/include/asm/pgtable.h
7061 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7062 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7063 #define PAGE_COPY PAGE_EXECREAD
7064 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7065 +
7066 +#ifdef CONFIG_PAX_PAGEEXEC
7067 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7068 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7069 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7070 +#else
7071 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7072 +# define PAGE_COPY_NOEXEC PAGE_COPY
7073 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7074 +#endif
7075 +
7076 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7077 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7078 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7079 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7080 index e0a8235..ce2f1e1 100644
7081 --- a/arch/parisc/include/asm/uaccess.h
7082 +++ b/arch/parisc/include/asm/uaccess.h
7083 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7084 const void __user *from,
7085 unsigned long n)
7086 {
7087 - int sz = __compiletime_object_size(to);
7088 + size_t sz = __compiletime_object_size(to);
7089 int ret = -EFAULT;
7090
7091 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7092 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7093 ret = __copy_from_user(to, from, n);
7094 else
7095 copy_from_user_overflow();
7096 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7097 index 2a625fb..9908930 100644
7098 --- a/arch/parisc/kernel/module.c
7099 +++ b/arch/parisc/kernel/module.c
7100 @@ -98,16 +98,38 @@
7101
7102 /* three functions to determine where in the module core
7103 * or init pieces the location is */
7104 +static inline int in_init_rx(struct module *me, void *loc)
7105 +{
7106 + return (loc >= me->module_init_rx &&
7107 + loc < (me->module_init_rx + me->init_size_rx));
7108 +}
7109 +
7110 +static inline int in_init_rw(struct module *me, void *loc)
7111 +{
7112 + return (loc >= me->module_init_rw &&
7113 + loc < (me->module_init_rw + me->init_size_rw));
7114 +}
7115 +
7116 static inline int in_init(struct module *me, void *loc)
7117 {
7118 - return (loc >= me->module_init &&
7119 - loc <= (me->module_init + me->init_size));
7120 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7121 +}
7122 +
7123 +static inline int in_core_rx(struct module *me, void *loc)
7124 +{
7125 + return (loc >= me->module_core_rx &&
7126 + loc < (me->module_core_rx + me->core_size_rx));
7127 +}
7128 +
7129 +static inline int in_core_rw(struct module *me, void *loc)
7130 +{
7131 + return (loc >= me->module_core_rw &&
7132 + loc < (me->module_core_rw + me->core_size_rw));
7133 }
7134
7135 static inline int in_core(struct module *me, void *loc)
7136 {
7137 - return (loc >= me->module_core &&
7138 - loc <= (me->module_core + me->core_size));
7139 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7140 }
7141
7142 static inline int in_local(struct module *me, void *loc)
7143 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7144 }
7145
7146 /* align things a bit */
7147 - me->core_size = ALIGN(me->core_size, 16);
7148 - me->arch.got_offset = me->core_size;
7149 - me->core_size += gots * sizeof(struct got_entry);
7150 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7151 + me->arch.got_offset = me->core_size_rw;
7152 + me->core_size_rw += gots * sizeof(struct got_entry);
7153
7154 - me->core_size = ALIGN(me->core_size, 16);
7155 - me->arch.fdesc_offset = me->core_size;
7156 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7157 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7158 + me->arch.fdesc_offset = me->core_size_rw;
7159 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7160
7161 me->arch.got_max = gots;
7162 me->arch.fdesc_max = fdescs;
7163 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7164
7165 BUG_ON(value == 0);
7166
7167 - got = me->module_core + me->arch.got_offset;
7168 + got = me->module_core_rw + me->arch.got_offset;
7169 for (i = 0; got[i].addr; i++)
7170 if (got[i].addr == value)
7171 goto out;
7172 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7173 #ifdef CONFIG_64BIT
7174 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7175 {
7176 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7177 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7178
7179 if (!value) {
7180 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7181 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7182
7183 /* Create new one */
7184 fdesc->addr = value;
7185 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7186 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7187 return (Elf_Addr)fdesc;
7188 }
7189 #endif /* CONFIG_64BIT */
7190 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7191
7192 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7193 end = table + sechdrs[me->arch.unwind_section].sh_size;
7194 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7195 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7196
7197 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7198 me->arch.unwind_section, table, end, gp);
7199 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7200 index 5dfd248..64914ac 100644
7201 --- a/arch/parisc/kernel/sys_parisc.c
7202 +++ b/arch/parisc/kernel/sys_parisc.c
7203 @@ -33,9 +33,11 @@
7204 #include <linux/utsname.h>
7205 #include <linux/personality.h>
7206
7207 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7208 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7209 + unsigned long flags)
7210 {
7211 struct vm_unmapped_area_info info;
7212 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7213
7214 info.flags = 0;
7215 info.length = len;
7216 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7217 info.high_limit = TASK_SIZE;
7218 info.align_mask = 0;
7219 info.align_offset = 0;
7220 + info.threadstack_offset = offset;
7221 return vm_unmapped_area(&info);
7222 }
7223
7224 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7225 return (unsigned long) mapping >> 8;
7226 }
7227
7228 -static unsigned long get_shared_area(struct address_space *mapping,
7229 - unsigned long addr, unsigned long len, unsigned long pgoff)
7230 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7231 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7232 {
7233 struct vm_unmapped_area_info info;
7234 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7235
7236 info.flags = 0;
7237 info.length = len;
7238 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7239 info.high_limit = TASK_SIZE;
7240 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7241 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7242 + info.threadstack_offset = offset;
7243 return vm_unmapped_area(&info);
7244 }
7245
7246 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7247 return -EINVAL;
7248 return addr;
7249 }
7250 - if (!addr)
7251 + if (!addr) {
7252 addr = TASK_UNMAPPED_BASE;
7253
7254 +#ifdef CONFIG_PAX_RANDMMAP
7255 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7256 + addr += current->mm->delta_mmap;
7257 +#endif
7258 +
7259 + }
7260 +
7261 if (filp) {
7262 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7263 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7264 } else if(flags & MAP_SHARED) {
7265 - addr = get_shared_area(NULL, addr, len, pgoff);
7266 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7267 } else {
7268 - addr = get_unshared_area(addr, len);
7269 + addr = get_unshared_area(filp, addr, len, flags);
7270 }
7271 return addr;
7272 }
7273 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7274 index 1cd1d0c..44ec918 100644
7275 --- a/arch/parisc/kernel/traps.c
7276 +++ b/arch/parisc/kernel/traps.c
7277 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7278
7279 down_read(&current->mm->mmap_sem);
7280 vma = find_vma(current->mm,regs->iaoq[0]);
7281 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7282 - && (vma->vm_flags & VM_EXEC)) {
7283 -
7284 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7285 fault_address = regs->iaoq[0];
7286 fault_space = regs->iasq[0];
7287
7288 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7289 index 0293588..3b229aa 100644
7290 --- a/arch/parisc/mm/fault.c
7291 +++ b/arch/parisc/mm/fault.c
7292 @@ -15,6 +15,7 @@
7293 #include <linux/sched.h>
7294 #include <linux/interrupt.h>
7295 #include <linux/module.h>
7296 +#include <linux/unistd.h>
7297
7298 #include <asm/uaccess.h>
7299 #include <asm/traps.h>
7300 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7301 static unsigned long
7302 parisc_acctyp(unsigned long code, unsigned int inst)
7303 {
7304 - if (code == 6 || code == 16)
7305 + if (code == 6 || code == 7 || code == 16)
7306 return VM_EXEC;
7307
7308 switch (inst & 0xf0000000) {
7309 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7310 }
7311 #endif
7312
7313 +#ifdef CONFIG_PAX_PAGEEXEC
7314 +/*
7315 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7316 + *
7317 + * returns 1 when task should be killed
7318 + * 2 when rt_sigreturn trampoline was detected
7319 + * 3 when unpatched PLT trampoline was detected
7320 + */
7321 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7322 +{
7323 +
7324 +#ifdef CONFIG_PAX_EMUPLT
7325 + int err;
7326 +
7327 + do { /* PaX: unpatched PLT emulation */
7328 + unsigned int bl, depwi;
7329 +
7330 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7331 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7332 +
7333 + if (err)
7334 + break;
7335 +
7336 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7337 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7338 +
7339 + err = get_user(ldw, (unsigned int *)addr);
7340 + err |= get_user(bv, (unsigned int *)(addr+4));
7341 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7342 +
7343 + if (err)
7344 + break;
7345 +
7346 + if (ldw == 0x0E801096U &&
7347 + bv == 0xEAC0C000U &&
7348 + ldw2 == 0x0E881095U)
7349 + {
7350 + unsigned int resolver, map;
7351 +
7352 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7353 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7354 + if (err)
7355 + break;
7356 +
7357 + regs->gr[20] = instruction_pointer(regs)+8;
7358 + regs->gr[21] = map;
7359 + regs->gr[22] = resolver;
7360 + regs->iaoq[0] = resolver | 3UL;
7361 + regs->iaoq[1] = regs->iaoq[0] + 4;
7362 + return 3;
7363 + }
7364 + }
7365 + } while (0);
7366 +#endif
7367 +
7368 +#ifdef CONFIG_PAX_EMUTRAMP
7369 +
7370 +#ifndef CONFIG_PAX_EMUSIGRT
7371 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7372 + return 1;
7373 +#endif
7374 +
7375 + do { /* PaX: rt_sigreturn emulation */
7376 + unsigned int ldi1, ldi2, bel, nop;
7377 +
7378 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7379 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7380 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7381 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7382 +
7383 + if (err)
7384 + break;
7385 +
7386 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7387 + ldi2 == 0x3414015AU &&
7388 + bel == 0xE4008200U &&
7389 + nop == 0x08000240U)
7390 + {
7391 + regs->gr[25] = (ldi1 & 2) >> 1;
7392 + regs->gr[20] = __NR_rt_sigreturn;
7393 + regs->gr[31] = regs->iaoq[1] + 16;
7394 + regs->sr[0] = regs->iasq[1];
7395 + regs->iaoq[0] = 0x100UL;
7396 + regs->iaoq[1] = regs->iaoq[0] + 4;
7397 + regs->iasq[0] = regs->sr[2];
7398 + regs->iasq[1] = regs->sr[2];
7399 + return 2;
7400 + }
7401 + } while (0);
7402 +#endif
7403 +
7404 + return 1;
7405 +}
7406 +
7407 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7408 +{
7409 + unsigned long i;
7410 +
7411 + printk(KERN_ERR "PAX: bytes at PC: ");
7412 + for (i = 0; i < 5; i++) {
7413 + unsigned int c;
7414 + if (get_user(c, (unsigned int *)pc+i))
7415 + printk(KERN_CONT "???????? ");
7416 + else
7417 + printk(KERN_CONT "%08x ", c);
7418 + }
7419 + printk("\n");
7420 +}
7421 +#endif
7422 +
7423 int fixup_exception(struct pt_regs *regs)
7424 {
7425 const struct exception_table_entry *fix;
7426 @@ -204,8 +315,33 @@ retry:
7427
7428 good_area:
7429
7430 - if ((vma->vm_flags & acc_type) != acc_type)
7431 + if ((vma->vm_flags & acc_type) != acc_type) {
7432 +
7433 +#ifdef CONFIG_PAX_PAGEEXEC
7434 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7435 + (address & ~3UL) == instruction_pointer(regs))
7436 + {
7437 + up_read(&mm->mmap_sem);
7438 + switch (pax_handle_fetch_fault(regs)) {
7439 +
7440 +#ifdef CONFIG_PAX_EMUPLT
7441 + case 3:
7442 + return;
7443 +#endif
7444 +
7445 +#ifdef CONFIG_PAX_EMUTRAMP
7446 + case 2:
7447 + return;
7448 +#endif
7449 +
7450 + }
7451 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7452 + do_group_exit(SIGKILL);
7453 + }
7454 +#endif
7455 +
7456 goto bad_area;
7457 + }
7458
7459 /*
7460 * If for any reason at all we couldn't handle the fault, make
7461 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7462 index e3b1d41..8e81edf 100644
7463 --- a/arch/powerpc/include/asm/atomic.h
7464 +++ b/arch/powerpc/include/asm/atomic.h
7465 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7466 return t1;
7467 }
7468
7469 +#define atomic64_read_unchecked(v) atomic64_read(v)
7470 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7471 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7472 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7473 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7474 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7475 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7476 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7477 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7478 +
7479 #endif /* __powerpc64__ */
7480
7481 #endif /* __KERNEL__ */
7482 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7483 index 9e495c9..b6878e5 100644
7484 --- a/arch/powerpc/include/asm/cache.h
7485 +++ b/arch/powerpc/include/asm/cache.h
7486 @@ -3,6 +3,7 @@
7487
7488 #ifdef __KERNEL__
7489
7490 +#include <linux/const.h>
7491
7492 /* bytes per L1 cache line */
7493 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7494 @@ -22,7 +23,7 @@
7495 #define L1_CACHE_SHIFT 7
7496 #endif
7497
7498 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7499 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7500
7501 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7502
7503 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7504 index cc0655a..13eac2e 100644
7505 --- a/arch/powerpc/include/asm/elf.h
7506 +++ b/arch/powerpc/include/asm/elf.h
7507 @@ -28,8 +28,19 @@
7508 the loader. We need to make sure that it is out of the way of the program
7509 that it will "exec", and that there is sufficient room for the brk. */
7510
7511 -extern unsigned long randomize_et_dyn(unsigned long base);
7512 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7513 +#define ELF_ET_DYN_BASE (0x20000000)
7514 +
7515 +#ifdef CONFIG_PAX_ASLR
7516 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7517 +
7518 +#ifdef __powerpc64__
7519 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7520 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7521 +#else
7522 +#define PAX_DELTA_MMAP_LEN 15
7523 +#define PAX_DELTA_STACK_LEN 15
7524 +#endif
7525 +#endif
7526
7527 /*
7528 * Our registers are always unsigned longs, whether we're a 32 bit
7529 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7530 (0x7ff >> (PAGE_SHIFT - 12)) : \
7531 (0x3ffff >> (PAGE_SHIFT - 12)))
7532
7533 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7534 -#define arch_randomize_brk arch_randomize_brk
7535 -
7536 -
7537 #ifdef CONFIG_SPU_BASE
7538 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7539 #define NT_SPU 1
7540 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7541 index 8196e9c..d83a9f3 100644
7542 --- a/arch/powerpc/include/asm/exec.h
7543 +++ b/arch/powerpc/include/asm/exec.h
7544 @@ -4,6 +4,6 @@
7545 #ifndef _ASM_POWERPC_EXEC_H
7546 #define _ASM_POWERPC_EXEC_H
7547
7548 -extern unsigned long arch_align_stack(unsigned long sp);
7549 +#define arch_align_stack(x) ((x) & ~0xfUL)
7550
7551 #endif /* _ASM_POWERPC_EXEC_H */
7552 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7553 index 5acabbd..7ea14fa 100644
7554 --- a/arch/powerpc/include/asm/kmap_types.h
7555 +++ b/arch/powerpc/include/asm/kmap_types.h
7556 @@ -10,7 +10,7 @@
7557 * 2 of the License, or (at your option) any later version.
7558 */
7559
7560 -#define KM_TYPE_NR 16
7561 +#define KM_TYPE_NR 17
7562
7563 #endif /* __KERNEL__ */
7564 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7565 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7566 index 8565c25..2865190 100644
7567 --- a/arch/powerpc/include/asm/mman.h
7568 +++ b/arch/powerpc/include/asm/mman.h
7569 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7570 }
7571 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7572
7573 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7574 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7575 {
7576 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7577 }
7578 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7579 index b9f4262..dcf04f7 100644
7580 --- a/arch/powerpc/include/asm/page.h
7581 +++ b/arch/powerpc/include/asm/page.h
7582 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7583 * and needs to be executable. This means the whole heap ends
7584 * up being executable.
7585 */
7586 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7587 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7588 +#define VM_DATA_DEFAULT_FLAGS32 \
7589 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7590 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7591
7592 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7593 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7594 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7595 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7596 #endif
7597
7598 +#define ktla_ktva(addr) (addr)
7599 +#define ktva_ktla(addr) (addr)
7600 +
7601 #ifndef CONFIG_PPC_BOOK3S_64
7602 /*
7603 * Use the top bit of the higher-level page table entries to indicate whether
7604 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7605 index 88693ce..ac6f9ab 100644
7606 --- a/arch/powerpc/include/asm/page_64.h
7607 +++ b/arch/powerpc/include/asm/page_64.h
7608 @@ -153,15 +153,18 @@ do { \
7609 * stack by default, so in the absence of a PT_GNU_STACK program header
7610 * we turn execute permission off.
7611 */
7612 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7613 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7614 +#define VM_STACK_DEFAULT_FLAGS32 \
7615 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7616 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7617
7618 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7619 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7620
7621 +#ifndef CONFIG_PAX_PAGEEXEC
7622 #define VM_STACK_DEFAULT_FLAGS \
7623 (is_32bit_task() ? \
7624 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7625 +#endif
7626
7627 #include <asm-generic/getorder.h>
7628
7629 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7630 index f65e27b..23ffb5b 100644
7631 --- a/arch/powerpc/include/asm/pgalloc-64.h
7632 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7633 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7634 #ifndef CONFIG_PPC_64K_PAGES
7635
7636 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7637 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7638
7639 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7640 {
7641 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7642 pud_set(pud, (unsigned long)pmd);
7643 }
7644
7645 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7646 +{
7647 + pud_populate(mm, pud, pmd);
7648 +}
7649 +
7650 #define pmd_populate(mm, pmd, pte_page) \
7651 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7652 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7653 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7654 #endif
7655
7656 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7657 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7658
7659 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7660 pte_t *pte)
7661 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7662 index 7d6eacf..14c0240 100644
7663 --- a/arch/powerpc/include/asm/pgtable.h
7664 +++ b/arch/powerpc/include/asm/pgtable.h
7665 @@ -2,6 +2,7 @@
7666 #define _ASM_POWERPC_PGTABLE_H
7667 #ifdef __KERNEL__
7668
7669 +#include <linux/const.h>
7670 #ifndef __ASSEMBLY__
7671 #include <asm/processor.h> /* For TASK_SIZE */
7672 #include <asm/mmu.h>
7673 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7674 index 4aad413..85d86bf 100644
7675 --- a/arch/powerpc/include/asm/pte-hash32.h
7676 +++ b/arch/powerpc/include/asm/pte-hash32.h
7677 @@ -21,6 +21,7 @@
7678 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7679 #define _PAGE_USER 0x004 /* usermode access allowed */
7680 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7681 +#define _PAGE_EXEC _PAGE_GUARDED
7682 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7683 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7684 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7685 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7686 index 10d1ef0..8f83abc 100644
7687 --- a/arch/powerpc/include/asm/reg.h
7688 +++ b/arch/powerpc/include/asm/reg.h
7689 @@ -234,6 +234,7 @@
7690 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7691 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7692 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7693 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7694 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7695 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7696 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7697 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7698 index 98da78e..dc68271 100644
7699 --- a/arch/powerpc/include/asm/smp.h
7700 +++ b/arch/powerpc/include/asm/smp.h
7701 @@ -50,7 +50,7 @@ struct smp_ops_t {
7702 int (*cpu_disable)(void);
7703 void (*cpu_die)(unsigned int nr);
7704 int (*cpu_bootable)(unsigned int nr);
7705 -};
7706 +} __no_const;
7707
7708 extern void smp_send_debugger_break(void);
7709 extern void start_secondary_resume(void);
7710 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7711 index ba7b197..d292e26 100644
7712 --- a/arch/powerpc/include/asm/thread_info.h
7713 +++ b/arch/powerpc/include/asm/thread_info.h
7714 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7715 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7716 TIF_NEED_RESCHED */
7717 #define TIF_32BIT 4 /* 32 bit binary */
7718 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7719 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7720 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7721 #define TIF_SINGLESTEP 8 /* singlestepping active */
7722 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7723 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7724 for stack store? */
7725 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7726 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7727 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7728 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7729
7730 /* as above, but as bit values */
7731 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7732 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7733 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7734 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7735 #define _TIF_NOHZ (1<<TIF_NOHZ)
7736 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7737 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7738 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7739 - _TIF_NOHZ)
7740 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7741
7742 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7743 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7744 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7745 index 9485b43..4718d50 100644
7746 --- a/arch/powerpc/include/asm/uaccess.h
7747 +++ b/arch/powerpc/include/asm/uaccess.h
7748 @@ -318,52 +318,6 @@ do { \
7749 extern unsigned long __copy_tofrom_user(void __user *to,
7750 const void __user *from, unsigned long size);
7751
7752 -#ifndef __powerpc64__
7753 -
7754 -static inline unsigned long copy_from_user(void *to,
7755 - const void __user *from, unsigned long n)
7756 -{
7757 - unsigned long over;
7758 -
7759 - if (access_ok(VERIFY_READ, from, n))
7760 - return __copy_tofrom_user((__force void __user *)to, from, n);
7761 - if ((unsigned long)from < TASK_SIZE) {
7762 - over = (unsigned long)from + n - TASK_SIZE;
7763 - return __copy_tofrom_user((__force void __user *)to, from,
7764 - n - over) + over;
7765 - }
7766 - return n;
7767 -}
7768 -
7769 -static inline unsigned long copy_to_user(void __user *to,
7770 - const void *from, unsigned long n)
7771 -{
7772 - unsigned long over;
7773 -
7774 - if (access_ok(VERIFY_WRITE, to, n))
7775 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7776 - if ((unsigned long)to < TASK_SIZE) {
7777 - over = (unsigned long)to + n - TASK_SIZE;
7778 - return __copy_tofrom_user(to, (__force void __user *)from,
7779 - n - over) + over;
7780 - }
7781 - return n;
7782 -}
7783 -
7784 -#else /* __powerpc64__ */
7785 -
7786 -#define __copy_in_user(to, from, size) \
7787 - __copy_tofrom_user((to), (from), (size))
7788 -
7789 -extern unsigned long copy_from_user(void *to, const void __user *from,
7790 - unsigned long n);
7791 -extern unsigned long copy_to_user(void __user *to, const void *from,
7792 - unsigned long n);
7793 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7794 - unsigned long n);
7795 -
7796 -#endif /* __powerpc64__ */
7797 -
7798 static inline unsigned long __copy_from_user_inatomic(void *to,
7799 const void __user *from, unsigned long n)
7800 {
7801 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7802 if (ret == 0)
7803 return 0;
7804 }
7805 +
7806 + if (!__builtin_constant_p(n))
7807 + check_object_size(to, n, false);
7808 +
7809 return __copy_tofrom_user((__force void __user *)to, from, n);
7810 }
7811
7812 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7813 if (ret == 0)
7814 return 0;
7815 }
7816 +
7817 + if (!__builtin_constant_p(n))
7818 + check_object_size(from, n, true);
7819 +
7820 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7821 }
7822
7823 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7824 return __copy_to_user_inatomic(to, from, size);
7825 }
7826
7827 +#ifndef __powerpc64__
7828 +
7829 +static inline unsigned long __must_check copy_from_user(void *to,
7830 + const void __user *from, unsigned long n)
7831 +{
7832 + unsigned long over;
7833 +
7834 + if ((long)n < 0)
7835 + return n;
7836 +
7837 + if (access_ok(VERIFY_READ, from, n)) {
7838 + if (!__builtin_constant_p(n))
7839 + check_object_size(to, n, false);
7840 + return __copy_tofrom_user((__force void __user *)to, from, n);
7841 + }
7842 + if ((unsigned long)from < TASK_SIZE) {
7843 + over = (unsigned long)from + n - TASK_SIZE;
7844 + if (!__builtin_constant_p(n - over))
7845 + check_object_size(to, n - over, false);
7846 + return __copy_tofrom_user((__force void __user *)to, from,
7847 + n - over) + over;
7848 + }
7849 + return n;
7850 +}
7851 +
7852 +static inline unsigned long __must_check copy_to_user(void __user *to,
7853 + const void *from, unsigned long n)
7854 +{
7855 + unsigned long over;
7856 +
7857 + if ((long)n < 0)
7858 + return n;
7859 +
7860 + if (access_ok(VERIFY_WRITE, to, n)) {
7861 + if (!__builtin_constant_p(n))
7862 + check_object_size(from, n, true);
7863 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7864 + }
7865 + if ((unsigned long)to < TASK_SIZE) {
7866 + over = (unsigned long)to + n - TASK_SIZE;
7867 + if (!__builtin_constant_p(n))
7868 + check_object_size(from, n - over, true);
7869 + return __copy_tofrom_user(to, (__force void __user *)from,
7870 + n - over) + over;
7871 + }
7872 + return n;
7873 +}
7874 +
7875 +#else /* __powerpc64__ */
7876 +
7877 +#define __copy_in_user(to, from, size) \
7878 + __copy_tofrom_user((to), (from), (size))
7879 +
7880 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7881 +{
7882 + if ((long)n < 0 || n > INT_MAX)
7883 + return n;
7884 +
7885 + if (!__builtin_constant_p(n))
7886 + check_object_size(to, n, false);
7887 +
7888 + if (likely(access_ok(VERIFY_READ, from, n)))
7889 + n = __copy_from_user(to, from, n);
7890 + else
7891 + memset(to, 0, n);
7892 + return n;
7893 +}
7894 +
7895 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7896 +{
7897 + if ((long)n < 0 || n > INT_MAX)
7898 + return n;
7899 +
7900 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7901 + if (!__builtin_constant_p(n))
7902 + check_object_size(from, n, true);
7903 + n = __copy_to_user(to, from, n);
7904 + }
7905 + return n;
7906 +}
7907 +
7908 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7909 + unsigned long n);
7910 +
7911 +#endif /* __powerpc64__ */
7912 +
7913 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7914
7915 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7916 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7917 index 2d06704..1616f1b 100644
7918 --- a/arch/powerpc/kernel/exceptions-64e.S
7919 +++ b/arch/powerpc/kernel/exceptions-64e.S
7920 @@ -757,6 +757,7 @@ storage_fault_common:
7921 std r14,_DAR(r1)
7922 std r15,_DSISR(r1)
7923 addi r3,r1,STACK_FRAME_OVERHEAD
7924 + bl .save_nvgprs
7925 mr r4,r14
7926 mr r5,r15
7927 ld r14,PACA_EXGEN+EX_R14(r13)
7928 @@ -765,8 +766,7 @@ storage_fault_common:
7929 cmpdi r3,0
7930 bne- 1f
7931 b .ret_from_except_lite
7932 -1: bl .save_nvgprs
7933 - mr r5,r3
7934 +1: mr r5,r3
7935 addi r3,r1,STACK_FRAME_OVERHEAD
7936 ld r4,_DAR(r1)
7937 bl .bad_page_fault
7938 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7939 index 3a9ed6a..b534681 100644
7940 --- a/arch/powerpc/kernel/exceptions-64s.S
7941 +++ b/arch/powerpc/kernel/exceptions-64s.S
7942 @@ -1364,10 +1364,10 @@ handle_page_fault:
7943 11: ld r4,_DAR(r1)
7944 ld r5,_DSISR(r1)
7945 addi r3,r1,STACK_FRAME_OVERHEAD
7946 + bl .save_nvgprs
7947 bl .do_page_fault
7948 cmpdi r3,0
7949 beq+ 12f
7950 - bl .save_nvgprs
7951 mr r5,r3
7952 addi r3,r1,STACK_FRAME_OVERHEAD
7953 lwz r4,_DAR(r1)
7954 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7955 index 2e3200c..72095ce 100644
7956 --- a/arch/powerpc/kernel/module_32.c
7957 +++ b/arch/powerpc/kernel/module_32.c
7958 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7959 me->arch.core_plt_section = i;
7960 }
7961 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7962 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7963 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7964 return -ENOEXEC;
7965 }
7966
7967 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7968
7969 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7970 /* Init, or core PLT? */
7971 - if (location >= mod->module_core
7972 - && location < mod->module_core + mod->core_size)
7973 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7974 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7975 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7976 - else
7977 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7978 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7979 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7980 + else {
7981 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7982 + return ~0UL;
7983 + }
7984
7985 /* Find this entry, or if that fails, the next avail. entry */
7986 while (entry->jump[0]) {
7987 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7988 index 96d2fdf..f6d10c8 100644
7989 --- a/arch/powerpc/kernel/process.c
7990 +++ b/arch/powerpc/kernel/process.c
7991 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
7992 * Lookup NIP late so we have the best change of getting the
7993 * above info out without failing
7994 */
7995 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7996 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7997 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7998 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7999 #endif
8000 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8001 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8002 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8003 newsp = stack[0];
8004 ip = stack[STACK_FRAME_LR_SAVE];
8005 if (!firstframe || ip != lr) {
8006 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8007 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8008 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8009 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8010 - printk(" (%pS)",
8011 + printk(" (%pA)",
8012 (void *)current->ret_stack[curr_frame].ret);
8013 curr_frame--;
8014 }
8015 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8016 struct pt_regs *regs = (struct pt_regs *)
8017 (sp + STACK_FRAME_OVERHEAD);
8018 lr = regs->link;
8019 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8020 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8021 regs->trap, (void *)regs->nip, (void *)lr);
8022 firstframe = 1;
8023 }
8024 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8025 mtspr(SPRN_CTRLT, ctrl);
8026 }
8027 #endif /* CONFIG_PPC64 */
8028 -
8029 -unsigned long arch_align_stack(unsigned long sp)
8030 -{
8031 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8032 - sp -= get_random_int() & ~PAGE_MASK;
8033 - return sp & ~0xf;
8034 -}
8035 -
8036 -static inline unsigned long brk_rnd(void)
8037 -{
8038 - unsigned long rnd = 0;
8039 -
8040 - /* 8MB for 32bit, 1GB for 64bit */
8041 - if (is_32bit_task())
8042 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8043 - else
8044 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8045 -
8046 - return rnd << PAGE_SHIFT;
8047 -}
8048 -
8049 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8050 -{
8051 - unsigned long base = mm->brk;
8052 - unsigned long ret;
8053 -
8054 -#ifdef CONFIG_PPC_STD_MMU_64
8055 - /*
8056 - * If we are using 1TB segments and we are allowed to randomise
8057 - * the heap, we can put it above 1TB so it is backed by a 1TB
8058 - * segment. Otherwise the heap will be in the bottom 1TB
8059 - * which always uses 256MB segments and this may result in a
8060 - * performance penalty.
8061 - */
8062 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8063 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8064 -#endif
8065 -
8066 - ret = PAGE_ALIGN(base + brk_rnd());
8067 -
8068 - if (ret < mm->brk)
8069 - return mm->brk;
8070 -
8071 - return ret;
8072 -}
8073 -
8074 -unsigned long randomize_et_dyn(unsigned long base)
8075 -{
8076 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8077 -
8078 - if (ret < base)
8079 - return base;
8080 -
8081 - return ret;
8082 -}
8083 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8084 index 9a0d24c..e7fbedf 100644
8085 --- a/arch/powerpc/kernel/ptrace.c
8086 +++ b/arch/powerpc/kernel/ptrace.c
8087 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8088 return ret;
8089 }
8090
8091 +#ifdef CONFIG_GRKERNSEC_SETXID
8092 +extern void gr_delayed_cred_worker(void);
8093 +#endif
8094 +
8095 /*
8096 * We must return the syscall number to actually look up in the table.
8097 * This can be -1L to skip running any syscall at all.
8098 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8099
8100 secure_computing_strict(regs->gpr[0]);
8101
8102 +#ifdef CONFIG_GRKERNSEC_SETXID
8103 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8104 + gr_delayed_cred_worker();
8105 +#endif
8106 +
8107 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8108 tracehook_report_syscall_entry(regs))
8109 /*
8110 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8111 {
8112 int step;
8113
8114 +#ifdef CONFIG_GRKERNSEC_SETXID
8115 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8116 + gr_delayed_cred_worker();
8117 +#endif
8118 +
8119 audit_syscall_exit(regs);
8120
8121 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8122 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8123 index bebdf1a..7a9e095 100644
8124 --- a/arch/powerpc/kernel/signal_32.c
8125 +++ b/arch/powerpc/kernel/signal_32.c
8126 @@ -996,7 +996,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8127 /* Save user registers on the stack */
8128 frame = &rt_sf->uc.uc_mcontext;
8129 addr = frame;
8130 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8131 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8132 sigret = 0;
8133 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8134 } else {
8135 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8136 index f93ec28..97e0fbb 100644
8137 --- a/arch/powerpc/kernel/signal_64.c
8138 +++ b/arch/powerpc/kernel/signal_64.c
8139 @@ -757,7 +757,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8140 #endif
8141
8142 /* Set up to return from userspace. */
8143 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8144 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8145 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8146 } else {
8147 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8148 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8149 index f783c93..619baf1 100644
8150 --- a/arch/powerpc/kernel/traps.c
8151 +++ b/arch/powerpc/kernel/traps.c
8152 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8153 return flags;
8154 }
8155
8156 +extern void gr_handle_kernel_exploit(void);
8157 +
8158 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8159 int signr)
8160 {
8161 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8162 panic("Fatal exception in interrupt");
8163 if (panic_on_oops)
8164 panic("Fatal exception");
8165 +
8166 + gr_handle_kernel_exploit();
8167 +
8168 do_exit(signr);
8169 }
8170
8171 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8172 index 1d9c926..25f4741 100644
8173 --- a/arch/powerpc/kernel/vdso.c
8174 +++ b/arch/powerpc/kernel/vdso.c
8175 @@ -34,6 +34,7 @@
8176 #include <asm/firmware.h>
8177 #include <asm/vdso.h>
8178 #include <asm/vdso_datapage.h>
8179 +#include <asm/mman.h>
8180
8181 #include "setup.h"
8182
8183 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8184 vdso_base = VDSO32_MBASE;
8185 #endif
8186
8187 - current->mm->context.vdso_base = 0;
8188 + current->mm->context.vdso_base = ~0UL;
8189
8190 /* vDSO has a problem and was disabled, just don't "enable" it for the
8191 * process
8192 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8193 vdso_base = get_unmapped_area(NULL, vdso_base,
8194 (vdso_pages << PAGE_SHIFT) +
8195 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8196 - 0, 0);
8197 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8198 if (IS_ERR_VALUE(vdso_base)) {
8199 rc = vdso_base;
8200 goto fail_mmapsem;
8201 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8202 index 5eea6f3..5d10396 100644
8203 --- a/arch/powerpc/lib/usercopy_64.c
8204 +++ b/arch/powerpc/lib/usercopy_64.c
8205 @@ -9,22 +9,6 @@
8206 #include <linux/module.h>
8207 #include <asm/uaccess.h>
8208
8209 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8210 -{
8211 - if (likely(access_ok(VERIFY_READ, from, n)))
8212 - n = __copy_from_user(to, from, n);
8213 - else
8214 - memset(to, 0, n);
8215 - return n;
8216 -}
8217 -
8218 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8219 -{
8220 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8221 - n = __copy_to_user(to, from, n);
8222 - return n;
8223 -}
8224 -
8225 unsigned long copy_in_user(void __user *to, const void __user *from,
8226 unsigned long n)
8227 {
8228 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8229 return n;
8230 }
8231
8232 -EXPORT_SYMBOL(copy_from_user);
8233 -EXPORT_SYMBOL(copy_to_user);
8234 EXPORT_SYMBOL(copy_in_user);
8235
8236 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8237 index 51ab9e7..7d3c78b 100644
8238 --- a/arch/powerpc/mm/fault.c
8239 +++ b/arch/powerpc/mm/fault.c
8240 @@ -33,6 +33,10 @@
8241 #include <linux/magic.h>
8242 #include <linux/ratelimit.h>
8243 #include <linux/context_tracking.h>
8244 +#include <linux/slab.h>
8245 +#include <linux/pagemap.h>
8246 +#include <linux/compiler.h>
8247 +#include <linux/unistd.h>
8248
8249 #include <asm/firmware.h>
8250 #include <asm/page.h>
8251 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8252 }
8253 #endif
8254
8255 +#ifdef CONFIG_PAX_PAGEEXEC
8256 +/*
8257 + * PaX: decide what to do with offenders (regs->nip = fault address)
8258 + *
8259 + * returns 1 when task should be killed
8260 + */
8261 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8262 +{
8263 + return 1;
8264 +}
8265 +
8266 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8267 +{
8268 + unsigned long i;
8269 +
8270 + printk(KERN_ERR "PAX: bytes at PC: ");
8271 + for (i = 0; i < 5; i++) {
8272 + unsigned int c;
8273 + if (get_user(c, (unsigned int __user *)pc+i))
8274 + printk(KERN_CONT "???????? ");
8275 + else
8276 + printk(KERN_CONT "%08x ", c);
8277 + }
8278 + printk("\n");
8279 +}
8280 +#endif
8281 +
8282 /*
8283 * Check whether the instruction at regs->nip is a store using
8284 * an update addressing form which will update r1.
8285 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8286 * indicate errors in DSISR but can validly be set in SRR1.
8287 */
8288 if (trap == 0x400)
8289 - error_code &= 0x48200000;
8290 + error_code &= 0x58200000;
8291 else
8292 is_write = error_code & DSISR_ISSTORE;
8293 #else
8294 @@ -378,7 +409,7 @@ good_area:
8295 * "undefined". Of those that can be set, this is the only
8296 * one which seems bad.
8297 */
8298 - if (error_code & 0x10000000)
8299 + if (error_code & DSISR_GUARDED)
8300 /* Guarded storage error. */
8301 goto bad_area;
8302 #endif /* CONFIG_8xx */
8303 @@ -393,7 +424,7 @@ good_area:
8304 * processors use the same I/D cache coherency mechanism
8305 * as embedded.
8306 */
8307 - if (error_code & DSISR_PROTFAULT)
8308 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8309 goto bad_area;
8310 #endif /* CONFIG_PPC_STD_MMU */
8311
8312 @@ -483,6 +514,23 @@ bad_area:
8313 bad_area_nosemaphore:
8314 /* User mode accesses cause a SIGSEGV */
8315 if (user_mode(regs)) {
8316 +
8317 +#ifdef CONFIG_PAX_PAGEEXEC
8318 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8319 +#ifdef CONFIG_PPC_STD_MMU
8320 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8321 +#else
8322 + if (is_exec && regs->nip == address) {
8323 +#endif
8324 + switch (pax_handle_fetch_fault(regs)) {
8325 + }
8326 +
8327 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8328 + do_group_exit(SIGKILL);
8329 + }
8330 + }
8331 +#endif
8332 +
8333 _exception(SIGSEGV, regs, code, address);
8334 goto bail;
8335 }
8336 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8337 index cb8bdbe..d770680 100644
8338 --- a/arch/powerpc/mm/mmap.c
8339 +++ b/arch/powerpc/mm/mmap.c
8340 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8341 {
8342 unsigned long rnd = 0;
8343
8344 +#ifdef CONFIG_PAX_RANDMMAP
8345 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8346 +#endif
8347 +
8348 if (current->flags & PF_RANDOMIZE) {
8349 /* 8MB for 32bit, 1GB for 64bit */
8350 if (is_32bit_task())
8351 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8352 */
8353 if (mmap_is_legacy()) {
8354 mm->mmap_base = TASK_UNMAPPED_BASE;
8355 +
8356 +#ifdef CONFIG_PAX_RANDMMAP
8357 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8358 + mm->mmap_base += mm->delta_mmap;
8359 +#endif
8360 +
8361 mm->get_unmapped_area = arch_get_unmapped_area;
8362 } else {
8363 mm->mmap_base = mmap_base();
8364 +
8365 +#ifdef CONFIG_PAX_RANDMMAP
8366 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8367 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8368 +#endif
8369 +
8370 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8371 }
8372 }
8373 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8374 index 3e99c14..f00953c 100644
8375 --- a/arch/powerpc/mm/slice.c
8376 +++ b/arch/powerpc/mm/slice.c
8377 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8378 if ((mm->task_size - len) < addr)
8379 return 0;
8380 vma = find_vma(mm, addr);
8381 - return (!vma || (addr + len) <= vma->vm_start);
8382 + return check_heap_stack_gap(vma, addr, len, 0);
8383 }
8384
8385 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8386 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8387 info.align_offset = 0;
8388
8389 addr = TASK_UNMAPPED_BASE;
8390 +
8391 +#ifdef CONFIG_PAX_RANDMMAP
8392 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8393 + addr += mm->delta_mmap;
8394 +#endif
8395 +
8396 while (addr < TASK_SIZE) {
8397 info.low_limit = addr;
8398 if (!slice_scan_available(addr, available, 1, &addr))
8399 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8400 if (fixed && addr > (mm->task_size - len))
8401 return -EINVAL;
8402
8403 +#ifdef CONFIG_PAX_RANDMMAP
8404 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8405 + addr = 0;
8406 +#endif
8407 +
8408 /* If hint, make sure it matches our alignment restrictions */
8409 if (!fixed && addr) {
8410 addr = _ALIGN_UP(addr, 1ul << pshift);
8411 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8412 index 9098692..3d54cd1 100644
8413 --- a/arch/powerpc/platforms/cell/spufs/file.c
8414 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8415 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8416 return VM_FAULT_NOPAGE;
8417 }
8418
8419 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8420 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8421 unsigned long address,
8422 - void *buf, int len, int write)
8423 + void *buf, size_t len, int write)
8424 {
8425 struct spu_context *ctx = vma->vm_file->private_data;
8426 unsigned long offset = address - vma->vm_start;
8427 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8428 index c797832..ce575c8 100644
8429 --- a/arch/s390/include/asm/atomic.h
8430 +++ b/arch/s390/include/asm/atomic.h
8431 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8432 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8433 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8434
8435 +#define atomic64_read_unchecked(v) atomic64_read(v)
8436 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8437 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8438 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8439 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8440 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8441 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8442 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8443 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8444 +
8445 #define smp_mb__before_atomic_dec() smp_mb()
8446 #define smp_mb__after_atomic_dec() smp_mb()
8447 #define smp_mb__before_atomic_inc() smp_mb()
8448 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8449 index 4d7ccac..d03d0ad 100644
8450 --- a/arch/s390/include/asm/cache.h
8451 +++ b/arch/s390/include/asm/cache.h
8452 @@ -9,8 +9,10 @@
8453 #ifndef __ARCH_S390_CACHE_H
8454 #define __ARCH_S390_CACHE_H
8455
8456 -#define L1_CACHE_BYTES 256
8457 +#include <linux/const.h>
8458 +
8459 #define L1_CACHE_SHIFT 8
8460 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8461 #define NET_SKB_PAD 32
8462
8463 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8464 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8465 index 78f4f87..598ce39 100644
8466 --- a/arch/s390/include/asm/elf.h
8467 +++ b/arch/s390/include/asm/elf.h
8468 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8469 the loader. We need to make sure that it is out of the way of the program
8470 that it will "exec", and that there is sufficient room for the brk. */
8471
8472 -extern unsigned long randomize_et_dyn(unsigned long base);
8473 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8474 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8475 +
8476 +#ifdef CONFIG_PAX_ASLR
8477 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8478 +
8479 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8480 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8481 +#endif
8482
8483 /* This yields a mask that user programs can use to figure out what
8484 instruction set this CPU supports. */
8485 @@ -222,9 +228,6 @@ struct linux_binprm;
8486 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8487 int arch_setup_additional_pages(struct linux_binprm *, int);
8488
8489 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8490 -#define arch_randomize_brk arch_randomize_brk
8491 -
8492 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8493
8494 #endif
8495 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8496 index c4a93d6..4d2a9b4 100644
8497 --- a/arch/s390/include/asm/exec.h
8498 +++ b/arch/s390/include/asm/exec.h
8499 @@ -7,6 +7,6 @@
8500 #ifndef __ASM_EXEC_H
8501 #define __ASM_EXEC_H
8502
8503 -extern unsigned long arch_align_stack(unsigned long sp);
8504 +#define arch_align_stack(x) ((x) & ~0xfUL)
8505
8506 #endif /* __ASM_EXEC_H */
8507 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8508 index 9c33ed4..e40cbef 100644
8509 --- a/arch/s390/include/asm/uaccess.h
8510 +++ b/arch/s390/include/asm/uaccess.h
8511 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8512 copy_to_user(void __user *to, const void *from, unsigned long n)
8513 {
8514 might_fault();
8515 +
8516 + if ((long)n < 0)
8517 + return n;
8518 +
8519 return __copy_to_user(to, from, n);
8520 }
8521
8522 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8523 static inline unsigned long __must_check
8524 __copy_from_user(void *to, const void __user *from, unsigned long n)
8525 {
8526 + if ((long)n < 0)
8527 + return n;
8528 +
8529 if (__builtin_constant_p(n) && (n <= 256))
8530 return uaccess.copy_from_user_small(n, from, to);
8531 else
8532 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8533 static inline unsigned long __must_check
8534 copy_from_user(void *to, const void __user *from, unsigned long n)
8535 {
8536 - unsigned int sz = __compiletime_object_size(to);
8537 + size_t sz = __compiletime_object_size(to);
8538
8539 might_fault();
8540 - if (unlikely(sz != -1 && sz < n)) {
8541 +
8542 + if ((long)n < 0)
8543 + return n;
8544 +
8545 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8546 copy_from_user_overflow();
8547 return n;
8548 }
8549 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8550 index 7845e15..59c4353 100644
8551 --- a/arch/s390/kernel/module.c
8552 +++ b/arch/s390/kernel/module.c
8553 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8554
8555 /* Increase core size by size of got & plt and set start
8556 offsets for got and plt. */
8557 - me->core_size = ALIGN(me->core_size, 4);
8558 - me->arch.got_offset = me->core_size;
8559 - me->core_size += me->arch.got_size;
8560 - me->arch.plt_offset = me->core_size;
8561 - me->core_size += me->arch.plt_size;
8562 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8563 + me->arch.got_offset = me->core_size_rw;
8564 + me->core_size_rw += me->arch.got_size;
8565 + me->arch.plt_offset = me->core_size_rx;
8566 + me->core_size_rx += me->arch.plt_size;
8567 return 0;
8568 }
8569
8570 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8571 if (info->got_initialized == 0) {
8572 Elf_Addr *gotent;
8573
8574 - gotent = me->module_core + me->arch.got_offset +
8575 + gotent = me->module_core_rw + me->arch.got_offset +
8576 info->got_offset;
8577 *gotent = val;
8578 info->got_initialized = 1;
8579 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8580 rc = apply_rela_bits(loc, val, 0, 64, 0);
8581 else if (r_type == R_390_GOTENT ||
8582 r_type == R_390_GOTPLTENT) {
8583 - val += (Elf_Addr) me->module_core - loc;
8584 + val += (Elf_Addr) me->module_core_rw - loc;
8585 rc = apply_rela_bits(loc, val, 1, 32, 1);
8586 }
8587 break;
8588 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8589 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8590 if (info->plt_initialized == 0) {
8591 unsigned int *ip;
8592 - ip = me->module_core + me->arch.plt_offset +
8593 + ip = me->module_core_rx + me->arch.plt_offset +
8594 info->plt_offset;
8595 #ifndef CONFIG_64BIT
8596 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8597 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8598 val - loc + 0xffffUL < 0x1ffffeUL) ||
8599 (r_type == R_390_PLT32DBL &&
8600 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8601 - val = (Elf_Addr) me->module_core +
8602 + val = (Elf_Addr) me->module_core_rx +
8603 me->arch.plt_offset +
8604 info->plt_offset;
8605 val += rela->r_addend - loc;
8606 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8607 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8608 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8609 val = val + rela->r_addend -
8610 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8611 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8612 if (r_type == R_390_GOTOFF16)
8613 rc = apply_rela_bits(loc, val, 0, 16, 0);
8614 else if (r_type == R_390_GOTOFF32)
8615 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8616 break;
8617 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8618 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8619 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8620 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8621 rela->r_addend - loc;
8622 if (r_type == R_390_GOTPC)
8623 rc = apply_rela_bits(loc, val, 1, 32, 0);
8624 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8625 index c5dbb33..b41f4ee 100644
8626 --- a/arch/s390/kernel/process.c
8627 +++ b/arch/s390/kernel/process.c
8628 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8629 }
8630 return 0;
8631 }
8632 -
8633 -unsigned long arch_align_stack(unsigned long sp)
8634 -{
8635 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8636 - sp -= get_random_int() & ~PAGE_MASK;
8637 - return sp & ~0xf;
8638 -}
8639 -
8640 -static inline unsigned long brk_rnd(void)
8641 -{
8642 - /* 8MB for 32bit, 1GB for 64bit */
8643 - if (is_32bit_task())
8644 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8645 - else
8646 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8647 -}
8648 -
8649 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8650 -{
8651 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8652 -
8653 - if (ret < mm->brk)
8654 - return mm->brk;
8655 - return ret;
8656 -}
8657 -
8658 -unsigned long randomize_et_dyn(unsigned long base)
8659 -{
8660 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8661 -
8662 - if (!(current->flags & PF_RANDOMIZE))
8663 - return base;
8664 - if (ret < base)
8665 - return base;
8666 - return ret;
8667 -}
8668 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8669 index 4002329..99b67cb 100644
8670 --- a/arch/s390/mm/mmap.c
8671 +++ b/arch/s390/mm/mmap.c
8672 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8673 */
8674 if (mmap_is_legacy()) {
8675 mm->mmap_base = TASK_UNMAPPED_BASE;
8676 +
8677 +#ifdef CONFIG_PAX_RANDMMAP
8678 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8679 + mm->mmap_base += mm->delta_mmap;
8680 +#endif
8681 +
8682 mm->get_unmapped_area = arch_get_unmapped_area;
8683 } else {
8684 mm->mmap_base = mmap_base();
8685 +
8686 +#ifdef CONFIG_PAX_RANDMMAP
8687 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8688 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8689 +#endif
8690 +
8691 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8692 }
8693 }
8694 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8695 */
8696 if (mmap_is_legacy()) {
8697 mm->mmap_base = TASK_UNMAPPED_BASE;
8698 +
8699 +#ifdef CONFIG_PAX_RANDMMAP
8700 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8701 + mm->mmap_base += mm->delta_mmap;
8702 +#endif
8703 +
8704 mm->get_unmapped_area = s390_get_unmapped_area;
8705 } else {
8706 mm->mmap_base = mmap_base();
8707 +
8708 +#ifdef CONFIG_PAX_RANDMMAP
8709 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8710 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8711 +#endif
8712 +
8713 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8714 }
8715 }
8716 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8717 index ae3d59f..f65f075 100644
8718 --- a/arch/score/include/asm/cache.h
8719 +++ b/arch/score/include/asm/cache.h
8720 @@ -1,7 +1,9 @@
8721 #ifndef _ASM_SCORE_CACHE_H
8722 #define _ASM_SCORE_CACHE_H
8723
8724 +#include <linux/const.h>
8725 +
8726 #define L1_CACHE_SHIFT 4
8727 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8728 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8729
8730 #endif /* _ASM_SCORE_CACHE_H */
8731 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8732 index f9f3cd5..58ff438 100644
8733 --- a/arch/score/include/asm/exec.h
8734 +++ b/arch/score/include/asm/exec.h
8735 @@ -1,6 +1,6 @@
8736 #ifndef _ASM_SCORE_EXEC_H
8737 #define _ASM_SCORE_EXEC_H
8738
8739 -extern unsigned long arch_align_stack(unsigned long sp);
8740 +#define arch_align_stack(x) (x)
8741
8742 #endif /* _ASM_SCORE_EXEC_H */
8743 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8744 index a1519ad3..e8ac1ff 100644
8745 --- a/arch/score/kernel/process.c
8746 +++ b/arch/score/kernel/process.c
8747 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8748
8749 return task_pt_regs(task)->cp0_epc;
8750 }
8751 -
8752 -unsigned long arch_align_stack(unsigned long sp)
8753 -{
8754 - return sp;
8755 -}
8756 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8757 index ef9e555..331bd29 100644
8758 --- a/arch/sh/include/asm/cache.h
8759 +++ b/arch/sh/include/asm/cache.h
8760 @@ -9,10 +9,11 @@
8761 #define __ASM_SH_CACHE_H
8762 #ifdef __KERNEL__
8763
8764 +#include <linux/const.h>
8765 #include <linux/init.h>
8766 #include <cpu/cache.h>
8767
8768 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8769 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8770
8771 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8772
8773 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8774 index 6777177..cb5e44f 100644
8775 --- a/arch/sh/mm/mmap.c
8776 +++ b/arch/sh/mm/mmap.c
8777 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8778 struct mm_struct *mm = current->mm;
8779 struct vm_area_struct *vma;
8780 int do_colour_align;
8781 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8782 struct vm_unmapped_area_info info;
8783
8784 if (flags & MAP_FIXED) {
8785 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8786 if (filp || (flags & MAP_SHARED))
8787 do_colour_align = 1;
8788
8789 +#ifdef CONFIG_PAX_RANDMMAP
8790 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8791 +#endif
8792 +
8793 if (addr) {
8794 if (do_colour_align)
8795 addr = COLOUR_ALIGN(addr, pgoff);
8796 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8797 addr = PAGE_ALIGN(addr);
8798
8799 vma = find_vma(mm, addr);
8800 - if (TASK_SIZE - len >= addr &&
8801 - (!vma || addr + len <= vma->vm_start))
8802 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8803 return addr;
8804 }
8805
8806 info.flags = 0;
8807 info.length = len;
8808 - info.low_limit = TASK_UNMAPPED_BASE;
8809 + info.low_limit = mm->mmap_base;
8810 info.high_limit = TASK_SIZE;
8811 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8812 info.align_offset = pgoff << PAGE_SHIFT;
8813 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8814 struct mm_struct *mm = current->mm;
8815 unsigned long addr = addr0;
8816 int do_colour_align;
8817 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8818 struct vm_unmapped_area_info info;
8819
8820 if (flags & MAP_FIXED) {
8821 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8822 if (filp || (flags & MAP_SHARED))
8823 do_colour_align = 1;
8824
8825 +#ifdef CONFIG_PAX_RANDMMAP
8826 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8827 +#endif
8828 +
8829 /* requesting a specific address */
8830 if (addr) {
8831 if (do_colour_align)
8832 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8833 addr = PAGE_ALIGN(addr);
8834
8835 vma = find_vma(mm, addr);
8836 - if (TASK_SIZE - len >= addr &&
8837 - (!vma || addr + len <= vma->vm_start))
8838 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8839 return addr;
8840 }
8841
8842 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8843 VM_BUG_ON(addr != -ENOMEM);
8844 info.flags = 0;
8845 info.low_limit = TASK_UNMAPPED_BASE;
8846 +
8847 +#ifdef CONFIG_PAX_RANDMMAP
8848 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8849 + info.low_limit += mm->delta_mmap;
8850 +#endif
8851 +
8852 info.high_limit = TASK_SIZE;
8853 addr = vm_unmapped_area(&info);
8854 }
8855 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8856 index be56a24..443328f 100644
8857 --- a/arch/sparc/include/asm/atomic_64.h
8858 +++ b/arch/sparc/include/asm/atomic_64.h
8859 @@ -14,18 +14,40 @@
8860 #define ATOMIC64_INIT(i) { (i) }
8861
8862 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8863 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8864 +{
8865 + return v->counter;
8866 +}
8867 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8868 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8869 +{
8870 + return v->counter;
8871 +}
8872
8873 #define atomic_set(v, i) (((v)->counter) = i)
8874 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8875 +{
8876 + v->counter = i;
8877 +}
8878 #define atomic64_set(v, i) (((v)->counter) = i)
8879 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8880 +{
8881 + v->counter = i;
8882 +}
8883
8884 extern void atomic_add(int, atomic_t *);
8885 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8886 extern void atomic64_add(long, atomic64_t *);
8887 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8888 extern void atomic_sub(int, atomic_t *);
8889 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8890 extern void atomic64_sub(long, atomic64_t *);
8891 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8892
8893 extern int atomic_add_ret(int, atomic_t *);
8894 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8895 extern long atomic64_add_ret(long, atomic64_t *);
8896 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8897 extern int atomic_sub_ret(int, atomic_t *);
8898 extern long atomic64_sub_ret(long, atomic64_t *);
8899
8900 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8901 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8902
8903 #define atomic_inc_return(v) atomic_add_ret(1, v)
8904 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8905 +{
8906 + return atomic_add_ret_unchecked(1, v);
8907 +}
8908 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8909 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8910 +{
8911 + return atomic64_add_ret_unchecked(1, v);
8912 +}
8913
8914 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8915 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8916
8917 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8918 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8919 +{
8920 + return atomic_add_ret_unchecked(i, v);
8921 +}
8922 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8923 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8924 +{
8925 + return atomic64_add_ret_unchecked(i, v);
8926 +}
8927
8928 /*
8929 * atomic_inc_and_test - increment and test
8930 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8931 * other cases.
8932 */
8933 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8934 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8935 +{
8936 + return atomic_inc_return_unchecked(v) == 0;
8937 +}
8938 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8939
8940 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8941 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8942 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8943
8944 #define atomic_inc(v) atomic_add(1, v)
8945 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8946 +{
8947 + atomic_add_unchecked(1, v);
8948 +}
8949 #define atomic64_inc(v) atomic64_add(1, v)
8950 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8951 +{
8952 + atomic64_add_unchecked(1, v);
8953 +}
8954
8955 #define atomic_dec(v) atomic_sub(1, v)
8956 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8957 +{
8958 + atomic_sub_unchecked(1, v);
8959 +}
8960 #define atomic64_dec(v) atomic64_sub(1, v)
8961 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8962 +{
8963 + atomic64_sub_unchecked(1, v);
8964 +}
8965
8966 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8967 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8968
8969 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8970 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8971 +{
8972 + return cmpxchg(&v->counter, old, new);
8973 +}
8974 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8975 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8976 +{
8977 + return xchg(&v->counter, new);
8978 +}
8979
8980 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8981 {
8982 - int c, old;
8983 + int c, old, new;
8984 c = atomic_read(v);
8985 for (;;) {
8986 - if (unlikely(c == (u)))
8987 + if (unlikely(c == u))
8988 break;
8989 - old = atomic_cmpxchg((v), c, c + (a));
8990 +
8991 + asm volatile("addcc %2, %0, %0\n"
8992 +
8993 +#ifdef CONFIG_PAX_REFCOUNT
8994 + "tvs %%icc, 6\n"
8995 +#endif
8996 +
8997 + : "=r" (new)
8998 + : "0" (c), "ir" (a)
8999 + : "cc");
9000 +
9001 + old = atomic_cmpxchg(v, c, new);
9002 if (likely(old == c))
9003 break;
9004 c = old;
9005 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9006 #define atomic64_cmpxchg(v, o, n) \
9007 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9008 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9009 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9010 +{
9011 + return xchg(&v->counter, new);
9012 +}
9013
9014 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9015 {
9016 - long c, old;
9017 + long c, old, new;
9018 c = atomic64_read(v);
9019 for (;;) {
9020 - if (unlikely(c == (u)))
9021 + if (unlikely(c == u))
9022 break;
9023 - old = atomic64_cmpxchg((v), c, c + (a));
9024 +
9025 + asm volatile("addcc %2, %0, %0\n"
9026 +
9027 +#ifdef CONFIG_PAX_REFCOUNT
9028 + "tvs %%xcc, 6\n"
9029 +#endif
9030 +
9031 + : "=r" (new)
9032 + : "0" (c), "ir" (a)
9033 + : "cc");
9034 +
9035 + old = atomic64_cmpxchg(v, c, new);
9036 if (likely(old == c))
9037 break;
9038 c = old;
9039 }
9040 - return c != (u);
9041 + return c != u;
9042 }
9043
9044 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9045 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9046 index 5bb6991..5c2132e 100644
9047 --- a/arch/sparc/include/asm/cache.h
9048 +++ b/arch/sparc/include/asm/cache.h
9049 @@ -7,10 +7,12 @@
9050 #ifndef _SPARC_CACHE_H
9051 #define _SPARC_CACHE_H
9052
9053 +#include <linux/const.h>
9054 +
9055 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9056
9057 #define L1_CACHE_SHIFT 5
9058 -#define L1_CACHE_BYTES 32
9059 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9060
9061 #ifdef CONFIG_SPARC32
9062 #define SMP_CACHE_BYTES_SHIFT 5
9063 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9064 index a24e41f..47677ff 100644
9065 --- a/arch/sparc/include/asm/elf_32.h
9066 +++ b/arch/sparc/include/asm/elf_32.h
9067 @@ -114,6 +114,13 @@ typedef struct {
9068
9069 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9070
9071 +#ifdef CONFIG_PAX_ASLR
9072 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9073 +
9074 +#define PAX_DELTA_MMAP_LEN 16
9075 +#define PAX_DELTA_STACK_LEN 16
9076 +#endif
9077 +
9078 /* This yields a mask that user programs can use to figure out what
9079 instruction set this cpu supports. This can NOT be done in userspace
9080 on Sparc. */
9081 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9082 index 370ca1e..d4f4a98 100644
9083 --- a/arch/sparc/include/asm/elf_64.h
9084 +++ b/arch/sparc/include/asm/elf_64.h
9085 @@ -189,6 +189,13 @@ typedef struct {
9086 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9087 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9088
9089 +#ifdef CONFIG_PAX_ASLR
9090 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9091 +
9092 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9093 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9094 +#endif
9095 +
9096 extern unsigned long sparc64_elf_hwcap;
9097 #define ELF_HWCAP sparc64_elf_hwcap
9098
9099 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9100 index 9b1c36d..209298b 100644
9101 --- a/arch/sparc/include/asm/pgalloc_32.h
9102 +++ b/arch/sparc/include/asm/pgalloc_32.h
9103 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9104 }
9105
9106 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9107 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9108
9109 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9110 unsigned long address)
9111 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9112 index bcfe063..b333142 100644
9113 --- a/arch/sparc/include/asm/pgalloc_64.h
9114 +++ b/arch/sparc/include/asm/pgalloc_64.h
9115 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9116 }
9117
9118 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9119 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9120
9121 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9122 {
9123 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9124 index 502f632..da1917f 100644
9125 --- a/arch/sparc/include/asm/pgtable_32.h
9126 +++ b/arch/sparc/include/asm/pgtable_32.h
9127 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9128 #define PAGE_SHARED SRMMU_PAGE_SHARED
9129 #define PAGE_COPY SRMMU_PAGE_COPY
9130 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9131 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9132 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9133 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9134 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9135
9136 /* Top-level page directory - dummy used by init-mm.
9137 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9138
9139 /* xwr */
9140 #define __P000 PAGE_NONE
9141 -#define __P001 PAGE_READONLY
9142 -#define __P010 PAGE_COPY
9143 -#define __P011 PAGE_COPY
9144 +#define __P001 PAGE_READONLY_NOEXEC
9145 +#define __P010 PAGE_COPY_NOEXEC
9146 +#define __P011 PAGE_COPY_NOEXEC
9147 #define __P100 PAGE_READONLY
9148 #define __P101 PAGE_READONLY
9149 #define __P110 PAGE_COPY
9150 #define __P111 PAGE_COPY
9151
9152 #define __S000 PAGE_NONE
9153 -#define __S001 PAGE_READONLY
9154 -#define __S010 PAGE_SHARED
9155 -#define __S011 PAGE_SHARED
9156 +#define __S001 PAGE_READONLY_NOEXEC
9157 +#define __S010 PAGE_SHARED_NOEXEC
9158 +#define __S011 PAGE_SHARED_NOEXEC
9159 #define __S100 PAGE_READONLY
9160 #define __S101 PAGE_READONLY
9161 #define __S110 PAGE_SHARED
9162 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9163 index 79da178..c2eede8 100644
9164 --- a/arch/sparc/include/asm/pgtsrmmu.h
9165 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9166 @@ -115,6 +115,11 @@
9167 SRMMU_EXEC | SRMMU_REF)
9168 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9169 SRMMU_EXEC | SRMMU_REF)
9170 +
9171 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9172 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9173 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9174 +
9175 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9176 SRMMU_DIRTY | SRMMU_REF)
9177
9178 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9179 index 9689176..63c18ea 100644
9180 --- a/arch/sparc/include/asm/spinlock_64.h
9181 +++ b/arch/sparc/include/asm/spinlock_64.h
9182 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9183
9184 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9185
9186 -static void inline arch_read_lock(arch_rwlock_t *lock)
9187 +static inline void arch_read_lock(arch_rwlock_t *lock)
9188 {
9189 unsigned long tmp1, tmp2;
9190
9191 __asm__ __volatile__ (
9192 "1: ldsw [%2], %0\n"
9193 " brlz,pn %0, 2f\n"
9194 -"4: add %0, 1, %1\n"
9195 +"4: addcc %0, 1, %1\n"
9196 +
9197 +#ifdef CONFIG_PAX_REFCOUNT
9198 +" tvs %%icc, 6\n"
9199 +#endif
9200 +
9201 " cas [%2], %0, %1\n"
9202 " cmp %0, %1\n"
9203 " bne,pn %%icc, 1b\n"
9204 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9205 " .previous"
9206 : "=&r" (tmp1), "=&r" (tmp2)
9207 : "r" (lock)
9208 - : "memory");
9209 + : "memory", "cc");
9210 }
9211
9212 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9213 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9214 {
9215 int tmp1, tmp2;
9216
9217 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9218 "1: ldsw [%2], %0\n"
9219 " brlz,a,pn %0, 2f\n"
9220 " mov 0, %0\n"
9221 -" add %0, 1, %1\n"
9222 +" addcc %0, 1, %1\n"
9223 +
9224 +#ifdef CONFIG_PAX_REFCOUNT
9225 +" tvs %%icc, 6\n"
9226 +#endif
9227 +
9228 " cas [%2], %0, %1\n"
9229 " cmp %0, %1\n"
9230 " bne,pn %%icc, 1b\n"
9231 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9232 return tmp1;
9233 }
9234
9235 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9236 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9237 {
9238 unsigned long tmp1, tmp2;
9239
9240 __asm__ __volatile__(
9241 "1: lduw [%2], %0\n"
9242 -" sub %0, 1, %1\n"
9243 +" subcc %0, 1, %1\n"
9244 +
9245 +#ifdef CONFIG_PAX_REFCOUNT
9246 +" tvs %%icc, 6\n"
9247 +#endif
9248 +
9249 " cas [%2], %0, %1\n"
9250 " cmp %0, %1\n"
9251 " bne,pn %%xcc, 1b\n"
9252 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9253 : "memory");
9254 }
9255
9256 -static void inline arch_write_lock(arch_rwlock_t *lock)
9257 +static inline void arch_write_lock(arch_rwlock_t *lock)
9258 {
9259 unsigned long mask, tmp1, tmp2;
9260
9261 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9262 : "memory");
9263 }
9264
9265 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9266 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9267 {
9268 __asm__ __volatile__(
9269 " stw %%g0, [%0]"
9270 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9271 : "memory");
9272 }
9273
9274 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9275 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9276 {
9277 unsigned long mask, tmp1, tmp2, result;
9278
9279 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9280 index dd38075..e7cac83 100644
9281 --- a/arch/sparc/include/asm/thread_info_32.h
9282 +++ b/arch/sparc/include/asm/thread_info_32.h
9283 @@ -49,6 +49,8 @@ struct thread_info {
9284 unsigned long w_saved;
9285
9286 struct restart_block restart_block;
9287 +
9288 + unsigned long lowest_stack;
9289 };
9290
9291 /*
9292 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9293 index d5e5042..9bfee76 100644
9294 --- a/arch/sparc/include/asm/thread_info_64.h
9295 +++ b/arch/sparc/include/asm/thread_info_64.h
9296 @@ -63,6 +63,8 @@ struct thread_info {
9297 struct pt_regs *kern_una_regs;
9298 unsigned int kern_una_insn;
9299
9300 + unsigned long lowest_stack;
9301 +
9302 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9303 };
9304
9305 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9306 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9307 /* flag bit 6 is available */
9308 #define TIF_32BIT 7 /* 32-bit binary */
9309 -/* flag bit 8 is available */
9310 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9311 #define TIF_SECCOMP 9 /* secure computing */
9312 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9313 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9314 +
9315 /* NOTE: Thread flags >= 12 should be ones we have no interest
9316 * in using in assembly, else we can't use the mask as
9317 * an immediate value in instructions such as andcc.
9318 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9319 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9320 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9321 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9322 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9323
9324 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9325 _TIF_DO_NOTIFY_RESUME_MASK | \
9326 _TIF_NEED_RESCHED)
9327 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9328
9329 +#define _TIF_WORK_SYSCALL \
9330 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9331 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9332 +
9333 +
9334 /*
9335 * Thread-synchronous status.
9336 *
9337 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9338 index 0167d26..767bb0c 100644
9339 --- a/arch/sparc/include/asm/uaccess.h
9340 +++ b/arch/sparc/include/asm/uaccess.h
9341 @@ -1,5 +1,6 @@
9342 #ifndef ___ASM_SPARC_UACCESS_H
9343 #define ___ASM_SPARC_UACCESS_H
9344 +
9345 #if defined(__sparc__) && defined(__arch64__)
9346 #include <asm/uaccess_64.h>
9347 #else
9348 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9349 index 53a28dd..50c38c3 100644
9350 --- a/arch/sparc/include/asm/uaccess_32.h
9351 +++ b/arch/sparc/include/asm/uaccess_32.h
9352 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9353
9354 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9355 {
9356 - if (n && __access_ok((unsigned long) to, n))
9357 + if ((long)n < 0)
9358 + return n;
9359 +
9360 + if (n && __access_ok((unsigned long) to, n)) {
9361 + if (!__builtin_constant_p(n))
9362 + check_object_size(from, n, true);
9363 return __copy_user(to, (__force void __user *) from, n);
9364 - else
9365 + } else
9366 return n;
9367 }
9368
9369 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9370 {
9371 + if ((long)n < 0)
9372 + return n;
9373 +
9374 + if (!__builtin_constant_p(n))
9375 + check_object_size(from, n, true);
9376 +
9377 return __copy_user(to, (__force void __user *) from, n);
9378 }
9379
9380 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9381 {
9382 - if (n && __access_ok((unsigned long) from, n))
9383 + if ((long)n < 0)
9384 + return n;
9385 +
9386 + if (n && __access_ok((unsigned long) from, n)) {
9387 + if (!__builtin_constant_p(n))
9388 + check_object_size(to, n, false);
9389 return __copy_user((__force void __user *) to, from, n);
9390 - else
9391 + } else
9392 return n;
9393 }
9394
9395 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9396 {
9397 + if ((long)n < 0)
9398 + return n;
9399 +
9400 return __copy_user((__force void __user *) to, from, n);
9401 }
9402
9403 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9404 index e562d3c..191f176 100644
9405 --- a/arch/sparc/include/asm/uaccess_64.h
9406 +++ b/arch/sparc/include/asm/uaccess_64.h
9407 @@ -10,6 +10,7 @@
9408 #include <linux/compiler.h>
9409 #include <linux/string.h>
9410 #include <linux/thread_info.h>
9411 +#include <linux/kernel.h>
9412 #include <asm/asi.h>
9413 #include <asm/spitfire.h>
9414 #include <asm-generic/uaccess-unaligned.h>
9415 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9416 static inline unsigned long __must_check
9417 copy_from_user(void *to, const void __user *from, unsigned long size)
9418 {
9419 - unsigned long ret = ___copy_from_user(to, from, size);
9420 + unsigned long ret;
9421
9422 + if ((long)size < 0 || size > INT_MAX)
9423 + return size;
9424 +
9425 + if (!__builtin_constant_p(size))
9426 + check_object_size(to, size, false);
9427 +
9428 + ret = ___copy_from_user(to, from, size);
9429 if (unlikely(ret))
9430 ret = copy_from_user_fixup(to, from, size);
9431
9432 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9433 static inline unsigned long __must_check
9434 copy_to_user(void __user *to, const void *from, unsigned long size)
9435 {
9436 - unsigned long ret = ___copy_to_user(to, from, size);
9437 + unsigned long ret;
9438
9439 + if ((long)size < 0 || size > INT_MAX)
9440 + return size;
9441 +
9442 + if (!__builtin_constant_p(size))
9443 + check_object_size(from, size, true);
9444 +
9445 + ret = ___copy_to_user(to, from, size);
9446 if (unlikely(ret))
9447 ret = copy_to_user_fixup(to, from, size);
9448 return ret;
9449 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9450 index d15cc17..d0ae796 100644
9451 --- a/arch/sparc/kernel/Makefile
9452 +++ b/arch/sparc/kernel/Makefile
9453 @@ -4,7 +4,7 @@
9454 #
9455
9456 asflags-y := -ansi
9457 -ccflags-y := -Werror
9458 +#ccflags-y := -Werror
9459
9460 extra-y := head_$(BITS).o
9461
9462 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9463 index fdd819d..5af08c8 100644
9464 --- a/arch/sparc/kernel/process_32.c
9465 +++ b/arch/sparc/kernel/process_32.c
9466 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9467
9468 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9469 r->psr, r->pc, r->npc, r->y, print_tainted());
9470 - printk("PC: <%pS>\n", (void *) r->pc);
9471 + printk("PC: <%pA>\n", (void *) r->pc);
9472 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9473 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9474 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9475 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9476 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9477 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9478 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9479 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9480
9481 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9482 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9483 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9484 rw = (struct reg_window32 *) fp;
9485 pc = rw->ins[7];
9486 printk("[%08lx : ", pc);
9487 - printk("%pS ] ", (void *) pc);
9488 + printk("%pA ] ", (void *) pc);
9489 fp = rw->ins[6];
9490 } while (++count < 16);
9491 printk("\n");
9492 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9493 index baebab2..9cd13b1 100644
9494 --- a/arch/sparc/kernel/process_64.c
9495 +++ b/arch/sparc/kernel/process_64.c
9496 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9497 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9498 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9499 if (regs->tstate & TSTATE_PRIV)
9500 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9501 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9502 }
9503
9504 void show_regs(struct pt_regs *regs)
9505 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9506
9507 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9508 regs->tpc, regs->tnpc, regs->y, print_tainted());
9509 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9510 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9511 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9512 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9513 regs->u_regs[3]);
9514 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9515 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9516 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9517 regs->u_regs[15]);
9518 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9519 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9520 show_regwindow(regs);
9521 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9522 }
9523 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9524 ((tp && tp->task) ? tp->task->pid : -1));
9525
9526 if (gp->tstate & TSTATE_PRIV) {
9527 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9528 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9529 (void *) gp->tpc,
9530 (void *) gp->o7,
9531 (void *) gp->i7,
9532 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9533 index 79cc0d1..ec62734 100644
9534 --- a/arch/sparc/kernel/prom_common.c
9535 +++ b/arch/sparc/kernel/prom_common.c
9536 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9537
9538 unsigned int prom_early_allocated __initdata;
9539
9540 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9541 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9542 .nextprop = prom_common_nextprop,
9543 .getproplen = prom_getproplen,
9544 .getproperty = prom_getproperty,
9545 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9546 index 773c1f2..a8bdd87 100644
9547 --- a/arch/sparc/kernel/ptrace_64.c
9548 +++ b/arch/sparc/kernel/ptrace_64.c
9549 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9550 return ret;
9551 }
9552
9553 +#ifdef CONFIG_GRKERNSEC_SETXID
9554 +extern void gr_delayed_cred_worker(void);
9555 +#endif
9556 +
9557 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9558 {
9559 int ret = 0;
9560 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9561 /* do the secure computing check first */
9562 secure_computing_strict(regs->u_regs[UREG_G1]);
9563
9564 +#ifdef CONFIG_GRKERNSEC_SETXID
9565 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9566 + gr_delayed_cred_worker();
9567 +#endif
9568 +
9569 if (test_thread_flag(TIF_SYSCALL_TRACE))
9570 ret = tracehook_report_syscall_entry(regs);
9571
9572 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9573
9574 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9575 {
9576 +#ifdef CONFIG_GRKERNSEC_SETXID
9577 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9578 + gr_delayed_cred_worker();
9579 +#endif
9580 +
9581 audit_syscall_exit(regs);
9582
9583 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9584 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9585 index e142545..fd29654 100644
9586 --- a/arch/sparc/kernel/smp_64.c
9587 +++ b/arch/sparc/kernel/smp_64.c
9588 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9589 extern unsigned long xcall_flush_dcache_page_spitfire;
9590
9591 #ifdef CONFIG_DEBUG_DCFLUSH
9592 -extern atomic_t dcpage_flushes;
9593 -extern atomic_t dcpage_flushes_xcall;
9594 +extern atomic_unchecked_t dcpage_flushes;
9595 +extern atomic_unchecked_t dcpage_flushes_xcall;
9596 #endif
9597
9598 static inline void __local_flush_dcache_page(struct page *page)
9599 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9600 return;
9601
9602 #ifdef CONFIG_DEBUG_DCFLUSH
9603 - atomic_inc(&dcpage_flushes);
9604 + atomic_inc_unchecked(&dcpage_flushes);
9605 #endif
9606
9607 this_cpu = get_cpu();
9608 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9609 xcall_deliver(data0, __pa(pg_addr),
9610 (u64) pg_addr, cpumask_of(cpu));
9611 #ifdef CONFIG_DEBUG_DCFLUSH
9612 - atomic_inc(&dcpage_flushes_xcall);
9613 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9614 #endif
9615 }
9616 }
9617 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9618 preempt_disable();
9619
9620 #ifdef CONFIG_DEBUG_DCFLUSH
9621 - atomic_inc(&dcpage_flushes);
9622 + atomic_inc_unchecked(&dcpage_flushes);
9623 #endif
9624 data0 = 0;
9625 pg_addr = page_address(page);
9626 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9627 xcall_deliver(data0, __pa(pg_addr),
9628 (u64) pg_addr, cpu_online_mask);
9629 #ifdef CONFIG_DEBUG_DCFLUSH
9630 - atomic_inc(&dcpage_flushes_xcall);
9631 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9632 #endif
9633 }
9634 __local_flush_dcache_page(page);
9635 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9636 index 3a8d184..49498a8 100644
9637 --- a/arch/sparc/kernel/sys_sparc_32.c
9638 +++ b/arch/sparc/kernel/sys_sparc_32.c
9639 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9640 if (len > TASK_SIZE - PAGE_SIZE)
9641 return -ENOMEM;
9642 if (!addr)
9643 - addr = TASK_UNMAPPED_BASE;
9644 + addr = current->mm->mmap_base;
9645
9646 info.flags = 0;
9647 info.length = len;
9648 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9649 index 51561b8..8256764 100644
9650 --- a/arch/sparc/kernel/sys_sparc_64.c
9651 +++ b/arch/sparc/kernel/sys_sparc_64.c
9652 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9653 struct vm_area_struct * vma;
9654 unsigned long task_size = TASK_SIZE;
9655 int do_color_align;
9656 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9657 struct vm_unmapped_area_info info;
9658
9659 if (flags & MAP_FIXED) {
9660 /* We do not accept a shared mapping if it would violate
9661 * cache aliasing constraints.
9662 */
9663 - if ((flags & MAP_SHARED) &&
9664 + if ((filp || (flags & MAP_SHARED)) &&
9665 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9666 return -EINVAL;
9667 return addr;
9668 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9669 if (filp || (flags & MAP_SHARED))
9670 do_color_align = 1;
9671
9672 +#ifdef CONFIG_PAX_RANDMMAP
9673 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9674 +#endif
9675 +
9676 if (addr) {
9677 if (do_color_align)
9678 addr = COLOR_ALIGN(addr, pgoff);
9679 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9680 addr = PAGE_ALIGN(addr);
9681
9682 vma = find_vma(mm, addr);
9683 - if (task_size - len >= addr &&
9684 - (!vma || addr + len <= vma->vm_start))
9685 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9686 return addr;
9687 }
9688
9689 info.flags = 0;
9690 info.length = len;
9691 - info.low_limit = TASK_UNMAPPED_BASE;
9692 + info.low_limit = mm->mmap_base;
9693 info.high_limit = min(task_size, VA_EXCLUDE_START);
9694 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9695 info.align_offset = pgoff << PAGE_SHIFT;
9696 + info.threadstack_offset = offset;
9697 addr = vm_unmapped_area(&info);
9698
9699 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9700 VM_BUG_ON(addr != -ENOMEM);
9701 info.low_limit = VA_EXCLUDE_END;
9702 +
9703 +#ifdef CONFIG_PAX_RANDMMAP
9704 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9705 + info.low_limit += mm->delta_mmap;
9706 +#endif
9707 +
9708 info.high_limit = task_size;
9709 addr = vm_unmapped_area(&info);
9710 }
9711 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9712 unsigned long task_size = STACK_TOP32;
9713 unsigned long addr = addr0;
9714 int do_color_align;
9715 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9716 struct vm_unmapped_area_info info;
9717
9718 /* This should only ever run for 32-bit processes. */
9719 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9720 /* We do not accept a shared mapping if it would violate
9721 * cache aliasing constraints.
9722 */
9723 - if ((flags & MAP_SHARED) &&
9724 + if ((filp || (flags & MAP_SHARED)) &&
9725 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9726 return -EINVAL;
9727 return addr;
9728 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9729 if (filp || (flags & MAP_SHARED))
9730 do_color_align = 1;
9731
9732 +#ifdef CONFIG_PAX_RANDMMAP
9733 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9734 +#endif
9735 +
9736 /* requesting a specific address */
9737 if (addr) {
9738 if (do_color_align)
9739 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9740 addr = PAGE_ALIGN(addr);
9741
9742 vma = find_vma(mm, addr);
9743 - if (task_size - len >= addr &&
9744 - (!vma || addr + len <= vma->vm_start))
9745 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9746 return addr;
9747 }
9748
9749 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9750 info.high_limit = mm->mmap_base;
9751 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9752 info.align_offset = pgoff << PAGE_SHIFT;
9753 + info.threadstack_offset = offset;
9754 addr = vm_unmapped_area(&info);
9755
9756 /*
9757 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9758 VM_BUG_ON(addr != -ENOMEM);
9759 info.flags = 0;
9760 info.low_limit = TASK_UNMAPPED_BASE;
9761 +
9762 +#ifdef CONFIG_PAX_RANDMMAP
9763 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9764 + info.low_limit += mm->delta_mmap;
9765 +#endif
9766 +
9767 info.high_limit = STACK_TOP32;
9768 addr = vm_unmapped_area(&info);
9769 }
9770 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9771 EXPORT_SYMBOL(get_fb_unmapped_area);
9772
9773 /* Essentially the same as PowerPC. */
9774 -static unsigned long mmap_rnd(void)
9775 +static unsigned long mmap_rnd(struct mm_struct *mm)
9776 {
9777 unsigned long rnd = 0UL;
9778
9779 +#ifdef CONFIG_PAX_RANDMMAP
9780 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9781 +#endif
9782 +
9783 if (current->flags & PF_RANDOMIZE) {
9784 unsigned long val = get_random_int();
9785 if (test_thread_flag(TIF_32BIT))
9786 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9787
9788 void arch_pick_mmap_layout(struct mm_struct *mm)
9789 {
9790 - unsigned long random_factor = mmap_rnd();
9791 + unsigned long random_factor = mmap_rnd(mm);
9792 unsigned long gap;
9793
9794 /*
9795 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9796 gap == RLIM_INFINITY ||
9797 sysctl_legacy_va_layout) {
9798 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9799 +
9800 +#ifdef CONFIG_PAX_RANDMMAP
9801 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9802 + mm->mmap_base += mm->delta_mmap;
9803 +#endif
9804 +
9805 mm->get_unmapped_area = arch_get_unmapped_area;
9806 } else {
9807 /* We know it's 32-bit */
9808 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9809 gap = (task_size / 6 * 5);
9810
9811 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9812 +
9813 +#ifdef CONFIG_PAX_RANDMMAP
9814 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9815 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9816 +#endif
9817 +
9818 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9819 }
9820 }
9821 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9822 index d950197..192f9d8 100644
9823 --- a/arch/sparc/kernel/syscalls.S
9824 +++ b/arch/sparc/kernel/syscalls.S
9825 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9826 #endif
9827 .align 32
9828 1: ldx [%g6 + TI_FLAGS], %l5
9829 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9830 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9831 be,pt %icc, rtrap
9832 nop
9833 call syscall_trace_leave
9834 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9835
9836 srl %i3, 0, %o3 ! IEU0
9837 srl %i2, 0, %o2 ! IEU0 Group
9838 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9839 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9840 bne,pn %icc, linux_syscall_trace32 ! CTI
9841 mov %i0, %l5 ! IEU1
9842 5: call %l7 ! CTI Group brk forced
9843 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9844
9845 mov %i3, %o3 ! IEU1
9846 mov %i4, %o4 ! IEU0 Group
9847 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9848 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9849 bne,pn %icc, linux_syscall_trace ! CTI Group
9850 mov %i0, %l5 ! IEU0
9851 2: call %l7 ! CTI Group brk forced
9852 @@ -223,7 +223,7 @@ ret_sys_call:
9853
9854 cmp %o0, -ERESTART_RESTARTBLOCK
9855 bgeu,pn %xcc, 1f
9856 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9857 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9858 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9859
9860 2:
9861 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9862 index 6629829..036032d 100644
9863 --- a/arch/sparc/kernel/traps_32.c
9864 +++ b/arch/sparc/kernel/traps_32.c
9865 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9866 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9867 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9868
9869 +extern void gr_handle_kernel_exploit(void);
9870 +
9871 void die_if_kernel(char *str, struct pt_regs *regs)
9872 {
9873 static int die_counter;
9874 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9875 count++ < 30 &&
9876 (((unsigned long) rw) >= PAGE_OFFSET) &&
9877 !(((unsigned long) rw) & 0x7)) {
9878 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9879 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9880 (void *) rw->ins[7]);
9881 rw = (struct reg_window32 *)rw->ins[6];
9882 }
9883 }
9884 printk("Instruction DUMP:");
9885 instruction_dump ((unsigned long *) regs->pc);
9886 - if(regs->psr & PSR_PS)
9887 + if(regs->psr & PSR_PS) {
9888 + gr_handle_kernel_exploit();
9889 do_exit(SIGKILL);
9890 + }
9891 do_exit(SIGSEGV);
9892 }
9893
9894 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9895 index b3f833a..f485f80 100644
9896 --- a/arch/sparc/kernel/traps_64.c
9897 +++ b/arch/sparc/kernel/traps_64.c
9898 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9899 i + 1,
9900 p->trapstack[i].tstate, p->trapstack[i].tpc,
9901 p->trapstack[i].tnpc, p->trapstack[i].tt);
9902 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9903 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9904 }
9905 }
9906
9907 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9908
9909 lvl -= 0x100;
9910 if (regs->tstate & TSTATE_PRIV) {
9911 +
9912 +#ifdef CONFIG_PAX_REFCOUNT
9913 + if (lvl == 6)
9914 + pax_report_refcount_overflow(regs);
9915 +#endif
9916 +
9917 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9918 die_if_kernel(buffer, regs);
9919 }
9920 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9921 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9922 {
9923 char buffer[32];
9924 -
9925 +
9926 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9927 0, lvl, SIGTRAP) == NOTIFY_STOP)
9928 return;
9929
9930 +#ifdef CONFIG_PAX_REFCOUNT
9931 + if (lvl == 6)
9932 + pax_report_refcount_overflow(regs);
9933 +#endif
9934 +
9935 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9936
9937 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9938 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9939 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9940 printk("%s" "ERROR(%d): ",
9941 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9942 - printk("TPC<%pS>\n", (void *) regs->tpc);
9943 + printk("TPC<%pA>\n", (void *) regs->tpc);
9944 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9945 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9946 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9947 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9948 smp_processor_id(),
9949 (type & 0x1) ? 'I' : 'D',
9950 regs->tpc);
9951 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9952 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9953 panic("Irrecoverable Cheetah+ parity error.");
9954 }
9955
9956 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9957 smp_processor_id(),
9958 (type & 0x1) ? 'I' : 'D',
9959 regs->tpc);
9960 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9961 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9962 }
9963
9964 struct sun4v_error_entry {
9965 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9966 /*0x38*/u64 reserved_5;
9967 };
9968
9969 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9970 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9971 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9972 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9973
9974 static const char *sun4v_err_type_to_str(u8 type)
9975 {
9976 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9977 }
9978
9979 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9980 - int cpu, const char *pfx, atomic_t *ocnt)
9981 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9982 {
9983 u64 *raw_ptr = (u64 *) ent;
9984 u32 attrs;
9985 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9986
9987 show_regs(regs);
9988
9989 - if ((cnt = atomic_read(ocnt)) != 0) {
9990 - atomic_set(ocnt, 0);
9991 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9992 + atomic_set_unchecked(ocnt, 0);
9993 wmb();
9994 printk("%s: Queue overflowed %d times.\n",
9995 pfx, cnt);
9996 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9997 */
9998 void sun4v_resum_overflow(struct pt_regs *regs)
9999 {
10000 - atomic_inc(&sun4v_resum_oflow_cnt);
10001 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10002 }
10003
10004 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10005 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10006 /* XXX Actually even this can make not that much sense. Perhaps
10007 * XXX we should just pull the plug and panic directly from here?
10008 */
10009 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10010 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10011 }
10012
10013 unsigned long sun4v_err_itlb_vaddr;
10014 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10015
10016 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10017 regs->tpc, tl);
10018 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10019 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10020 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10021 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10022 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10023 (void *) regs->u_regs[UREG_I7]);
10024 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10025 "pte[%lx] error[%lx]\n",
10026 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10027
10028 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10029 regs->tpc, tl);
10030 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10031 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10032 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10033 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10034 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10035 (void *) regs->u_regs[UREG_I7]);
10036 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10037 "pte[%lx] error[%lx]\n",
10038 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10039 fp = (unsigned long)sf->fp + STACK_BIAS;
10040 }
10041
10042 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10043 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10044 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10045 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10046 int index = tsk->curr_ret_stack;
10047 if (tsk->ret_stack && index >= graph) {
10048 pc = tsk->ret_stack[index - graph].ret;
10049 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10050 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10051 graph++;
10052 }
10053 }
10054 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10055 return (struct reg_window *) (fp + STACK_BIAS);
10056 }
10057
10058 +extern void gr_handle_kernel_exploit(void);
10059 +
10060 void die_if_kernel(char *str, struct pt_regs *regs)
10061 {
10062 static int die_counter;
10063 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10064 while (rw &&
10065 count++ < 30 &&
10066 kstack_valid(tp, (unsigned long) rw)) {
10067 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10068 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10069 (void *) rw->ins[7]);
10070
10071 rw = kernel_stack_up(rw);
10072 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10073 }
10074 user_instruction_dump ((unsigned int __user *) regs->tpc);
10075 }
10076 - if (regs->tstate & TSTATE_PRIV)
10077 + if (regs->tstate & TSTATE_PRIV) {
10078 + gr_handle_kernel_exploit();
10079 do_exit(SIGKILL);
10080 + }
10081 do_exit(SIGSEGV);
10082 }
10083 EXPORT_SYMBOL(die_if_kernel);
10084 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10085 index 8201c25e..072a2a7 100644
10086 --- a/arch/sparc/kernel/unaligned_64.c
10087 +++ b/arch/sparc/kernel/unaligned_64.c
10088 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10089 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10090
10091 if (__ratelimit(&ratelimit)) {
10092 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10093 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10094 regs->tpc, (void *) regs->tpc);
10095 }
10096 }
10097 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10098 index dbe119b..089c7c1 100644
10099 --- a/arch/sparc/lib/Makefile
10100 +++ b/arch/sparc/lib/Makefile
10101 @@ -2,7 +2,7 @@
10102 #
10103
10104 asflags-y := -ansi -DST_DIV0=0x02
10105 -ccflags-y := -Werror
10106 +#ccflags-y := -Werror
10107
10108 lib-$(CONFIG_SPARC32) += ashrdi3.o
10109 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10110 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10111 index 85c233d..68500e0 100644
10112 --- a/arch/sparc/lib/atomic_64.S
10113 +++ b/arch/sparc/lib/atomic_64.S
10114 @@ -17,7 +17,12 @@
10115 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10116 BACKOFF_SETUP(%o2)
10117 1: lduw [%o1], %g1
10118 - add %g1, %o0, %g7
10119 + addcc %g1, %o0, %g7
10120 +
10121 +#ifdef CONFIG_PAX_REFCOUNT
10122 + tvs %icc, 6
10123 +#endif
10124 +
10125 cas [%o1], %g1, %g7
10126 cmp %g1, %g7
10127 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10128 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10129 2: BACKOFF_SPIN(%o2, %o3, 1b)
10130 ENDPROC(atomic_add)
10131
10132 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10133 + BACKOFF_SETUP(%o2)
10134 +1: lduw [%o1], %g1
10135 + add %g1, %o0, %g7
10136 + cas [%o1], %g1, %g7
10137 + cmp %g1, %g7
10138 + bne,pn %icc, 2f
10139 + nop
10140 + retl
10141 + nop
10142 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10143 +ENDPROC(atomic_add_unchecked)
10144 +
10145 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10146 BACKOFF_SETUP(%o2)
10147 1: lduw [%o1], %g1
10148 - sub %g1, %o0, %g7
10149 + subcc %g1, %o0, %g7
10150 +
10151 +#ifdef CONFIG_PAX_REFCOUNT
10152 + tvs %icc, 6
10153 +#endif
10154 +
10155 cas [%o1], %g1, %g7
10156 cmp %g1, %g7
10157 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10158 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10159 2: BACKOFF_SPIN(%o2, %o3, 1b)
10160 ENDPROC(atomic_sub)
10161
10162 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10163 + BACKOFF_SETUP(%o2)
10164 +1: lduw [%o1], %g1
10165 + sub %g1, %o0, %g7
10166 + cas [%o1], %g1, %g7
10167 + cmp %g1, %g7
10168 + bne,pn %icc, 2f
10169 + nop
10170 + retl
10171 + nop
10172 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10173 +ENDPROC(atomic_sub_unchecked)
10174 +
10175 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10176 BACKOFF_SETUP(%o2)
10177 1: lduw [%o1], %g1
10178 - add %g1, %o0, %g7
10179 + addcc %g1, %o0, %g7
10180 +
10181 +#ifdef CONFIG_PAX_REFCOUNT
10182 + tvs %icc, 6
10183 +#endif
10184 +
10185 cas [%o1], %g1, %g7
10186 cmp %g1, %g7
10187 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10188 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10189 2: BACKOFF_SPIN(%o2, %o3, 1b)
10190 ENDPROC(atomic_add_ret)
10191
10192 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10193 + BACKOFF_SETUP(%o2)
10194 +1: lduw [%o1], %g1
10195 + addcc %g1, %o0, %g7
10196 + cas [%o1], %g1, %g7
10197 + cmp %g1, %g7
10198 + bne,pn %icc, 2f
10199 + add %g7, %o0, %g7
10200 + sra %g7, 0, %o0
10201 + retl
10202 + nop
10203 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10204 +ENDPROC(atomic_add_ret_unchecked)
10205 +
10206 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10207 BACKOFF_SETUP(%o2)
10208 1: lduw [%o1], %g1
10209 - sub %g1, %o0, %g7
10210 + subcc %g1, %o0, %g7
10211 +
10212 +#ifdef CONFIG_PAX_REFCOUNT
10213 + tvs %icc, 6
10214 +#endif
10215 +
10216 cas [%o1], %g1, %g7
10217 cmp %g1, %g7
10218 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10219 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10220 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10221 BACKOFF_SETUP(%o2)
10222 1: ldx [%o1], %g1
10223 - add %g1, %o0, %g7
10224 + addcc %g1, %o0, %g7
10225 +
10226 +#ifdef CONFIG_PAX_REFCOUNT
10227 + tvs %xcc, 6
10228 +#endif
10229 +
10230 casx [%o1], %g1, %g7
10231 cmp %g1, %g7
10232 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10233 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10234 2: BACKOFF_SPIN(%o2, %o3, 1b)
10235 ENDPROC(atomic64_add)
10236
10237 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10238 + BACKOFF_SETUP(%o2)
10239 +1: ldx [%o1], %g1
10240 + addcc %g1, %o0, %g7
10241 + casx [%o1], %g1, %g7
10242 + cmp %g1, %g7
10243 + bne,pn %xcc, 2f
10244 + nop
10245 + retl
10246 + nop
10247 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10248 +ENDPROC(atomic64_add_unchecked)
10249 +
10250 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10251 BACKOFF_SETUP(%o2)
10252 1: ldx [%o1], %g1
10253 - sub %g1, %o0, %g7
10254 + subcc %g1, %o0, %g7
10255 +
10256 +#ifdef CONFIG_PAX_REFCOUNT
10257 + tvs %xcc, 6
10258 +#endif
10259 +
10260 casx [%o1], %g1, %g7
10261 cmp %g1, %g7
10262 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10263 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10264 2: BACKOFF_SPIN(%o2, %o3, 1b)
10265 ENDPROC(atomic64_sub)
10266
10267 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10268 + BACKOFF_SETUP(%o2)
10269 +1: ldx [%o1], %g1
10270 + subcc %g1, %o0, %g7
10271 + casx [%o1], %g1, %g7
10272 + cmp %g1, %g7
10273 + bne,pn %xcc, 2f
10274 + nop
10275 + retl
10276 + nop
10277 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10278 +ENDPROC(atomic64_sub_unchecked)
10279 +
10280 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10281 BACKOFF_SETUP(%o2)
10282 1: ldx [%o1], %g1
10283 - add %g1, %o0, %g7
10284 + addcc %g1, %o0, %g7
10285 +
10286 +#ifdef CONFIG_PAX_REFCOUNT
10287 + tvs %xcc, 6
10288 +#endif
10289 +
10290 casx [%o1], %g1, %g7
10291 cmp %g1, %g7
10292 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10293 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10294 2: BACKOFF_SPIN(%o2, %o3, 1b)
10295 ENDPROC(atomic64_add_ret)
10296
10297 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10298 + BACKOFF_SETUP(%o2)
10299 +1: ldx [%o1], %g1
10300 + addcc %g1, %o0, %g7
10301 + casx [%o1], %g1, %g7
10302 + cmp %g1, %g7
10303 + bne,pn %xcc, 2f
10304 + add %g7, %o0, %g7
10305 + mov %g7, %o0
10306 + retl
10307 + nop
10308 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10309 +ENDPROC(atomic64_add_ret_unchecked)
10310 +
10311 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10312 BACKOFF_SETUP(%o2)
10313 1: ldx [%o1], %g1
10314 - sub %g1, %o0, %g7
10315 + subcc %g1, %o0, %g7
10316 +
10317 +#ifdef CONFIG_PAX_REFCOUNT
10318 + tvs %xcc, 6
10319 +#endif
10320 +
10321 casx [%o1], %g1, %g7
10322 cmp %g1, %g7
10323 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10324 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10325 index 323335b..ed85ea2 100644
10326 --- a/arch/sparc/lib/ksyms.c
10327 +++ b/arch/sparc/lib/ksyms.c
10328 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10329
10330 /* Atomic counter implementation. */
10331 EXPORT_SYMBOL(atomic_add);
10332 +EXPORT_SYMBOL(atomic_add_unchecked);
10333 EXPORT_SYMBOL(atomic_add_ret);
10334 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10335 EXPORT_SYMBOL(atomic_sub);
10336 +EXPORT_SYMBOL(atomic_sub_unchecked);
10337 EXPORT_SYMBOL(atomic_sub_ret);
10338 EXPORT_SYMBOL(atomic64_add);
10339 +EXPORT_SYMBOL(atomic64_add_unchecked);
10340 EXPORT_SYMBOL(atomic64_add_ret);
10341 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10342 EXPORT_SYMBOL(atomic64_sub);
10343 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10344 EXPORT_SYMBOL(atomic64_sub_ret);
10345 EXPORT_SYMBOL(atomic64_dec_if_positive);
10346
10347 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10348 index 30c3ecc..736f015 100644
10349 --- a/arch/sparc/mm/Makefile
10350 +++ b/arch/sparc/mm/Makefile
10351 @@ -2,7 +2,7 @@
10352 #
10353
10354 asflags-y := -ansi
10355 -ccflags-y := -Werror
10356 +#ccflags-y := -Werror
10357
10358 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10359 obj-y += fault_$(BITS).o
10360 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10361 index 59dbd46..1dd7f5e 100644
10362 --- a/arch/sparc/mm/fault_32.c
10363 +++ b/arch/sparc/mm/fault_32.c
10364 @@ -21,6 +21,9 @@
10365 #include <linux/perf_event.h>
10366 #include <linux/interrupt.h>
10367 #include <linux/kdebug.h>
10368 +#include <linux/slab.h>
10369 +#include <linux/pagemap.h>
10370 +#include <linux/compiler.h>
10371
10372 #include <asm/page.h>
10373 #include <asm/pgtable.h>
10374 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10375 return safe_compute_effective_address(regs, insn);
10376 }
10377
10378 +#ifdef CONFIG_PAX_PAGEEXEC
10379 +#ifdef CONFIG_PAX_DLRESOLVE
10380 +static void pax_emuplt_close(struct vm_area_struct *vma)
10381 +{
10382 + vma->vm_mm->call_dl_resolve = 0UL;
10383 +}
10384 +
10385 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10386 +{
10387 + unsigned int *kaddr;
10388 +
10389 + vmf->page = alloc_page(GFP_HIGHUSER);
10390 + if (!vmf->page)
10391 + return VM_FAULT_OOM;
10392 +
10393 + kaddr = kmap(vmf->page);
10394 + memset(kaddr, 0, PAGE_SIZE);
10395 + kaddr[0] = 0x9DE3BFA8U; /* save */
10396 + flush_dcache_page(vmf->page);
10397 + kunmap(vmf->page);
10398 + return VM_FAULT_MAJOR;
10399 +}
10400 +
10401 +static const struct vm_operations_struct pax_vm_ops = {
10402 + .close = pax_emuplt_close,
10403 + .fault = pax_emuplt_fault
10404 +};
10405 +
10406 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10407 +{
10408 + int ret;
10409 +
10410 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10411 + vma->vm_mm = current->mm;
10412 + vma->vm_start = addr;
10413 + vma->vm_end = addr + PAGE_SIZE;
10414 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10415 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10416 + vma->vm_ops = &pax_vm_ops;
10417 +
10418 + ret = insert_vm_struct(current->mm, vma);
10419 + if (ret)
10420 + return ret;
10421 +
10422 + ++current->mm->total_vm;
10423 + return 0;
10424 +}
10425 +#endif
10426 +
10427 +/*
10428 + * PaX: decide what to do with offenders (regs->pc = fault address)
10429 + *
10430 + * returns 1 when task should be killed
10431 + * 2 when patched PLT trampoline was detected
10432 + * 3 when unpatched PLT trampoline was detected
10433 + */
10434 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10435 +{
10436 +
10437 +#ifdef CONFIG_PAX_EMUPLT
10438 + int err;
10439 +
10440 + do { /* PaX: patched PLT emulation #1 */
10441 + unsigned int sethi1, sethi2, jmpl;
10442 +
10443 + err = get_user(sethi1, (unsigned int *)regs->pc);
10444 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10445 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10446 +
10447 + if (err)
10448 + break;
10449 +
10450 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10451 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10452 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10453 + {
10454 + unsigned int addr;
10455 +
10456 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10457 + addr = regs->u_regs[UREG_G1];
10458 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10459 + regs->pc = addr;
10460 + regs->npc = addr+4;
10461 + return 2;
10462 + }
10463 + } while (0);
10464 +
10465 + do { /* PaX: patched PLT emulation #2 */
10466 + unsigned int ba;
10467 +
10468 + err = get_user(ba, (unsigned int *)regs->pc);
10469 +
10470 + if (err)
10471 + break;
10472 +
10473 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10474 + unsigned int addr;
10475 +
10476 + if ((ba & 0xFFC00000U) == 0x30800000U)
10477 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10478 + else
10479 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10480 + regs->pc = addr;
10481 + regs->npc = addr+4;
10482 + return 2;
10483 + }
10484 + } while (0);
10485 +
10486 + do { /* PaX: patched PLT emulation #3 */
10487 + unsigned int sethi, bajmpl, nop;
10488 +
10489 + err = get_user(sethi, (unsigned int *)regs->pc);
10490 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10491 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10492 +
10493 + if (err)
10494 + break;
10495 +
10496 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10497 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10498 + nop == 0x01000000U)
10499 + {
10500 + unsigned int addr;
10501 +
10502 + addr = (sethi & 0x003FFFFFU) << 10;
10503 + regs->u_regs[UREG_G1] = addr;
10504 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10505 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10506 + else
10507 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10508 + regs->pc = addr;
10509 + regs->npc = addr+4;
10510 + return 2;
10511 + }
10512 + } while (0);
10513 +
10514 + do { /* PaX: unpatched PLT emulation step 1 */
10515 + unsigned int sethi, ba, nop;
10516 +
10517 + err = get_user(sethi, (unsigned int *)regs->pc);
10518 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10519 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10520 +
10521 + if (err)
10522 + break;
10523 +
10524 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10525 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10526 + nop == 0x01000000U)
10527 + {
10528 + unsigned int addr, save, call;
10529 +
10530 + if ((ba & 0xFFC00000U) == 0x30800000U)
10531 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10532 + else
10533 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10534 +
10535 + err = get_user(save, (unsigned int *)addr);
10536 + err |= get_user(call, (unsigned int *)(addr+4));
10537 + err |= get_user(nop, (unsigned int *)(addr+8));
10538 + if (err)
10539 + break;
10540 +
10541 +#ifdef CONFIG_PAX_DLRESOLVE
10542 + if (save == 0x9DE3BFA8U &&
10543 + (call & 0xC0000000U) == 0x40000000U &&
10544 + nop == 0x01000000U)
10545 + {
10546 + struct vm_area_struct *vma;
10547 + unsigned long call_dl_resolve;
10548 +
10549 + down_read(&current->mm->mmap_sem);
10550 + call_dl_resolve = current->mm->call_dl_resolve;
10551 + up_read(&current->mm->mmap_sem);
10552 + if (likely(call_dl_resolve))
10553 + goto emulate;
10554 +
10555 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10556 +
10557 + down_write(&current->mm->mmap_sem);
10558 + if (current->mm->call_dl_resolve) {
10559 + call_dl_resolve = current->mm->call_dl_resolve;
10560 + up_write(&current->mm->mmap_sem);
10561 + if (vma)
10562 + kmem_cache_free(vm_area_cachep, vma);
10563 + goto emulate;
10564 + }
10565 +
10566 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10567 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10568 + up_write(&current->mm->mmap_sem);
10569 + if (vma)
10570 + kmem_cache_free(vm_area_cachep, vma);
10571 + return 1;
10572 + }
10573 +
10574 + if (pax_insert_vma(vma, call_dl_resolve)) {
10575 + up_write(&current->mm->mmap_sem);
10576 + kmem_cache_free(vm_area_cachep, vma);
10577 + return 1;
10578 + }
10579 +
10580 + current->mm->call_dl_resolve = call_dl_resolve;
10581 + up_write(&current->mm->mmap_sem);
10582 +
10583 +emulate:
10584 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10585 + regs->pc = call_dl_resolve;
10586 + regs->npc = addr+4;
10587 + return 3;
10588 + }
10589 +#endif
10590 +
10591 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10592 + if ((save & 0xFFC00000U) == 0x05000000U &&
10593 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10594 + nop == 0x01000000U)
10595 + {
10596 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10597 + regs->u_regs[UREG_G2] = addr + 4;
10598 + addr = (save & 0x003FFFFFU) << 10;
10599 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10600 + regs->pc = addr;
10601 + regs->npc = addr+4;
10602 + return 3;
10603 + }
10604 + }
10605 + } while (0);
10606 +
10607 + do { /* PaX: unpatched PLT emulation step 2 */
10608 + unsigned int save, call, nop;
10609 +
10610 + err = get_user(save, (unsigned int *)(regs->pc-4));
10611 + err |= get_user(call, (unsigned int *)regs->pc);
10612 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10613 + if (err)
10614 + break;
10615 +
10616 + if (save == 0x9DE3BFA8U &&
10617 + (call & 0xC0000000U) == 0x40000000U &&
10618 + nop == 0x01000000U)
10619 + {
10620 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10621 +
10622 + regs->u_regs[UREG_RETPC] = regs->pc;
10623 + regs->pc = dl_resolve;
10624 + regs->npc = dl_resolve+4;
10625 + return 3;
10626 + }
10627 + } while (0);
10628 +#endif
10629 +
10630 + return 1;
10631 +}
10632 +
10633 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10634 +{
10635 + unsigned long i;
10636 +
10637 + printk(KERN_ERR "PAX: bytes at PC: ");
10638 + for (i = 0; i < 8; i++) {
10639 + unsigned int c;
10640 + if (get_user(c, (unsigned int *)pc+i))
10641 + printk(KERN_CONT "???????? ");
10642 + else
10643 + printk(KERN_CONT "%08x ", c);
10644 + }
10645 + printk("\n");
10646 +}
10647 +#endif
10648 +
10649 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10650 int text_fault)
10651 {
10652 @@ -229,6 +503,24 @@ good_area:
10653 if (!(vma->vm_flags & VM_WRITE))
10654 goto bad_area;
10655 } else {
10656 +
10657 +#ifdef CONFIG_PAX_PAGEEXEC
10658 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10659 + up_read(&mm->mmap_sem);
10660 + switch (pax_handle_fetch_fault(regs)) {
10661 +
10662 +#ifdef CONFIG_PAX_EMUPLT
10663 + case 2:
10664 + case 3:
10665 + return;
10666 +#endif
10667 +
10668 + }
10669 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10670 + do_group_exit(SIGKILL);
10671 + }
10672 +#endif
10673 +
10674 /* Allow reads even for write-only mappings */
10675 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10676 goto bad_area;
10677 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10678 index 2ebec26..b212598 100644
10679 --- a/arch/sparc/mm/fault_64.c
10680 +++ b/arch/sparc/mm/fault_64.c
10681 @@ -21,6 +21,9 @@
10682 #include <linux/kprobes.h>
10683 #include <linux/kdebug.h>
10684 #include <linux/percpu.h>
10685 +#include <linux/slab.h>
10686 +#include <linux/pagemap.h>
10687 +#include <linux/compiler.h>
10688
10689 #include <asm/page.h>
10690 #include <asm/pgtable.h>
10691 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10692 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10693 regs->tpc);
10694 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10695 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10696 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10697 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10698 dump_stack();
10699 unhandled_fault(regs->tpc, current, regs);
10700 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10701 show_regs(regs);
10702 }
10703
10704 +#ifdef CONFIG_PAX_PAGEEXEC
10705 +#ifdef CONFIG_PAX_DLRESOLVE
10706 +static void pax_emuplt_close(struct vm_area_struct *vma)
10707 +{
10708 + vma->vm_mm->call_dl_resolve = 0UL;
10709 +}
10710 +
10711 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10712 +{
10713 + unsigned int *kaddr;
10714 +
10715 + vmf->page = alloc_page(GFP_HIGHUSER);
10716 + if (!vmf->page)
10717 + return VM_FAULT_OOM;
10718 +
10719 + kaddr = kmap(vmf->page);
10720 + memset(kaddr, 0, PAGE_SIZE);
10721 + kaddr[0] = 0x9DE3BFA8U; /* save */
10722 + flush_dcache_page(vmf->page);
10723 + kunmap(vmf->page);
10724 + return VM_FAULT_MAJOR;
10725 +}
10726 +
10727 +static const struct vm_operations_struct pax_vm_ops = {
10728 + .close = pax_emuplt_close,
10729 + .fault = pax_emuplt_fault
10730 +};
10731 +
10732 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10733 +{
10734 + int ret;
10735 +
10736 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10737 + vma->vm_mm = current->mm;
10738 + vma->vm_start = addr;
10739 + vma->vm_end = addr + PAGE_SIZE;
10740 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10741 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10742 + vma->vm_ops = &pax_vm_ops;
10743 +
10744 + ret = insert_vm_struct(current->mm, vma);
10745 + if (ret)
10746 + return ret;
10747 +
10748 + ++current->mm->total_vm;
10749 + return 0;
10750 +}
10751 +#endif
10752 +
10753 +/*
10754 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10755 + *
10756 + * returns 1 when task should be killed
10757 + * 2 when patched PLT trampoline was detected
10758 + * 3 when unpatched PLT trampoline was detected
10759 + */
10760 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10761 +{
10762 +
10763 +#ifdef CONFIG_PAX_EMUPLT
10764 + int err;
10765 +
10766 + do { /* PaX: patched PLT emulation #1 */
10767 + unsigned int sethi1, sethi2, jmpl;
10768 +
10769 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10770 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10771 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10772 +
10773 + if (err)
10774 + break;
10775 +
10776 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10777 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10778 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10779 + {
10780 + unsigned long addr;
10781 +
10782 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10783 + addr = regs->u_regs[UREG_G1];
10784 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10785 +
10786 + if (test_thread_flag(TIF_32BIT))
10787 + addr &= 0xFFFFFFFFUL;
10788 +
10789 + regs->tpc = addr;
10790 + regs->tnpc = addr+4;
10791 + return 2;
10792 + }
10793 + } while (0);
10794 +
10795 + do { /* PaX: patched PLT emulation #2 */
10796 + unsigned int ba;
10797 +
10798 + err = get_user(ba, (unsigned int *)regs->tpc);
10799 +
10800 + if (err)
10801 + break;
10802 +
10803 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10804 + unsigned long addr;
10805 +
10806 + if ((ba & 0xFFC00000U) == 0x30800000U)
10807 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10808 + else
10809 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10810 +
10811 + if (test_thread_flag(TIF_32BIT))
10812 + addr &= 0xFFFFFFFFUL;
10813 +
10814 + regs->tpc = addr;
10815 + regs->tnpc = addr+4;
10816 + return 2;
10817 + }
10818 + } while (0);
10819 +
10820 + do { /* PaX: patched PLT emulation #3 */
10821 + unsigned int sethi, bajmpl, nop;
10822 +
10823 + err = get_user(sethi, (unsigned int *)regs->tpc);
10824 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10825 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10826 +
10827 + if (err)
10828 + break;
10829 +
10830 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10831 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10832 + nop == 0x01000000U)
10833 + {
10834 + unsigned long addr;
10835 +
10836 + addr = (sethi & 0x003FFFFFU) << 10;
10837 + regs->u_regs[UREG_G1] = addr;
10838 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10839 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10840 + else
10841 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10842 +
10843 + if (test_thread_flag(TIF_32BIT))
10844 + addr &= 0xFFFFFFFFUL;
10845 +
10846 + regs->tpc = addr;
10847 + regs->tnpc = addr+4;
10848 + return 2;
10849 + }
10850 + } while (0);
10851 +
10852 + do { /* PaX: patched PLT emulation #4 */
10853 + unsigned int sethi, mov1, call, mov2;
10854 +
10855 + err = get_user(sethi, (unsigned int *)regs->tpc);
10856 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10857 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10858 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10859 +
10860 + if (err)
10861 + break;
10862 +
10863 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10864 + mov1 == 0x8210000FU &&
10865 + (call & 0xC0000000U) == 0x40000000U &&
10866 + mov2 == 0x9E100001U)
10867 + {
10868 + unsigned long addr;
10869 +
10870 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10871 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10872 +
10873 + if (test_thread_flag(TIF_32BIT))
10874 + addr &= 0xFFFFFFFFUL;
10875 +
10876 + regs->tpc = addr;
10877 + regs->tnpc = addr+4;
10878 + return 2;
10879 + }
10880 + } while (0);
10881 +
10882 + do { /* PaX: patched PLT emulation #5 */
10883 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10884 +
10885 + err = get_user(sethi, (unsigned int *)regs->tpc);
10886 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10887 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10888 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10889 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10890 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10891 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10892 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10893 +
10894 + if (err)
10895 + break;
10896 +
10897 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10898 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10899 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10900 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10901 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10902 + sllx == 0x83287020U &&
10903 + jmpl == 0x81C04005U &&
10904 + nop == 0x01000000U)
10905 + {
10906 + unsigned long addr;
10907 +
10908 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10909 + regs->u_regs[UREG_G1] <<= 32;
10910 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10911 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10912 + regs->tpc = addr;
10913 + regs->tnpc = addr+4;
10914 + return 2;
10915 + }
10916 + } while (0);
10917 +
10918 + do { /* PaX: patched PLT emulation #6 */
10919 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10920 +
10921 + err = get_user(sethi, (unsigned int *)regs->tpc);
10922 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10923 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10924 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10925 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10926 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10927 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10928 +
10929 + if (err)
10930 + break;
10931 +
10932 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10933 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10934 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10935 + sllx == 0x83287020U &&
10936 + (or & 0xFFFFE000U) == 0x8A116000U &&
10937 + jmpl == 0x81C04005U &&
10938 + nop == 0x01000000U)
10939 + {
10940 + unsigned long addr;
10941 +
10942 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10943 + regs->u_regs[UREG_G1] <<= 32;
10944 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10945 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10946 + regs->tpc = addr;
10947 + regs->tnpc = addr+4;
10948 + return 2;
10949 + }
10950 + } while (0);
10951 +
10952 + do { /* PaX: unpatched PLT emulation step 1 */
10953 + unsigned int sethi, ba, nop;
10954 +
10955 + err = get_user(sethi, (unsigned int *)regs->tpc);
10956 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10957 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10958 +
10959 + if (err)
10960 + break;
10961 +
10962 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10963 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10964 + nop == 0x01000000U)
10965 + {
10966 + unsigned long addr;
10967 + unsigned int save, call;
10968 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10969 +
10970 + if ((ba & 0xFFC00000U) == 0x30800000U)
10971 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10972 + else
10973 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10974 +
10975 + if (test_thread_flag(TIF_32BIT))
10976 + addr &= 0xFFFFFFFFUL;
10977 +
10978 + err = get_user(save, (unsigned int *)addr);
10979 + err |= get_user(call, (unsigned int *)(addr+4));
10980 + err |= get_user(nop, (unsigned int *)(addr+8));
10981 + if (err)
10982 + break;
10983 +
10984 +#ifdef CONFIG_PAX_DLRESOLVE
10985 + if (save == 0x9DE3BFA8U &&
10986 + (call & 0xC0000000U) == 0x40000000U &&
10987 + nop == 0x01000000U)
10988 + {
10989 + struct vm_area_struct *vma;
10990 + unsigned long call_dl_resolve;
10991 +
10992 + down_read(&current->mm->mmap_sem);
10993 + call_dl_resolve = current->mm->call_dl_resolve;
10994 + up_read(&current->mm->mmap_sem);
10995 + if (likely(call_dl_resolve))
10996 + goto emulate;
10997 +
10998 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10999 +
11000 + down_write(&current->mm->mmap_sem);
11001 + if (current->mm->call_dl_resolve) {
11002 + call_dl_resolve = current->mm->call_dl_resolve;
11003 + up_write(&current->mm->mmap_sem);
11004 + if (vma)
11005 + kmem_cache_free(vm_area_cachep, vma);
11006 + goto emulate;
11007 + }
11008 +
11009 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11010 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11011 + up_write(&current->mm->mmap_sem);
11012 + if (vma)
11013 + kmem_cache_free(vm_area_cachep, vma);
11014 + return 1;
11015 + }
11016 +
11017 + if (pax_insert_vma(vma, call_dl_resolve)) {
11018 + up_write(&current->mm->mmap_sem);
11019 + kmem_cache_free(vm_area_cachep, vma);
11020 + return 1;
11021 + }
11022 +
11023 + current->mm->call_dl_resolve = call_dl_resolve;
11024 + up_write(&current->mm->mmap_sem);
11025 +
11026 +emulate:
11027 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11028 + regs->tpc = call_dl_resolve;
11029 + regs->tnpc = addr+4;
11030 + return 3;
11031 + }
11032 +#endif
11033 +
11034 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11035 + if ((save & 0xFFC00000U) == 0x05000000U &&
11036 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11037 + nop == 0x01000000U)
11038 + {
11039 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11040 + regs->u_regs[UREG_G2] = addr + 4;
11041 + addr = (save & 0x003FFFFFU) << 10;
11042 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11043 +
11044 + if (test_thread_flag(TIF_32BIT))
11045 + addr &= 0xFFFFFFFFUL;
11046 +
11047 + regs->tpc = addr;
11048 + regs->tnpc = addr+4;
11049 + return 3;
11050 + }
11051 +
11052 + /* PaX: 64-bit PLT stub */
11053 + err = get_user(sethi1, (unsigned int *)addr);
11054 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11055 + err |= get_user(or1, (unsigned int *)(addr+8));
11056 + err |= get_user(or2, (unsigned int *)(addr+12));
11057 + err |= get_user(sllx, (unsigned int *)(addr+16));
11058 + err |= get_user(add, (unsigned int *)(addr+20));
11059 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11060 + err |= get_user(nop, (unsigned int *)(addr+28));
11061 + if (err)
11062 + break;
11063 +
11064 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11065 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11066 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11067 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11068 + sllx == 0x89293020U &&
11069 + add == 0x8A010005U &&
11070 + jmpl == 0x89C14000U &&
11071 + nop == 0x01000000U)
11072 + {
11073 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11074 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11075 + regs->u_regs[UREG_G4] <<= 32;
11076 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11077 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11078 + regs->u_regs[UREG_G4] = addr + 24;
11079 + addr = regs->u_regs[UREG_G5];
11080 + regs->tpc = addr;
11081 + regs->tnpc = addr+4;
11082 + return 3;
11083 + }
11084 + }
11085 + } while (0);
11086 +
11087 +#ifdef CONFIG_PAX_DLRESOLVE
11088 + do { /* PaX: unpatched PLT emulation step 2 */
11089 + unsigned int save, call, nop;
11090 +
11091 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11092 + err |= get_user(call, (unsigned int *)regs->tpc);
11093 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11094 + if (err)
11095 + break;
11096 +
11097 + if (save == 0x9DE3BFA8U &&
11098 + (call & 0xC0000000U) == 0x40000000U &&
11099 + nop == 0x01000000U)
11100 + {
11101 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11102 +
11103 + if (test_thread_flag(TIF_32BIT))
11104 + dl_resolve &= 0xFFFFFFFFUL;
11105 +
11106 + regs->u_regs[UREG_RETPC] = regs->tpc;
11107 + regs->tpc = dl_resolve;
11108 + regs->tnpc = dl_resolve+4;
11109 + return 3;
11110 + }
11111 + } while (0);
11112 +#endif
11113 +
11114 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11115 + unsigned int sethi, ba, nop;
11116 +
11117 + err = get_user(sethi, (unsigned int *)regs->tpc);
11118 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11119 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11120 +
11121 + if (err)
11122 + break;
11123 +
11124 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11125 + (ba & 0xFFF00000U) == 0x30600000U &&
11126 + nop == 0x01000000U)
11127 + {
11128 + unsigned long addr;
11129 +
11130 + addr = (sethi & 0x003FFFFFU) << 10;
11131 + regs->u_regs[UREG_G1] = addr;
11132 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11133 +
11134 + if (test_thread_flag(TIF_32BIT))
11135 + addr &= 0xFFFFFFFFUL;
11136 +
11137 + regs->tpc = addr;
11138 + regs->tnpc = addr+4;
11139 + return 2;
11140 + }
11141 + } while (0);
11142 +
11143 +#endif
11144 +
11145 + return 1;
11146 +}
11147 +
11148 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11149 +{
11150 + unsigned long i;
11151 +
11152 + printk(KERN_ERR "PAX: bytes at PC: ");
11153 + for (i = 0; i < 8; i++) {
11154 + unsigned int c;
11155 + if (get_user(c, (unsigned int *)pc+i))
11156 + printk(KERN_CONT "???????? ");
11157 + else
11158 + printk(KERN_CONT "%08x ", c);
11159 + }
11160 + printk("\n");
11161 +}
11162 +#endif
11163 +
11164 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11165 {
11166 struct mm_struct *mm = current->mm;
11167 @@ -342,6 +805,29 @@ retry:
11168 if (!vma)
11169 goto bad_area;
11170
11171 +#ifdef CONFIG_PAX_PAGEEXEC
11172 + /* PaX: detect ITLB misses on non-exec pages */
11173 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11174 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11175 + {
11176 + if (address != regs->tpc)
11177 + goto good_area;
11178 +
11179 + up_read(&mm->mmap_sem);
11180 + switch (pax_handle_fetch_fault(regs)) {
11181 +
11182 +#ifdef CONFIG_PAX_EMUPLT
11183 + case 2:
11184 + case 3:
11185 + return;
11186 +#endif
11187 +
11188 + }
11189 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11190 + do_group_exit(SIGKILL);
11191 + }
11192 +#endif
11193 +
11194 /* Pure DTLB misses do not tell us whether the fault causing
11195 * load/store/atomic was a write or not, it only says that there
11196 * was no match. So in such a case we (carefully) read the
11197 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11198 index 9639964..806cd0c 100644
11199 --- a/arch/sparc/mm/hugetlbpage.c
11200 +++ b/arch/sparc/mm/hugetlbpage.c
11201 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11202 unsigned long addr,
11203 unsigned long len,
11204 unsigned long pgoff,
11205 - unsigned long flags)
11206 + unsigned long flags,
11207 + unsigned long offset)
11208 {
11209 unsigned long task_size = TASK_SIZE;
11210 struct vm_unmapped_area_info info;
11211 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11212
11213 info.flags = 0;
11214 info.length = len;
11215 - info.low_limit = TASK_UNMAPPED_BASE;
11216 + info.low_limit = mm->mmap_base;
11217 info.high_limit = min(task_size, VA_EXCLUDE_START);
11218 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11219 info.align_offset = 0;
11220 + info.threadstack_offset = offset;
11221 addr = vm_unmapped_area(&info);
11222
11223 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11224 VM_BUG_ON(addr != -ENOMEM);
11225 info.low_limit = VA_EXCLUDE_END;
11226 +
11227 +#ifdef CONFIG_PAX_RANDMMAP
11228 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11229 + info.low_limit += mm->delta_mmap;
11230 +#endif
11231 +
11232 info.high_limit = task_size;
11233 addr = vm_unmapped_area(&info);
11234 }
11235 @@ -58,7 +66,8 @@ static unsigned long
11236 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11237 const unsigned long len,
11238 const unsigned long pgoff,
11239 - const unsigned long flags)
11240 + const unsigned long flags,
11241 + const unsigned long offset)
11242 {
11243 struct mm_struct *mm = current->mm;
11244 unsigned long addr = addr0;
11245 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11246 info.high_limit = mm->mmap_base;
11247 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11248 info.align_offset = 0;
11249 + info.threadstack_offset = offset;
11250 addr = vm_unmapped_area(&info);
11251
11252 /*
11253 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11254 VM_BUG_ON(addr != -ENOMEM);
11255 info.flags = 0;
11256 info.low_limit = TASK_UNMAPPED_BASE;
11257 +
11258 +#ifdef CONFIG_PAX_RANDMMAP
11259 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11260 + info.low_limit += mm->delta_mmap;
11261 +#endif
11262 +
11263 info.high_limit = STACK_TOP32;
11264 addr = vm_unmapped_area(&info);
11265 }
11266 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11267 struct mm_struct *mm = current->mm;
11268 struct vm_area_struct *vma;
11269 unsigned long task_size = TASK_SIZE;
11270 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11271
11272 if (test_thread_flag(TIF_32BIT))
11273 task_size = STACK_TOP32;
11274 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11275 return addr;
11276 }
11277
11278 +#ifdef CONFIG_PAX_RANDMMAP
11279 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11280 +#endif
11281 +
11282 if (addr) {
11283 addr = ALIGN(addr, HPAGE_SIZE);
11284 vma = find_vma(mm, addr);
11285 - if (task_size - len >= addr &&
11286 - (!vma || addr + len <= vma->vm_start))
11287 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11288 return addr;
11289 }
11290 if (mm->get_unmapped_area == arch_get_unmapped_area)
11291 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11292 - pgoff, flags);
11293 + pgoff, flags, offset);
11294 else
11295 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11296 - pgoff, flags);
11297 + pgoff, flags, offset);
11298 }
11299
11300 pte_t *huge_pte_alloc(struct mm_struct *mm,
11301 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11302 index ed82eda..0d80e77 100644
11303 --- a/arch/sparc/mm/init_64.c
11304 +++ b/arch/sparc/mm/init_64.c
11305 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11306 int num_kernel_image_mappings;
11307
11308 #ifdef CONFIG_DEBUG_DCFLUSH
11309 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11310 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11311 #ifdef CONFIG_SMP
11312 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11313 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11314 #endif
11315 #endif
11316
11317 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11318 {
11319 BUG_ON(tlb_type == hypervisor);
11320 #ifdef CONFIG_DEBUG_DCFLUSH
11321 - atomic_inc(&dcpage_flushes);
11322 + atomic_inc_unchecked(&dcpage_flushes);
11323 #endif
11324
11325 #ifdef DCACHE_ALIASING_POSSIBLE
11326 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11327
11328 #ifdef CONFIG_DEBUG_DCFLUSH
11329 seq_printf(m, "DCPageFlushes\t: %d\n",
11330 - atomic_read(&dcpage_flushes));
11331 + atomic_read_unchecked(&dcpage_flushes));
11332 #ifdef CONFIG_SMP
11333 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11334 - atomic_read(&dcpage_flushes_xcall));
11335 + atomic_read_unchecked(&dcpage_flushes_xcall));
11336 #endif /* CONFIG_SMP */
11337 #endif /* CONFIG_DEBUG_DCFLUSH */
11338 }
11339 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11340 index ad220ee..2f537b3 100644
11341 --- a/arch/tile/include/asm/atomic_64.h
11342 +++ b/arch/tile/include/asm/atomic_64.h
11343 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11344
11345 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11346
11347 +#define atomic64_read_unchecked(v) atomic64_read(v)
11348 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11349 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11350 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11351 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11352 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11353 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11354 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11355 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11356 +
11357 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11358 #define smp_mb__before_atomic_dec() smp_mb()
11359 #define smp_mb__after_atomic_dec() smp_mb()
11360 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11361 index 6160761..00cac88 100644
11362 --- a/arch/tile/include/asm/cache.h
11363 +++ b/arch/tile/include/asm/cache.h
11364 @@ -15,11 +15,12 @@
11365 #ifndef _ASM_TILE_CACHE_H
11366 #define _ASM_TILE_CACHE_H
11367
11368 +#include <linux/const.h>
11369 #include <arch/chip.h>
11370
11371 /* bytes per L1 data cache line */
11372 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11373 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11374 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11375
11376 /* bytes per L2 cache line */
11377 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11378 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11379 index b6cde32..c0cb736 100644
11380 --- a/arch/tile/include/asm/uaccess.h
11381 +++ b/arch/tile/include/asm/uaccess.h
11382 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11383 const void __user *from,
11384 unsigned long n)
11385 {
11386 - int sz = __compiletime_object_size(to);
11387 + size_t sz = __compiletime_object_size(to);
11388
11389 - if (likely(sz == -1 || sz >= n))
11390 + if (likely(sz == (size_t)-1 || sz >= n))
11391 n = _copy_from_user(to, from, n);
11392 else
11393 copy_from_user_overflow();
11394 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11395 index 0cb3bba..7338b2d 100644
11396 --- a/arch/tile/mm/hugetlbpage.c
11397 +++ b/arch/tile/mm/hugetlbpage.c
11398 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11399 info.high_limit = TASK_SIZE;
11400 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11401 info.align_offset = 0;
11402 + info.threadstack_offset = 0;
11403 return vm_unmapped_area(&info);
11404 }
11405
11406 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11407 info.high_limit = current->mm->mmap_base;
11408 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11409 info.align_offset = 0;
11410 + info.threadstack_offset = 0;
11411 addr = vm_unmapped_area(&info);
11412
11413 /*
11414 diff --git a/arch/um/Makefile b/arch/um/Makefile
11415 index 133f7de..1d6f2f1 100644
11416 --- a/arch/um/Makefile
11417 +++ b/arch/um/Makefile
11418 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11419 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11420 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11421
11422 +ifdef CONSTIFY_PLUGIN
11423 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11424 +endif
11425 +
11426 #This will adjust *FLAGS accordingly to the platform.
11427 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11428
11429 diff --git a/arch/um/defconfig b/arch/um/defconfig
11430 index 2665e6b..3e3822b 100644
11431 --- a/arch/um/defconfig
11432 +++ b/arch/um/defconfig
11433 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11434 CONFIG_X86_L1_CACHE_SHIFT=5
11435 CONFIG_X86_XADD=y
11436 CONFIG_X86_PPRO_FENCE=y
11437 -CONFIG_X86_WP_WORKS_OK=y
11438 CONFIG_X86_INVLPG=y
11439 CONFIG_X86_BSWAP=y
11440 CONFIG_X86_POPAD_OK=y
11441 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11442 index 19e1bdd..3665b77 100644
11443 --- a/arch/um/include/asm/cache.h
11444 +++ b/arch/um/include/asm/cache.h
11445 @@ -1,6 +1,7 @@
11446 #ifndef __UM_CACHE_H
11447 #define __UM_CACHE_H
11448
11449 +#include <linux/const.h>
11450
11451 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11452 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11453 @@ -12,6 +13,6 @@
11454 # define L1_CACHE_SHIFT 5
11455 #endif
11456
11457 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11458 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11459
11460 #endif
11461 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11462 index 2e0a6b1..a64d0f5 100644
11463 --- a/arch/um/include/asm/kmap_types.h
11464 +++ b/arch/um/include/asm/kmap_types.h
11465 @@ -8,6 +8,6 @@
11466
11467 /* No more #include "asm/arch/kmap_types.h" ! */
11468
11469 -#define KM_TYPE_NR 14
11470 +#define KM_TYPE_NR 15
11471
11472 #endif
11473 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11474 index 5ff53d9..5850cdf 100644
11475 --- a/arch/um/include/asm/page.h
11476 +++ b/arch/um/include/asm/page.h
11477 @@ -14,6 +14,9 @@
11478 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11479 #define PAGE_MASK (~(PAGE_SIZE-1))
11480
11481 +#define ktla_ktva(addr) (addr)
11482 +#define ktva_ktla(addr) (addr)
11483 +
11484 #ifndef __ASSEMBLY__
11485
11486 struct page;
11487 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11488 index 0032f92..cd151e0 100644
11489 --- a/arch/um/include/asm/pgtable-3level.h
11490 +++ b/arch/um/include/asm/pgtable-3level.h
11491 @@ -58,6 +58,7 @@
11492 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11493 #define pud_populate(mm, pud, pmd) \
11494 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11495 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11496
11497 #ifdef CONFIG_64BIT
11498 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11499 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11500 index bbcef52..6a2a483 100644
11501 --- a/arch/um/kernel/process.c
11502 +++ b/arch/um/kernel/process.c
11503 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11504 return 2;
11505 }
11506
11507 -/*
11508 - * Only x86 and x86_64 have an arch_align_stack().
11509 - * All other arches have "#define arch_align_stack(x) (x)"
11510 - * in their asm/system.h
11511 - * As this is included in UML from asm-um/system-generic.h,
11512 - * we can use it to behave as the subarch does.
11513 - */
11514 -#ifndef arch_align_stack
11515 -unsigned long arch_align_stack(unsigned long sp)
11516 -{
11517 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11518 - sp -= get_random_int() % 8192;
11519 - return sp & ~0xf;
11520 -}
11521 -#endif
11522 -
11523 unsigned long get_wchan(struct task_struct *p)
11524 {
11525 unsigned long stack_page, sp, ip;
11526 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11527 index ad8f795..2c7eec6 100644
11528 --- a/arch/unicore32/include/asm/cache.h
11529 +++ b/arch/unicore32/include/asm/cache.h
11530 @@ -12,8 +12,10 @@
11531 #ifndef __UNICORE_CACHE_H__
11532 #define __UNICORE_CACHE_H__
11533
11534 -#define L1_CACHE_SHIFT (5)
11535 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11536 +#include <linux/const.h>
11537 +
11538 +#define L1_CACHE_SHIFT 5
11539 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11540
11541 /*
11542 * Memory returned by kmalloc() may be used for DMA, so we must make
11543 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11544 index f67e839..419b5f7 100644
11545 --- a/arch/x86/Kconfig
11546 +++ b/arch/x86/Kconfig
11547 @@ -247,7 +247,7 @@ config X86_HT
11548
11549 config X86_32_LAZY_GS
11550 def_bool y
11551 - depends on X86_32 && !CC_STACKPROTECTOR
11552 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11553
11554 config ARCH_HWEIGHT_CFLAGS
11555 string
11556 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11557
11558 config X86_MSR
11559 tristate "/dev/cpu/*/msr - Model-specific register support"
11560 + depends on !GRKERNSEC_KMEM
11561 ---help---
11562 This device gives privileged processes access to the x86
11563 Model-Specific Registers (MSRs). It is a character device with
11564 @@ -1122,7 +1123,7 @@ choice
11565
11566 config NOHIGHMEM
11567 bool "off"
11568 - depends on !X86_NUMAQ
11569 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11570 ---help---
11571 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11572 However, the address space of 32-bit x86 processors is only 4
11573 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11574
11575 config HIGHMEM4G
11576 bool "4GB"
11577 - depends on !X86_NUMAQ
11578 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11579 ---help---
11580 Select this if you have a 32-bit processor and between 1 and 4
11581 gigabytes of physical RAM.
11582 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11583 hex
11584 default 0xB0000000 if VMSPLIT_3G_OPT
11585 default 0x80000000 if VMSPLIT_2G
11586 - default 0x78000000 if VMSPLIT_2G_OPT
11587 + default 0x70000000 if VMSPLIT_2G_OPT
11588 default 0x40000000 if VMSPLIT_1G
11589 default 0xC0000000
11590 depends on X86_32
11591 @@ -1614,6 +1615,7 @@ config SECCOMP
11592
11593 config CC_STACKPROTECTOR
11594 bool "Enable -fstack-protector buffer overflow detection"
11595 + depends on X86_64 || !PAX_MEMORY_UDEREF
11596 ---help---
11597 This option turns on the -fstack-protector GCC feature. This
11598 feature puts, at the beginning of functions, a canary value on
11599 @@ -1733,6 +1735,8 @@ config X86_NEED_RELOCS
11600 config PHYSICAL_ALIGN
11601 hex "Alignment value to which kernel should be aligned"
11602 default "0x1000000"
11603 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11604 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11605 range 0x2000 0x1000000 if X86_32
11606 range 0x200000 0x1000000 if X86_64
11607 ---help---
11608 @@ -1812,9 +1816,10 @@ config DEBUG_HOTPLUG_CPU0
11609 If unsure, say N.
11610
11611 config COMPAT_VDSO
11612 - def_bool y
11613 + def_bool n
11614 prompt "Compat VDSO support"
11615 depends on X86_32 || IA32_EMULATION
11616 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11617 ---help---
11618 Map the 32-bit VDSO to the predictable old-style address too.
11619
11620 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11621 index c026cca..14657ae 100644
11622 --- a/arch/x86/Kconfig.cpu
11623 +++ b/arch/x86/Kconfig.cpu
11624 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11625
11626 config X86_F00F_BUG
11627 def_bool y
11628 - depends on M586MMX || M586TSC || M586 || M486
11629 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11630
11631 config X86_INVD_BUG
11632 def_bool y
11633 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11634
11635 config X86_ALIGNMENT_16
11636 def_bool y
11637 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11638 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11639
11640 config X86_INTEL_USERCOPY
11641 def_bool y
11642 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11643 # generates cmov.
11644 config X86_CMOV
11645 def_bool y
11646 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11647 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11648
11649 config X86_MINIMUM_CPU_FAMILY
11650 int
11651 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11652 index 78d91af..8ceb94b 100644
11653 --- a/arch/x86/Kconfig.debug
11654 +++ b/arch/x86/Kconfig.debug
11655 @@ -74,7 +74,7 @@ config X86_PTDUMP
11656 config DEBUG_RODATA
11657 bool "Write protect kernel read-only data structures"
11658 default y
11659 - depends on DEBUG_KERNEL
11660 + depends on DEBUG_KERNEL && BROKEN
11661 ---help---
11662 Mark the kernel read-only data as write-protected in the pagetables,
11663 in order to catch accidental (and incorrect) writes to such const
11664 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11665
11666 config DEBUG_SET_MODULE_RONX
11667 bool "Set loadable kernel module data as NX and text as RO"
11668 - depends on MODULES
11669 + depends on MODULES && BROKEN
11670 ---help---
11671 This option helps catch unintended modifications to loadable
11672 kernel module's text and read-only data. It also prevents execution
11673 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11674 index 41250fb..863762e 100644
11675 --- a/arch/x86/Makefile
11676 +++ b/arch/x86/Makefile
11677 @@ -46,14 +46,12 @@ ifeq ($(CONFIG_X86_32),y)
11678 # CPU-specific tuning. Anything which can be shared with UML should go here.
11679 include $(srctree)/arch/x86/Makefile_32.cpu
11680 KBUILD_CFLAGS += $(cflags-y)
11681 -
11682 - # temporary until string.h is fixed
11683 - KBUILD_CFLAGS += -ffreestanding
11684 else
11685 BITS := 64
11686 UTS_MACHINE := x86_64
11687 CHECKFLAGS += -D__x86_64__ -m64
11688
11689 + biarch := $(call cc-option,-m64)
11690 KBUILD_AFLAGS += -m64
11691 KBUILD_CFLAGS += -m64
11692
11693 @@ -83,6 +81,9 @@ else
11694 KBUILD_CFLAGS += -maccumulate-outgoing-args
11695 endif
11696
11697 +# temporary until string.h is fixed
11698 +KBUILD_CFLAGS += -ffreestanding
11699 +
11700 ifdef CONFIG_CC_STACKPROTECTOR
11701 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11702 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11703 @@ -241,3 +242,12 @@ define archhelp
11704 echo ' FDINITRD=file initrd for the booted kernel'
11705 echo ' kvmconfig - Enable additional options for guest kernel support'
11706 endef
11707 +
11708 +define OLD_LD
11709 +
11710 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11711 +*** Please upgrade your binutils to 2.18 or newer
11712 +endef
11713 +
11714 +archprepare:
11715 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11716 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11717 index 379814b..add62ce 100644
11718 --- a/arch/x86/boot/Makefile
11719 +++ b/arch/x86/boot/Makefile
11720 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11721 $(call cc-option, -fno-stack-protector) \
11722 $(call cc-option, -mpreferred-stack-boundary=2)
11723 KBUILD_CFLAGS += $(call cc-option, -m32)
11724 +ifdef CONSTIFY_PLUGIN
11725 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11726 +endif
11727 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11728 GCOV_PROFILE := n
11729
11730 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11731 index 878e4b9..20537ab 100644
11732 --- a/arch/x86/boot/bitops.h
11733 +++ b/arch/x86/boot/bitops.h
11734 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11735 u8 v;
11736 const u32 *p = (const u32 *)addr;
11737
11738 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11739 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11740 return v;
11741 }
11742
11743 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11744
11745 static inline void set_bit(int nr, void *addr)
11746 {
11747 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11748 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11749 }
11750
11751 #endif /* BOOT_BITOPS_H */
11752 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11753 index ef72bae..353a184 100644
11754 --- a/arch/x86/boot/boot.h
11755 +++ b/arch/x86/boot/boot.h
11756 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11757 static inline u16 ds(void)
11758 {
11759 u16 seg;
11760 - asm("movw %%ds,%0" : "=rm" (seg));
11761 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11762 return seg;
11763 }
11764
11765 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11766 static inline int memcmp(const void *s1, const void *s2, size_t len)
11767 {
11768 u8 diff;
11769 - asm("repe; cmpsb; setnz %0"
11770 + asm volatile("repe; cmpsb; setnz %0"
11771 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11772 return diff;
11773 }
11774 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11775 index dcd90df..c830d7d 100644
11776 --- a/arch/x86/boot/compressed/Makefile
11777 +++ b/arch/x86/boot/compressed/Makefile
11778 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11779 KBUILD_CFLAGS += $(cflags-y)
11780 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11781 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11782 +ifdef CONSTIFY_PLUGIN
11783 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11784 +endif
11785
11786 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11787 GCOV_PROFILE := n
11788 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11789 index b7388a4..03844ec 100644
11790 --- a/arch/x86/boot/compressed/eboot.c
11791 +++ b/arch/x86/boot/compressed/eboot.c
11792 @@ -150,7 +150,6 @@ again:
11793 *addr = max_addr;
11794 }
11795
11796 -free_pool:
11797 efi_call_phys1(sys_table->boottime->free_pool, map);
11798
11799 fail:
11800 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11801 if (i == map_size / desc_size)
11802 status = EFI_NOT_FOUND;
11803
11804 -free_pool:
11805 efi_call_phys1(sys_table->boottime->free_pool, map);
11806 fail:
11807 return status;
11808 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11809 index a53440e..c3dbf1e 100644
11810 --- a/arch/x86/boot/compressed/efi_stub_32.S
11811 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11812 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11813 * parameter 2, ..., param n. To make things easy, we save the return
11814 * address of efi_call_phys in a global variable.
11815 */
11816 - popl %ecx
11817 - movl %ecx, saved_return_addr(%edx)
11818 - /* get the function pointer into ECX*/
11819 - popl %ecx
11820 - movl %ecx, efi_rt_function_ptr(%edx)
11821 + popl saved_return_addr(%edx)
11822 + popl efi_rt_function_ptr(%edx)
11823
11824 /*
11825 * 3. Call the physical function.
11826 */
11827 - call *%ecx
11828 + call *efi_rt_function_ptr(%edx)
11829
11830 /*
11831 * 4. Balance the stack. And because EAX contain the return value,
11832 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11833 1: popl %edx
11834 subl $1b, %edx
11835
11836 - movl efi_rt_function_ptr(%edx), %ecx
11837 - pushl %ecx
11838 + pushl efi_rt_function_ptr(%edx)
11839
11840 /*
11841 * 10. Push the saved return address onto the stack and return.
11842 */
11843 - movl saved_return_addr(%edx), %ecx
11844 - pushl %ecx
11845 - ret
11846 + jmpl *saved_return_addr(%edx)
11847 ENDPROC(efi_call_phys)
11848 .previous
11849
11850 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11851 index 5d6f689..9d06730 100644
11852 --- a/arch/x86/boot/compressed/head_32.S
11853 +++ b/arch/x86/boot/compressed/head_32.S
11854 @@ -118,7 +118,7 @@ preferred_addr:
11855 notl %eax
11856 andl %eax, %ebx
11857 #else
11858 - movl $LOAD_PHYSICAL_ADDR, %ebx
11859 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11860 #endif
11861
11862 /* Target address to relocate to for decompression */
11863 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11864 index c337422..2c5be72 100644
11865 --- a/arch/x86/boot/compressed/head_64.S
11866 +++ b/arch/x86/boot/compressed/head_64.S
11867 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11868 notl %eax
11869 andl %eax, %ebx
11870 #else
11871 - movl $LOAD_PHYSICAL_ADDR, %ebx
11872 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11873 #endif
11874
11875 /* Target address to relocate to for decompression */
11876 @@ -270,7 +270,7 @@ preferred_addr:
11877 notq %rax
11878 andq %rax, %rbp
11879 #else
11880 - movq $LOAD_PHYSICAL_ADDR, %rbp
11881 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11882 #endif
11883
11884 /* Target address to relocate to for decompression */
11885 @@ -362,8 +362,8 @@ gdt:
11886 .long gdt
11887 .word 0
11888 .quad 0x0000000000000000 /* NULL descriptor */
11889 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11890 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11891 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11892 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11893 .quad 0x0080890000000000 /* TS descriptor */
11894 .quad 0x0000000000000000 /* TS continued */
11895 gdt_end:
11896 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11897 index 434f077..b6b4b38 100644
11898 --- a/arch/x86/boot/compressed/misc.c
11899 +++ b/arch/x86/boot/compressed/misc.c
11900 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
11901 * Calculate the delta between where vmlinux was linked to load
11902 * and where it was actually loaded.
11903 */
11904 - delta = min_addr - LOAD_PHYSICAL_ADDR;
11905 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
11906 if (!delta) {
11907 debug_putstr("No relocation needed... ");
11908 return;
11909 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
11910 case PT_LOAD:
11911 #ifdef CONFIG_RELOCATABLE
11912 dest = output;
11913 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11914 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11915 #else
11916 dest = (void *)(phdr->p_paddr);
11917 #endif
11918 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11919 error("Destination address too large");
11920 #endif
11921 #ifndef CONFIG_RELOCATABLE
11922 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11923 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11924 error("Wrong destination address");
11925 #endif
11926
11927 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11928 index 4d3ff03..e4972ff 100644
11929 --- a/arch/x86/boot/cpucheck.c
11930 +++ b/arch/x86/boot/cpucheck.c
11931 @@ -74,7 +74,7 @@ static int has_fpu(void)
11932 u16 fcw = -1, fsw = -1;
11933 u32 cr0;
11934
11935 - asm("movl %%cr0,%0" : "=r" (cr0));
11936 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11937 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11938 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11939 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11940 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11941 {
11942 u32 f0, f1;
11943
11944 - asm("pushfl ; "
11945 + asm volatile("pushfl ; "
11946 "pushfl ; "
11947 "popl %0 ; "
11948 "movl %0,%1 ; "
11949 @@ -115,7 +115,7 @@ static void get_flags(void)
11950 set_bit(X86_FEATURE_FPU, cpu.flags);
11951
11952 if (has_eflag(X86_EFLAGS_ID)) {
11953 - asm("cpuid"
11954 + asm volatile("cpuid"
11955 : "=a" (max_intel_level),
11956 "=b" (cpu_vendor[0]),
11957 "=d" (cpu_vendor[1]),
11958 @@ -124,7 +124,7 @@ static void get_flags(void)
11959
11960 if (max_intel_level >= 0x00000001 &&
11961 max_intel_level <= 0x0000ffff) {
11962 - asm("cpuid"
11963 + asm volatile("cpuid"
11964 : "=a" (tfms),
11965 "=c" (cpu.flags[4]),
11966 "=d" (cpu.flags[0])
11967 @@ -136,7 +136,7 @@ static void get_flags(void)
11968 cpu.model += ((tfms >> 16) & 0xf) << 4;
11969 }
11970
11971 - asm("cpuid"
11972 + asm volatile("cpuid"
11973 : "=a" (max_amd_level)
11974 : "a" (0x80000000)
11975 : "ebx", "ecx", "edx");
11976 @@ -144,7 +144,7 @@ static void get_flags(void)
11977 if (max_amd_level >= 0x80000001 &&
11978 max_amd_level <= 0x8000ffff) {
11979 u32 eax = 0x80000001;
11980 - asm("cpuid"
11981 + asm volatile("cpuid"
11982 : "+a" (eax),
11983 "=c" (cpu.flags[6]),
11984 "=d" (cpu.flags[1])
11985 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11986 u32 ecx = MSR_K7_HWCR;
11987 u32 eax, edx;
11988
11989 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11990 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11991 eax &= ~(1 << 15);
11992 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11993 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11994
11995 get_flags(); /* Make sure it really did something */
11996 err = check_flags();
11997 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11998 u32 ecx = MSR_VIA_FCR;
11999 u32 eax, edx;
12000
12001 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12002 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12003 eax |= (1<<1)|(1<<7);
12004 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12005 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12006
12007 set_bit(X86_FEATURE_CX8, cpu.flags);
12008 err = check_flags();
12009 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12010 u32 eax, edx;
12011 u32 level = 1;
12012
12013 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12014 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12015 - asm("cpuid"
12016 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12017 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12018 + asm volatile("cpuid"
12019 : "+a" (level), "=d" (cpu.flags[0])
12020 : : "ecx", "ebx");
12021 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12022 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12023
12024 err = check_flags();
12025 }
12026 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12027 index 9ec06a1..2c25e79 100644
12028 --- a/arch/x86/boot/header.S
12029 +++ b/arch/x86/boot/header.S
12030 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12031 # single linked list of
12032 # struct setup_data
12033
12034 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12035 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12036
12037 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12039 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12040 +#else
12041 #define VO_INIT_SIZE (VO__end - VO__text)
12042 +#endif
12043 #if ZO_INIT_SIZE > VO_INIT_SIZE
12044 #define INIT_SIZE ZO_INIT_SIZE
12045 #else
12046 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12047 index db75d07..8e6d0af 100644
12048 --- a/arch/x86/boot/memory.c
12049 +++ b/arch/x86/boot/memory.c
12050 @@ -19,7 +19,7 @@
12051
12052 static int detect_memory_e820(void)
12053 {
12054 - int count = 0;
12055 + unsigned int count = 0;
12056 struct biosregs ireg, oreg;
12057 struct e820entry *desc = boot_params.e820_map;
12058 static struct e820entry buf; /* static so it is zeroed */
12059 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12060 index 11e8c6e..fdbb1ed 100644
12061 --- a/arch/x86/boot/video-vesa.c
12062 +++ b/arch/x86/boot/video-vesa.c
12063 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12064
12065 boot_params.screen_info.vesapm_seg = oreg.es;
12066 boot_params.screen_info.vesapm_off = oreg.di;
12067 + boot_params.screen_info.vesapm_size = oreg.cx;
12068 }
12069
12070 /*
12071 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12072 index 43eda28..5ab5fdb 100644
12073 --- a/arch/x86/boot/video.c
12074 +++ b/arch/x86/boot/video.c
12075 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12076 static unsigned int get_entry(void)
12077 {
12078 char entry_buf[4];
12079 - int i, len = 0;
12080 + unsigned int i, len = 0;
12081 int key;
12082 unsigned int v;
12083
12084 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12085 index 9105655..5e37f27 100644
12086 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12087 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12088 @@ -8,6 +8,8 @@
12089 * including this sentence is retained in full.
12090 */
12091
12092 +#include <asm/alternative-asm.h>
12093 +
12094 .extern crypto_ft_tab
12095 .extern crypto_it_tab
12096 .extern crypto_fl_tab
12097 @@ -70,6 +72,8 @@
12098 je B192; \
12099 leaq 32(r9),r9;
12100
12101 +#define ret pax_force_retaddr 0, 1; ret
12102 +
12103 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12104 movq r1,r2; \
12105 movq r3,r4; \
12106 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12107 index 477e9d7..3ab339f 100644
12108 --- a/arch/x86/crypto/aesni-intel_asm.S
12109 +++ b/arch/x86/crypto/aesni-intel_asm.S
12110 @@ -31,6 +31,7 @@
12111
12112 #include <linux/linkage.h>
12113 #include <asm/inst.h>
12114 +#include <asm/alternative-asm.h>
12115
12116 #ifdef __x86_64__
12117 .data
12118 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12119 pop %r14
12120 pop %r13
12121 pop %r12
12122 + pax_force_retaddr 0, 1
12123 ret
12124 ENDPROC(aesni_gcm_dec)
12125
12126 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12127 pop %r14
12128 pop %r13
12129 pop %r12
12130 + pax_force_retaddr 0, 1
12131 ret
12132 ENDPROC(aesni_gcm_enc)
12133
12134 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12135 pxor %xmm1, %xmm0
12136 movaps %xmm0, (TKEYP)
12137 add $0x10, TKEYP
12138 + pax_force_retaddr_bts
12139 ret
12140 ENDPROC(_key_expansion_128)
12141 ENDPROC(_key_expansion_256a)
12142 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12143 shufps $0b01001110, %xmm2, %xmm1
12144 movaps %xmm1, 0x10(TKEYP)
12145 add $0x20, TKEYP
12146 + pax_force_retaddr_bts
12147 ret
12148 ENDPROC(_key_expansion_192a)
12149
12150 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12151
12152 movaps %xmm0, (TKEYP)
12153 add $0x10, TKEYP
12154 + pax_force_retaddr_bts
12155 ret
12156 ENDPROC(_key_expansion_192b)
12157
12158 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12159 pxor %xmm1, %xmm2
12160 movaps %xmm2, (TKEYP)
12161 add $0x10, TKEYP
12162 + pax_force_retaddr_bts
12163 ret
12164 ENDPROC(_key_expansion_256b)
12165
12166 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12167 #ifndef __x86_64__
12168 popl KEYP
12169 #endif
12170 + pax_force_retaddr 0, 1
12171 ret
12172 ENDPROC(aesni_set_key)
12173
12174 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12175 popl KLEN
12176 popl KEYP
12177 #endif
12178 + pax_force_retaddr 0, 1
12179 ret
12180 ENDPROC(aesni_enc)
12181
12182 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12183 AESENC KEY STATE
12184 movaps 0x70(TKEYP), KEY
12185 AESENCLAST KEY STATE
12186 + pax_force_retaddr_bts
12187 ret
12188 ENDPROC(_aesni_enc1)
12189
12190 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12191 AESENCLAST KEY STATE2
12192 AESENCLAST KEY STATE3
12193 AESENCLAST KEY STATE4
12194 + pax_force_retaddr_bts
12195 ret
12196 ENDPROC(_aesni_enc4)
12197
12198 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12199 popl KLEN
12200 popl KEYP
12201 #endif
12202 + pax_force_retaddr 0, 1
12203 ret
12204 ENDPROC(aesni_dec)
12205
12206 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12207 AESDEC KEY STATE
12208 movaps 0x70(TKEYP), KEY
12209 AESDECLAST KEY STATE
12210 + pax_force_retaddr_bts
12211 ret
12212 ENDPROC(_aesni_dec1)
12213
12214 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12215 AESDECLAST KEY STATE2
12216 AESDECLAST KEY STATE3
12217 AESDECLAST KEY STATE4
12218 + pax_force_retaddr_bts
12219 ret
12220 ENDPROC(_aesni_dec4)
12221
12222 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12223 popl KEYP
12224 popl LEN
12225 #endif
12226 + pax_force_retaddr 0, 1
12227 ret
12228 ENDPROC(aesni_ecb_enc)
12229
12230 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12231 popl KEYP
12232 popl LEN
12233 #endif
12234 + pax_force_retaddr 0, 1
12235 ret
12236 ENDPROC(aesni_ecb_dec)
12237
12238 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12239 popl LEN
12240 popl IVP
12241 #endif
12242 + pax_force_retaddr 0, 1
12243 ret
12244 ENDPROC(aesni_cbc_enc)
12245
12246 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12247 popl LEN
12248 popl IVP
12249 #endif
12250 + pax_force_retaddr 0, 1
12251 ret
12252 ENDPROC(aesni_cbc_dec)
12253
12254 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12255 mov $1, TCTR_LOW
12256 MOVQ_R64_XMM TCTR_LOW INC
12257 MOVQ_R64_XMM CTR TCTR_LOW
12258 + pax_force_retaddr_bts
12259 ret
12260 ENDPROC(_aesni_inc_init)
12261
12262 @@ -2579,6 +2598,7 @@ _aesni_inc:
12263 .Linc_low:
12264 movaps CTR, IV
12265 PSHUFB_XMM BSWAP_MASK IV
12266 + pax_force_retaddr_bts
12267 ret
12268 ENDPROC(_aesni_inc)
12269
12270 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12271 .Lctr_enc_ret:
12272 movups IV, (IVP)
12273 .Lctr_enc_just_ret:
12274 + pax_force_retaddr 0, 1
12275 ret
12276 ENDPROC(aesni_ctr_enc)
12277
12278 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12279 pxor INC, STATE4
12280 movdqu STATE4, 0x70(OUTP)
12281
12282 + pax_force_retaddr 0, 1
12283 ret
12284 ENDPROC(aesni_xts_crypt8)
12285
12286 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12287 index 246c670..4d1ed00 100644
12288 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12289 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12290 @@ -21,6 +21,7 @@
12291 */
12292
12293 #include <linux/linkage.h>
12294 +#include <asm/alternative-asm.h>
12295
12296 .file "blowfish-x86_64-asm.S"
12297 .text
12298 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12299 jnz .L__enc_xor;
12300
12301 write_block();
12302 + pax_force_retaddr 0, 1
12303 ret;
12304 .L__enc_xor:
12305 xor_block();
12306 + pax_force_retaddr 0, 1
12307 ret;
12308 ENDPROC(__blowfish_enc_blk)
12309
12310 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12311
12312 movq %r11, %rbp;
12313
12314 + pax_force_retaddr 0, 1
12315 ret;
12316 ENDPROC(blowfish_dec_blk)
12317
12318 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12319
12320 popq %rbx;
12321 popq %rbp;
12322 + pax_force_retaddr 0, 1
12323 ret;
12324
12325 .L__enc_xor4:
12326 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12327
12328 popq %rbx;
12329 popq %rbp;
12330 + pax_force_retaddr 0, 1
12331 ret;
12332 ENDPROC(__blowfish_enc_blk_4way)
12333
12334 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12335 popq %rbx;
12336 popq %rbp;
12337
12338 + pax_force_retaddr 0, 1
12339 ret;
12340 ENDPROC(blowfish_dec_blk_4way)
12341 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12342 index ce71f92..2dd5b1e 100644
12343 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12344 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12345 @@ -16,6 +16,7 @@
12346 */
12347
12348 #include <linux/linkage.h>
12349 +#include <asm/alternative-asm.h>
12350
12351 #define CAMELLIA_TABLE_BYTE_LEN 272
12352
12353 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12354 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12355 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12356 %rcx, (%r9));
12357 + pax_force_retaddr_bts
12358 ret;
12359 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12360
12361 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12362 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12363 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12364 %rax, (%r9));
12365 + pax_force_retaddr_bts
12366 ret;
12367 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12368
12369 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12370 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12371 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12372
12373 + pax_force_retaddr_bts
12374 ret;
12375
12376 .align 8
12377 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12378 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12379 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12380
12381 + pax_force_retaddr_bts
12382 ret;
12383
12384 .align 8
12385 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12386 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12387 %xmm8, %rsi);
12388
12389 + pax_force_retaddr 0, 1
12390 ret;
12391 ENDPROC(camellia_ecb_enc_16way)
12392
12393 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12394 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12395 %xmm8, %rsi);
12396
12397 + pax_force_retaddr 0, 1
12398 ret;
12399 ENDPROC(camellia_ecb_dec_16way)
12400
12401 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12402 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12403 %xmm8, %rsi);
12404
12405 + pax_force_retaddr 0, 1
12406 ret;
12407 ENDPROC(camellia_cbc_dec_16way)
12408
12409 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12410 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12411 %xmm8, %rsi);
12412
12413 + pax_force_retaddr 0, 1
12414 ret;
12415 ENDPROC(camellia_ctr_16way)
12416
12417 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12418 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12419 %xmm8, %rsi);
12420
12421 + pax_force_retaddr 0, 1
12422 ret;
12423 ENDPROC(camellia_xts_crypt_16way)
12424
12425 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12426 index 0e0b886..8fc756a 100644
12427 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12428 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12429 @@ -11,6 +11,7 @@
12430 */
12431
12432 #include <linux/linkage.h>
12433 +#include <asm/alternative-asm.h>
12434
12435 #define CAMELLIA_TABLE_BYTE_LEN 272
12436
12437 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12438 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12439 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12440 %rcx, (%r9));
12441 + pax_force_retaddr_bts
12442 ret;
12443 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12444
12445 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12446 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12447 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12448 %rax, (%r9));
12449 + pax_force_retaddr_bts
12450 ret;
12451 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12452
12453 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12454 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12455 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12456
12457 + pax_force_retaddr_bts
12458 ret;
12459
12460 .align 8
12461 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12462 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12463 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12464
12465 + pax_force_retaddr_bts
12466 ret;
12467
12468 .align 8
12469 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12470
12471 vzeroupper;
12472
12473 + pax_force_retaddr 0, 1
12474 ret;
12475 ENDPROC(camellia_ecb_enc_32way)
12476
12477 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12478
12479 vzeroupper;
12480
12481 + pax_force_retaddr 0, 1
12482 ret;
12483 ENDPROC(camellia_ecb_dec_32way)
12484
12485 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12486
12487 vzeroupper;
12488
12489 + pax_force_retaddr 0, 1
12490 ret;
12491 ENDPROC(camellia_cbc_dec_32way)
12492
12493 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12494
12495 vzeroupper;
12496
12497 + pax_force_retaddr 0, 1
12498 ret;
12499 ENDPROC(camellia_ctr_32way)
12500
12501 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12502
12503 vzeroupper;
12504
12505 + pax_force_retaddr 0, 1
12506 ret;
12507 ENDPROC(camellia_xts_crypt_32way)
12508
12509 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12510 index 310319c..ce174a4 100644
12511 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12512 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12513 @@ -21,6 +21,7 @@
12514 */
12515
12516 #include <linux/linkage.h>
12517 +#include <asm/alternative-asm.h>
12518
12519 .file "camellia-x86_64-asm_64.S"
12520 .text
12521 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12522 enc_outunpack(mov, RT1);
12523
12524 movq RRBP, %rbp;
12525 + pax_force_retaddr 0, 1
12526 ret;
12527
12528 .L__enc_xor:
12529 enc_outunpack(xor, RT1);
12530
12531 movq RRBP, %rbp;
12532 + pax_force_retaddr 0, 1
12533 ret;
12534 ENDPROC(__camellia_enc_blk)
12535
12536 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12537 dec_outunpack();
12538
12539 movq RRBP, %rbp;
12540 + pax_force_retaddr 0, 1
12541 ret;
12542 ENDPROC(camellia_dec_blk)
12543
12544 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12545
12546 movq RRBP, %rbp;
12547 popq %rbx;
12548 + pax_force_retaddr 0, 1
12549 ret;
12550
12551 .L__enc2_xor:
12552 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12553
12554 movq RRBP, %rbp;
12555 popq %rbx;
12556 + pax_force_retaddr 0, 1
12557 ret;
12558 ENDPROC(__camellia_enc_blk_2way)
12559
12560 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12561
12562 movq RRBP, %rbp;
12563 movq RXOR, %rbx;
12564 + pax_force_retaddr 0, 1
12565 ret;
12566 ENDPROC(camellia_dec_blk_2way)
12567 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12568 index c35fd5d..c1ee236 100644
12569 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12570 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12571 @@ -24,6 +24,7 @@
12572 */
12573
12574 #include <linux/linkage.h>
12575 +#include <asm/alternative-asm.h>
12576
12577 .file "cast5-avx-x86_64-asm_64.S"
12578
12579 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12580 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12581 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12582
12583 + pax_force_retaddr 0, 1
12584 ret;
12585 ENDPROC(__cast5_enc_blk16)
12586
12587 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12588 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12589 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12590
12591 + pax_force_retaddr 0, 1
12592 ret;
12593
12594 .L__skip_dec:
12595 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12596 vmovdqu RR4, (6*4*4)(%r11);
12597 vmovdqu RL4, (7*4*4)(%r11);
12598
12599 + pax_force_retaddr
12600 ret;
12601 ENDPROC(cast5_ecb_enc_16way)
12602
12603 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12604 vmovdqu RR4, (6*4*4)(%r11);
12605 vmovdqu RL4, (7*4*4)(%r11);
12606
12607 + pax_force_retaddr
12608 ret;
12609 ENDPROC(cast5_ecb_dec_16way)
12610
12611 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12612
12613 popq %r12;
12614
12615 + pax_force_retaddr
12616 ret;
12617 ENDPROC(cast5_cbc_dec_16way)
12618
12619 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12620
12621 popq %r12;
12622
12623 + pax_force_retaddr
12624 ret;
12625 ENDPROC(cast5_ctr_16way)
12626 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12627 index e3531f8..18ded3a 100644
12628 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12629 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12630 @@ -24,6 +24,7 @@
12631 */
12632
12633 #include <linux/linkage.h>
12634 +#include <asm/alternative-asm.h>
12635 #include "glue_helper-asm-avx.S"
12636
12637 .file "cast6-avx-x86_64-asm_64.S"
12638 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12639 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12640 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12641
12642 + pax_force_retaddr 0, 1
12643 ret;
12644 ENDPROC(__cast6_enc_blk8)
12645
12646 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12647 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12648 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12649
12650 + pax_force_retaddr 0, 1
12651 ret;
12652 ENDPROC(__cast6_dec_blk8)
12653
12654 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12655
12656 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12657
12658 + pax_force_retaddr
12659 ret;
12660 ENDPROC(cast6_ecb_enc_8way)
12661
12662 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12663
12664 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12665
12666 + pax_force_retaddr
12667 ret;
12668 ENDPROC(cast6_ecb_dec_8way)
12669
12670 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12671
12672 popq %r12;
12673
12674 + pax_force_retaddr
12675 ret;
12676 ENDPROC(cast6_cbc_dec_8way)
12677
12678 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12679
12680 popq %r12;
12681
12682 + pax_force_retaddr
12683 ret;
12684 ENDPROC(cast6_ctr_8way)
12685
12686 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12687 /* dst <= regs xor IVs(in dst) */
12688 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12689
12690 + pax_force_retaddr
12691 ret;
12692 ENDPROC(cast6_xts_enc_8way)
12693
12694 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12695 /* dst <= regs xor IVs(in dst) */
12696 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12697
12698 + pax_force_retaddr
12699 ret;
12700 ENDPROC(cast6_xts_dec_8way)
12701 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12702 index dbc4339..3d868c5 100644
12703 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12704 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12705 @@ -45,6 +45,7 @@
12706
12707 #include <asm/inst.h>
12708 #include <linux/linkage.h>
12709 +#include <asm/alternative-asm.h>
12710
12711 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12712
12713 @@ -312,6 +313,7 @@ do_return:
12714 popq %rsi
12715 popq %rdi
12716 popq %rbx
12717 + pax_force_retaddr 0, 1
12718 ret
12719
12720 ################################################################
12721 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12722 index 586f41a..d02851e 100644
12723 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12724 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12725 @@ -18,6 +18,7 @@
12726
12727 #include <linux/linkage.h>
12728 #include <asm/inst.h>
12729 +#include <asm/alternative-asm.h>
12730
12731 .data
12732
12733 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12734 psrlq $1, T2
12735 pxor T2, T1
12736 pxor T1, DATA
12737 + pax_force_retaddr
12738 ret
12739 ENDPROC(__clmul_gf128mul_ble)
12740
12741 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12742 call __clmul_gf128mul_ble
12743 PSHUFB_XMM BSWAP DATA
12744 movups DATA, (%rdi)
12745 + pax_force_retaddr
12746 ret
12747 ENDPROC(clmul_ghash_mul)
12748
12749 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12750 PSHUFB_XMM BSWAP DATA
12751 movups DATA, (%rdi)
12752 .Lupdate_just_ret:
12753 + pax_force_retaddr
12754 ret
12755 ENDPROC(clmul_ghash_update)
12756
12757 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12758 pand .Lpoly, %xmm1
12759 pxor %xmm1, %xmm0
12760 movups %xmm0, (%rdi)
12761 + pax_force_retaddr
12762 ret
12763 ENDPROC(clmul_ghash_setkey)
12764 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12765 index 9279e0b..9270820 100644
12766 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12767 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12768 @@ -1,4 +1,5 @@
12769 #include <linux/linkage.h>
12770 +#include <asm/alternative-asm.h>
12771
12772 # enter salsa20_encrypt_bytes
12773 ENTRY(salsa20_encrypt_bytes)
12774 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12775 add %r11,%rsp
12776 mov %rdi,%rax
12777 mov %rsi,%rdx
12778 + pax_force_retaddr 0, 1
12779 ret
12780 # bytesatleast65:
12781 ._bytesatleast65:
12782 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12783 add %r11,%rsp
12784 mov %rdi,%rax
12785 mov %rsi,%rdx
12786 + pax_force_retaddr
12787 ret
12788 ENDPROC(salsa20_keysetup)
12789
12790 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12791 add %r11,%rsp
12792 mov %rdi,%rax
12793 mov %rsi,%rdx
12794 + pax_force_retaddr
12795 ret
12796 ENDPROC(salsa20_ivsetup)
12797 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12798 index 2f202f4..d9164d6 100644
12799 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12800 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12801 @@ -24,6 +24,7 @@
12802 */
12803
12804 #include <linux/linkage.h>
12805 +#include <asm/alternative-asm.h>
12806 #include "glue_helper-asm-avx.S"
12807
12808 .file "serpent-avx-x86_64-asm_64.S"
12809 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12810 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12811 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12812
12813 + pax_force_retaddr
12814 ret;
12815 ENDPROC(__serpent_enc_blk8_avx)
12816
12817 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12818 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12819 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12820
12821 + pax_force_retaddr
12822 ret;
12823 ENDPROC(__serpent_dec_blk8_avx)
12824
12825 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12826
12827 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12828
12829 + pax_force_retaddr
12830 ret;
12831 ENDPROC(serpent_ecb_enc_8way_avx)
12832
12833 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12834
12835 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12836
12837 + pax_force_retaddr
12838 ret;
12839 ENDPROC(serpent_ecb_dec_8way_avx)
12840
12841 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12842
12843 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12844
12845 + pax_force_retaddr
12846 ret;
12847 ENDPROC(serpent_cbc_dec_8way_avx)
12848
12849 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12850
12851 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12852
12853 + pax_force_retaddr
12854 ret;
12855 ENDPROC(serpent_ctr_8way_avx)
12856
12857 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12858 /* dst <= regs xor IVs(in dst) */
12859 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12860
12861 + pax_force_retaddr
12862 ret;
12863 ENDPROC(serpent_xts_enc_8way_avx)
12864
12865 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12866 /* dst <= regs xor IVs(in dst) */
12867 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12868
12869 + pax_force_retaddr
12870 ret;
12871 ENDPROC(serpent_xts_dec_8way_avx)
12872 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12873 index b222085..abd483c 100644
12874 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12875 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12876 @@ -15,6 +15,7 @@
12877 */
12878
12879 #include <linux/linkage.h>
12880 +#include <asm/alternative-asm.h>
12881 #include "glue_helper-asm-avx2.S"
12882
12883 .file "serpent-avx2-asm_64.S"
12884 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12885 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12886 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12887
12888 + pax_force_retaddr
12889 ret;
12890 ENDPROC(__serpent_enc_blk16)
12891
12892 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12893 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12894 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12895
12896 + pax_force_retaddr
12897 ret;
12898 ENDPROC(__serpent_dec_blk16)
12899
12900 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12901
12902 vzeroupper;
12903
12904 + pax_force_retaddr
12905 ret;
12906 ENDPROC(serpent_ecb_enc_16way)
12907
12908 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12909
12910 vzeroupper;
12911
12912 + pax_force_retaddr
12913 ret;
12914 ENDPROC(serpent_ecb_dec_16way)
12915
12916 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12917
12918 vzeroupper;
12919
12920 + pax_force_retaddr
12921 ret;
12922 ENDPROC(serpent_cbc_dec_16way)
12923
12924 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12925
12926 vzeroupper;
12927
12928 + pax_force_retaddr
12929 ret;
12930 ENDPROC(serpent_ctr_16way)
12931
12932 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12933
12934 vzeroupper;
12935
12936 + pax_force_retaddr
12937 ret;
12938 ENDPROC(serpent_xts_enc_16way)
12939
12940 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12941
12942 vzeroupper;
12943
12944 + pax_force_retaddr
12945 ret;
12946 ENDPROC(serpent_xts_dec_16way)
12947 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12948 index acc066c..1559cc4 100644
12949 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12950 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12951 @@ -25,6 +25,7 @@
12952 */
12953
12954 #include <linux/linkage.h>
12955 +#include <asm/alternative-asm.h>
12956
12957 .file "serpent-sse2-x86_64-asm_64.S"
12958 .text
12959 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12960 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12961 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12962
12963 + pax_force_retaddr
12964 ret;
12965
12966 .L__enc_xor8:
12967 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12968 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12969
12970 + pax_force_retaddr
12971 ret;
12972 ENDPROC(__serpent_enc_blk_8way)
12973
12974 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12975 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12976 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12977
12978 + pax_force_retaddr
12979 ret;
12980 ENDPROC(serpent_dec_blk_8way)
12981 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12982 index a410950..3356d42 100644
12983 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12984 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12985 @@ -29,6 +29,7 @@
12986 */
12987
12988 #include <linux/linkage.h>
12989 +#include <asm/alternative-asm.h>
12990
12991 #define CTX %rdi // arg1
12992 #define BUF %rsi // arg2
12993 @@ -104,6 +105,7 @@
12994 pop %r12
12995 pop %rbp
12996 pop %rbx
12997 + pax_force_retaddr 0, 1
12998 ret
12999
13000 ENDPROC(\name)
13001 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13002 index 642f156..4ab07b9 100644
13003 --- a/arch/x86/crypto/sha256-avx-asm.S
13004 +++ b/arch/x86/crypto/sha256-avx-asm.S
13005 @@ -49,6 +49,7 @@
13006
13007 #ifdef CONFIG_AS_AVX
13008 #include <linux/linkage.h>
13009 +#include <asm/alternative-asm.h>
13010
13011 ## assume buffers not aligned
13012 #define VMOVDQ vmovdqu
13013 @@ -460,6 +461,7 @@ done_hash:
13014 popq %r13
13015 popq %rbp
13016 popq %rbx
13017 + pax_force_retaddr 0, 1
13018 ret
13019 ENDPROC(sha256_transform_avx)
13020
13021 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13022 index 9e86944..2e7f95a 100644
13023 --- a/arch/x86/crypto/sha256-avx2-asm.S
13024 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13025 @@ -50,6 +50,7 @@
13026
13027 #ifdef CONFIG_AS_AVX2
13028 #include <linux/linkage.h>
13029 +#include <asm/alternative-asm.h>
13030
13031 ## assume buffers not aligned
13032 #define VMOVDQ vmovdqu
13033 @@ -720,6 +721,7 @@ done_hash:
13034 popq %r12
13035 popq %rbp
13036 popq %rbx
13037 + pax_force_retaddr 0, 1
13038 ret
13039 ENDPROC(sha256_transform_rorx)
13040
13041 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13042 index f833b74..c36ed14 100644
13043 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13044 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13045 @@ -47,6 +47,7 @@
13046 ########################################################################
13047
13048 #include <linux/linkage.h>
13049 +#include <asm/alternative-asm.h>
13050
13051 ## assume buffers not aligned
13052 #define MOVDQ movdqu
13053 @@ -471,6 +472,7 @@ done_hash:
13054 popq %rbp
13055 popq %rbx
13056
13057 + pax_force_retaddr 0, 1
13058 ret
13059 ENDPROC(sha256_transform_ssse3)
13060
13061 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13062 index 974dde9..4533d34 100644
13063 --- a/arch/x86/crypto/sha512-avx-asm.S
13064 +++ b/arch/x86/crypto/sha512-avx-asm.S
13065 @@ -49,6 +49,7 @@
13066
13067 #ifdef CONFIG_AS_AVX
13068 #include <linux/linkage.h>
13069 +#include <asm/alternative-asm.h>
13070
13071 .text
13072
13073 @@ -364,6 +365,7 @@ updateblock:
13074 mov frame_RSPSAVE(%rsp), %rsp
13075
13076 nowork:
13077 + pax_force_retaddr 0, 1
13078 ret
13079 ENDPROC(sha512_transform_avx)
13080
13081 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13082 index 568b961..061ef1d 100644
13083 --- a/arch/x86/crypto/sha512-avx2-asm.S
13084 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13085 @@ -51,6 +51,7 @@
13086
13087 #ifdef CONFIG_AS_AVX2
13088 #include <linux/linkage.h>
13089 +#include <asm/alternative-asm.h>
13090
13091 .text
13092
13093 @@ -678,6 +679,7 @@ done_hash:
13094
13095 # Restore Stack Pointer
13096 mov frame_RSPSAVE(%rsp), %rsp
13097 + pax_force_retaddr 0, 1
13098 ret
13099 ENDPROC(sha512_transform_rorx)
13100
13101 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13102 index fb56855..e23914f 100644
13103 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13104 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13105 @@ -48,6 +48,7 @@
13106 ########################################################################
13107
13108 #include <linux/linkage.h>
13109 +#include <asm/alternative-asm.h>
13110
13111 .text
13112
13113 @@ -363,6 +364,7 @@ updateblock:
13114 mov frame_RSPSAVE(%rsp), %rsp
13115
13116 nowork:
13117 + pax_force_retaddr 0, 1
13118 ret
13119 ENDPROC(sha512_transform_ssse3)
13120
13121 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13122 index 0505813..63b1d00 100644
13123 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13124 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13125 @@ -24,6 +24,7 @@
13126 */
13127
13128 #include <linux/linkage.h>
13129 +#include <asm/alternative-asm.h>
13130 #include "glue_helper-asm-avx.S"
13131
13132 .file "twofish-avx-x86_64-asm_64.S"
13133 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13134 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13135 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13136
13137 + pax_force_retaddr 0, 1
13138 ret;
13139 ENDPROC(__twofish_enc_blk8)
13140
13141 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13142 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13143 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13144
13145 + pax_force_retaddr 0, 1
13146 ret;
13147 ENDPROC(__twofish_dec_blk8)
13148
13149 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13150
13151 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13152
13153 + pax_force_retaddr 0, 1
13154 ret;
13155 ENDPROC(twofish_ecb_enc_8way)
13156
13157 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13158
13159 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13160
13161 + pax_force_retaddr 0, 1
13162 ret;
13163 ENDPROC(twofish_ecb_dec_8way)
13164
13165 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13166
13167 popq %r12;
13168
13169 + pax_force_retaddr 0, 1
13170 ret;
13171 ENDPROC(twofish_cbc_dec_8way)
13172
13173 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13174
13175 popq %r12;
13176
13177 + pax_force_retaddr 0, 1
13178 ret;
13179 ENDPROC(twofish_ctr_8way)
13180
13181 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13182 /* dst <= regs xor IVs(in dst) */
13183 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13184
13185 + pax_force_retaddr 0, 1
13186 ret;
13187 ENDPROC(twofish_xts_enc_8way)
13188
13189 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13190 /* dst <= regs xor IVs(in dst) */
13191 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13192
13193 + pax_force_retaddr 0, 1
13194 ret;
13195 ENDPROC(twofish_xts_dec_8way)
13196 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13197 index 1c3b7ce..b365c5e 100644
13198 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13199 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13200 @@ -21,6 +21,7 @@
13201 */
13202
13203 #include <linux/linkage.h>
13204 +#include <asm/alternative-asm.h>
13205
13206 .file "twofish-x86_64-asm-3way.S"
13207 .text
13208 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13209 popq %r13;
13210 popq %r14;
13211 popq %r15;
13212 + pax_force_retaddr 0, 1
13213 ret;
13214
13215 .L__enc_xor3:
13216 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13217 popq %r13;
13218 popq %r14;
13219 popq %r15;
13220 + pax_force_retaddr 0, 1
13221 ret;
13222 ENDPROC(__twofish_enc_blk_3way)
13223
13224 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13225 popq %r13;
13226 popq %r14;
13227 popq %r15;
13228 + pax_force_retaddr 0, 1
13229 ret;
13230 ENDPROC(twofish_dec_blk_3way)
13231 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13232 index a039d21..29e7615 100644
13233 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13234 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13235 @@ -22,6 +22,7 @@
13236
13237 #include <linux/linkage.h>
13238 #include <asm/asm-offsets.h>
13239 +#include <asm/alternative-asm.h>
13240
13241 #define a_offset 0
13242 #define b_offset 4
13243 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13244
13245 popq R1
13246 movq $1,%rax
13247 + pax_force_retaddr 0, 1
13248 ret
13249 ENDPROC(twofish_enc_blk)
13250
13251 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13252
13253 popq R1
13254 movq $1,%rax
13255 + pax_force_retaddr 0, 1
13256 ret
13257 ENDPROC(twofish_dec_blk)
13258 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13259 index bae3aba..c1788c1 100644
13260 --- a/arch/x86/ia32/ia32_aout.c
13261 +++ b/arch/x86/ia32/ia32_aout.c
13262 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13263 unsigned long dump_start, dump_size;
13264 struct user32 dump;
13265
13266 + memset(&dump, 0, sizeof(dump));
13267 +
13268 fs = get_fs();
13269 set_fs(KERNEL_DS);
13270 has_dumped = 1;
13271 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13272 index 665a730..8e7a67a 100644
13273 --- a/arch/x86/ia32/ia32_signal.c
13274 +++ b/arch/x86/ia32/ia32_signal.c
13275 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13276 sp -= frame_size;
13277 /* Align the stack pointer according to the i386 ABI,
13278 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13279 - sp = ((sp + 4) & -16ul) - 4;
13280 + sp = ((sp - 12) & -16ul) - 4;
13281 return (void __user *) sp;
13282 }
13283
13284 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13285 * These are actually not used anymore, but left because some
13286 * gdb versions depend on them as a marker.
13287 */
13288 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13289 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13290 } put_user_catch(err);
13291
13292 if (err)
13293 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13294 0xb8,
13295 __NR_ia32_rt_sigreturn,
13296 0x80cd,
13297 - 0,
13298 + 0
13299 };
13300
13301 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13302 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13303
13304 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13305 restorer = ksig->ka.sa.sa_restorer;
13306 + else if (current->mm->context.vdso)
13307 + /* Return stub is in 32bit vsyscall page */
13308 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13309 else
13310 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13311 - rt_sigreturn);
13312 + restorer = &frame->retcode;
13313 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13314
13315 /*
13316 * Not actually used anymore, but left because some gdb
13317 * versions need it.
13318 */
13319 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13320 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13321 } put_user_catch(err);
13322
13323 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13324 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13325 index 4299eb0..904b82a 100644
13326 --- a/arch/x86/ia32/ia32entry.S
13327 +++ b/arch/x86/ia32/ia32entry.S
13328 @@ -15,8 +15,10 @@
13329 #include <asm/irqflags.h>
13330 #include <asm/asm.h>
13331 #include <asm/smap.h>
13332 +#include <asm/pgtable.h>
13333 #include <linux/linkage.h>
13334 #include <linux/err.h>
13335 +#include <asm/alternative-asm.h>
13336
13337 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13338 #include <linux/elf-em.h>
13339 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13340 ENDPROC(native_irq_enable_sysexit)
13341 #endif
13342
13343 + .macro pax_enter_kernel_user
13344 + pax_set_fptr_mask
13345 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13346 + call pax_enter_kernel_user
13347 +#endif
13348 + .endm
13349 +
13350 + .macro pax_exit_kernel_user
13351 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13352 + call pax_exit_kernel_user
13353 +#endif
13354 +#ifdef CONFIG_PAX_RANDKSTACK
13355 + pushq %rax
13356 + pushq %r11
13357 + call pax_randomize_kstack
13358 + popq %r11
13359 + popq %rax
13360 +#endif
13361 + .endm
13362 +
13363 + .macro pax_erase_kstack
13364 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13365 + call pax_erase_kstack
13366 +#endif
13367 + .endm
13368 +
13369 /*
13370 * 32bit SYSENTER instruction entry.
13371 *
13372 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13373 CFI_REGISTER rsp,rbp
13374 SWAPGS_UNSAFE_STACK
13375 movq PER_CPU_VAR(kernel_stack), %rsp
13376 - addq $(KERNEL_STACK_OFFSET),%rsp
13377 - /*
13378 - * No need to follow this irqs on/off section: the syscall
13379 - * disabled irqs, here we enable it straight after entry:
13380 - */
13381 - ENABLE_INTERRUPTS(CLBR_NONE)
13382 movl %ebp,%ebp /* zero extension */
13383 pushq_cfi $__USER32_DS
13384 /*CFI_REL_OFFSET ss,0*/
13385 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13386 CFI_REL_OFFSET rsp,0
13387 pushfq_cfi
13388 /*CFI_REL_OFFSET rflags,0*/
13389 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13390 - CFI_REGISTER rip,r10
13391 + orl $X86_EFLAGS_IF,(%rsp)
13392 + GET_THREAD_INFO(%r11)
13393 + movl TI_sysenter_return(%r11), %r11d
13394 + CFI_REGISTER rip,r11
13395 pushq_cfi $__USER32_CS
13396 /*CFI_REL_OFFSET cs,0*/
13397 movl %eax, %eax
13398 - pushq_cfi %r10
13399 + pushq_cfi %r11
13400 CFI_REL_OFFSET rip,0
13401 pushq_cfi %rax
13402 cld
13403 SAVE_ARGS 0,1,0
13404 + pax_enter_kernel_user
13405 +
13406 +#ifdef CONFIG_PAX_RANDKSTACK
13407 + pax_erase_kstack
13408 +#endif
13409 +
13410 + /*
13411 + * No need to follow this irqs on/off section: the syscall
13412 + * disabled irqs, here we enable it straight after entry:
13413 + */
13414 + ENABLE_INTERRUPTS(CLBR_NONE)
13415 /* no need to do an access_ok check here because rbp has been
13416 32bit zero extended */
13417 +
13418 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13419 + addq pax_user_shadow_base,%rbp
13420 + ASM_PAX_OPEN_USERLAND
13421 +#endif
13422 +
13423 ASM_STAC
13424 1: movl (%rbp),%ebp
13425 _ASM_EXTABLE(1b,ia32_badarg)
13426 ASM_CLAC
13427 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13428 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13429 +
13430 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13431 + ASM_PAX_CLOSE_USERLAND
13432 +#endif
13433 +
13434 + GET_THREAD_INFO(%r11)
13435 + orl $TS_COMPAT,TI_status(%r11)
13436 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13437 CFI_REMEMBER_STATE
13438 jnz sysenter_tracesys
13439 cmpq $(IA32_NR_syscalls-1),%rax
13440 @@ -162,12 +209,15 @@ sysenter_do_call:
13441 sysenter_dispatch:
13442 call *ia32_sys_call_table(,%rax,8)
13443 movq %rax,RAX-ARGOFFSET(%rsp)
13444 + GET_THREAD_INFO(%r11)
13445 DISABLE_INTERRUPTS(CLBR_NONE)
13446 TRACE_IRQS_OFF
13447 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13448 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13449 jnz sysexit_audit
13450 sysexit_from_sys_call:
13451 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13452 + pax_exit_kernel_user
13453 + pax_erase_kstack
13454 + andl $~TS_COMPAT,TI_status(%r11)
13455 /* clear IF, that popfq doesn't enable interrupts early */
13456 andl $~0x200,EFLAGS-R11(%rsp)
13457 movl RIP-R11(%rsp),%edx /* User %eip */
13458 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13459 movl %eax,%esi /* 2nd arg: syscall number */
13460 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13461 call __audit_syscall_entry
13462 +
13463 + pax_erase_kstack
13464 +
13465 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13466 cmpq $(IA32_NR_syscalls-1),%rax
13467 ja ia32_badsys
13468 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13469 .endm
13470
13471 .macro auditsys_exit exit
13472 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13473 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13474 jnz ia32_ret_from_sys_call
13475 TRACE_IRQS_ON
13476 ENABLE_INTERRUPTS(CLBR_NONE)
13477 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13478 1: setbe %al /* 1 if error, 0 if not */
13479 movzbl %al,%edi /* zero-extend that into %edi */
13480 call __audit_syscall_exit
13481 + GET_THREAD_INFO(%r11)
13482 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13483 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13484 DISABLE_INTERRUPTS(CLBR_NONE)
13485 TRACE_IRQS_OFF
13486 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13487 + testl %edi,TI_flags(%r11)
13488 jz \exit
13489 CLEAR_RREGS -ARGOFFSET
13490 jmp int_with_check
13491 @@ -237,7 +291,7 @@ sysexit_audit:
13492
13493 sysenter_tracesys:
13494 #ifdef CONFIG_AUDITSYSCALL
13495 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13496 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13497 jz sysenter_auditsys
13498 #endif
13499 SAVE_REST
13500 @@ -249,6 +303,9 @@ sysenter_tracesys:
13501 RESTORE_REST
13502 cmpq $(IA32_NR_syscalls-1),%rax
13503 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13504 +
13505 + pax_erase_kstack
13506 +
13507 jmp sysenter_do_call
13508 CFI_ENDPROC
13509 ENDPROC(ia32_sysenter_target)
13510 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13511 ENTRY(ia32_cstar_target)
13512 CFI_STARTPROC32 simple
13513 CFI_SIGNAL_FRAME
13514 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13515 + CFI_DEF_CFA rsp,0
13516 CFI_REGISTER rip,rcx
13517 /*CFI_REGISTER rflags,r11*/
13518 SWAPGS_UNSAFE_STACK
13519 movl %esp,%r8d
13520 CFI_REGISTER rsp,r8
13521 movq PER_CPU_VAR(kernel_stack),%rsp
13522 + SAVE_ARGS 8*6,0,0
13523 + pax_enter_kernel_user
13524 +
13525 +#ifdef CONFIG_PAX_RANDKSTACK
13526 + pax_erase_kstack
13527 +#endif
13528 +
13529 /*
13530 * No need to follow this irqs on/off section: the syscall
13531 * disabled irqs and here we enable it straight after entry:
13532 */
13533 ENABLE_INTERRUPTS(CLBR_NONE)
13534 - SAVE_ARGS 8,0,0
13535 movl %eax,%eax /* zero extension */
13536 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13537 movq %rcx,RIP-ARGOFFSET(%rsp)
13538 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13539 /* no need to do an access_ok check here because r8 has been
13540 32bit zero extended */
13541 /* hardware stack frame is complete now */
13542 +
13543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13544 + ASM_PAX_OPEN_USERLAND
13545 + movq pax_user_shadow_base,%r8
13546 + addq RSP-ARGOFFSET(%rsp),%r8
13547 +#endif
13548 +
13549 ASM_STAC
13550 1: movl (%r8),%r9d
13551 _ASM_EXTABLE(1b,ia32_badarg)
13552 ASM_CLAC
13553 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13554 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13555 +
13556 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13557 + ASM_PAX_CLOSE_USERLAND
13558 +#endif
13559 +
13560 + GET_THREAD_INFO(%r11)
13561 + orl $TS_COMPAT,TI_status(%r11)
13562 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13563 CFI_REMEMBER_STATE
13564 jnz cstar_tracesys
13565 cmpq $IA32_NR_syscalls-1,%rax
13566 @@ -319,12 +395,15 @@ cstar_do_call:
13567 cstar_dispatch:
13568 call *ia32_sys_call_table(,%rax,8)
13569 movq %rax,RAX-ARGOFFSET(%rsp)
13570 + GET_THREAD_INFO(%r11)
13571 DISABLE_INTERRUPTS(CLBR_NONE)
13572 TRACE_IRQS_OFF
13573 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13574 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13575 jnz sysretl_audit
13576 sysretl_from_sys_call:
13577 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13578 + pax_exit_kernel_user
13579 + pax_erase_kstack
13580 + andl $~TS_COMPAT,TI_status(%r11)
13581 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13582 movl RIP-ARGOFFSET(%rsp),%ecx
13583 CFI_REGISTER rip,rcx
13584 @@ -352,7 +431,7 @@ sysretl_audit:
13585
13586 cstar_tracesys:
13587 #ifdef CONFIG_AUDITSYSCALL
13588 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13589 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13590 jz cstar_auditsys
13591 #endif
13592 xchgl %r9d,%ebp
13593 @@ -366,11 +445,19 @@ cstar_tracesys:
13594 xchgl %ebp,%r9d
13595 cmpq $(IA32_NR_syscalls-1),%rax
13596 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13597 +
13598 + pax_erase_kstack
13599 +
13600 jmp cstar_do_call
13601 END(ia32_cstar_target)
13602
13603 ia32_badarg:
13604 ASM_CLAC
13605 +
13606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13607 + ASM_PAX_CLOSE_USERLAND
13608 +#endif
13609 +
13610 movq $-EFAULT,%rax
13611 jmp ia32_sysret
13612 CFI_ENDPROC
13613 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13614 CFI_REL_OFFSET rip,RIP-RIP
13615 PARAVIRT_ADJUST_EXCEPTION_FRAME
13616 SWAPGS
13617 - /*
13618 - * No need to follow this irqs on/off section: the syscall
13619 - * disabled irqs and here we enable it straight after entry:
13620 - */
13621 - ENABLE_INTERRUPTS(CLBR_NONE)
13622 movl %eax,%eax
13623 pushq_cfi %rax
13624 cld
13625 /* note the registers are not zero extended to the sf.
13626 this could be a problem. */
13627 SAVE_ARGS 0,1,0
13628 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13629 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13630 + pax_enter_kernel_user
13631 +
13632 +#ifdef CONFIG_PAX_RANDKSTACK
13633 + pax_erase_kstack
13634 +#endif
13635 +
13636 + /*
13637 + * No need to follow this irqs on/off section: the syscall
13638 + * disabled irqs and here we enable it straight after entry:
13639 + */
13640 + ENABLE_INTERRUPTS(CLBR_NONE)
13641 + GET_THREAD_INFO(%r11)
13642 + orl $TS_COMPAT,TI_status(%r11)
13643 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13644 jnz ia32_tracesys
13645 cmpq $(IA32_NR_syscalls-1),%rax
13646 ja ia32_badsys
13647 @@ -442,6 +536,9 @@ ia32_tracesys:
13648 RESTORE_REST
13649 cmpq $(IA32_NR_syscalls-1),%rax
13650 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13651 +
13652 + pax_erase_kstack
13653 +
13654 jmp ia32_do_call
13655 END(ia32_syscall)
13656
13657 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13658 index 8e0ceec..af13504 100644
13659 --- a/arch/x86/ia32/sys_ia32.c
13660 +++ b/arch/x86/ia32/sys_ia32.c
13661 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13662 */
13663 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13664 {
13665 - typeof(ubuf->st_uid) uid = 0;
13666 - typeof(ubuf->st_gid) gid = 0;
13667 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13668 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13669 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13670 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13671 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13672 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13673 index 372231c..a5aa1a1 100644
13674 --- a/arch/x86/include/asm/alternative-asm.h
13675 +++ b/arch/x86/include/asm/alternative-asm.h
13676 @@ -18,6 +18,45 @@
13677 .endm
13678 #endif
13679
13680 +#ifdef KERNEXEC_PLUGIN
13681 + .macro pax_force_retaddr_bts rip=0
13682 + btsq $63,\rip(%rsp)
13683 + .endm
13684 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13685 + .macro pax_force_retaddr rip=0, reload=0
13686 + btsq $63,\rip(%rsp)
13687 + .endm
13688 + .macro pax_force_fptr ptr
13689 + btsq $63,\ptr
13690 + .endm
13691 + .macro pax_set_fptr_mask
13692 + .endm
13693 +#endif
13694 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13695 + .macro pax_force_retaddr rip=0, reload=0
13696 + .if \reload
13697 + pax_set_fptr_mask
13698 + .endif
13699 + orq %r10,\rip(%rsp)
13700 + .endm
13701 + .macro pax_force_fptr ptr
13702 + orq %r10,\ptr
13703 + .endm
13704 + .macro pax_set_fptr_mask
13705 + movabs $0x8000000000000000,%r10
13706 + .endm
13707 +#endif
13708 +#else
13709 + .macro pax_force_retaddr rip=0, reload=0
13710 + .endm
13711 + .macro pax_force_fptr ptr
13712 + .endm
13713 + .macro pax_force_retaddr_bts rip=0
13714 + .endm
13715 + .macro pax_set_fptr_mask
13716 + .endm
13717 +#endif
13718 +
13719 .macro altinstruction_entry orig alt feature orig_len alt_len
13720 .long \orig - .
13721 .long \alt - .
13722 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13723 index 0a3f9c9..c9d081d 100644
13724 --- a/arch/x86/include/asm/alternative.h
13725 +++ b/arch/x86/include/asm/alternative.h
13726 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13727 ".pushsection .discard,\"aw\",@progbits\n" \
13728 DISCARD_ENTRY(1) \
13729 ".popsection\n" \
13730 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13731 + ".pushsection .altinstr_replacement, \"a\"\n" \
13732 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13733 ".popsection"
13734
13735 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13736 DISCARD_ENTRY(1) \
13737 DISCARD_ENTRY(2) \
13738 ".popsection\n" \
13739 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13740 + ".pushsection .altinstr_replacement, \"a\"\n" \
13741 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13742 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13743 ".popsection"
13744 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13745 index 1d2091a..f5074c1 100644
13746 --- a/arch/x86/include/asm/apic.h
13747 +++ b/arch/x86/include/asm/apic.h
13748 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13749
13750 #ifdef CONFIG_X86_LOCAL_APIC
13751
13752 -extern unsigned int apic_verbosity;
13753 +extern int apic_verbosity;
13754 extern int local_apic_timer_c2_ok;
13755
13756 extern int disable_apic;
13757 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13758 index 20370c6..a2eb9b0 100644
13759 --- a/arch/x86/include/asm/apm.h
13760 +++ b/arch/x86/include/asm/apm.h
13761 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13762 __asm__ __volatile__(APM_DO_ZERO_SEGS
13763 "pushl %%edi\n\t"
13764 "pushl %%ebp\n\t"
13765 - "lcall *%%cs:apm_bios_entry\n\t"
13766 + "lcall *%%ss:apm_bios_entry\n\t"
13767 "setc %%al\n\t"
13768 "popl %%ebp\n\t"
13769 "popl %%edi\n\t"
13770 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13771 __asm__ __volatile__(APM_DO_ZERO_SEGS
13772 "pushl %%edi\n\t"
13773 "pushl %%ebp\n\t"
13774 - "lcall *%%cs:apm_bios_entry\n\t"
13775 + "lcall *%%ss:apm_bios_entry\n\t"
13776 "setc %%bl\n\t"
13777 "popl %%ebp\n\t"
13778 "popl %%edi\n\t"
13779 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13780 index 722aa3b..3a0bb27 100644
13781 --- a/arch/x86/include/asm/atomic.h
13782 +++ b/arch/x86/include/asm/atomic.h
13783 @@ -22,7 +22,18 @@
13784 */
13785 static inline int atomic_read(const atomic_t *v)
13786 {
13787 - return (*(volatile int *)&(v)->counter);
13788 + return (*(volatile const int *)&(v)->counter);
13789 +}
13790 +
13791 +/**
13792 + * atomic_read_unchecked - read atomic variable
13793 + * @v: pointer of type atomic_unchecked_t
13794 + *
13795 + * Atomically reads the value of @v.
13796 + */
13797 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13798 +{
13799 + return (*(volatile const int *)&(v)->counter);
13800 }
13801
13802 /**
13803 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13804 }
13805
13806 /**
13807 + * atomic_set_unchecked - set atomic variable
13808 + * @v: pointer of type atomic_unchecked_t
13809 + * @i: required value
13810 + *
13811 + * Atomically sets the value of @v to @i.
13812 + */
13813 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13814 +{
13815 + v->counter = i;
13816 +}
13817 +
13818 +/**
13819 * atomic_add - add integer to atomic variable
13820 * @i: integer value to add
13821 * @v: pointer of type atomic_t
13822 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13823 */
13824 static inline void atomic_add(int i, atomic_t *v)
13825 {
13826 - asm volatile(LOCK_PREFIX "addl %1,%0"
13827 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13828 +
13829 +#ifdef CONFIG_PAX_REFCOUNT
13830 + "jno 0f\n"
13831 + LOCK_PREFIX "subl %1,%0\n"
13832 + "int $4\n0:\n"
13833 + _ASM_EXTABLE(0b, 0b)
13834 +#endif
13835 +
13836 + : "+m" (v->counter)
13837 + : "ir" (i));
13838 +}
13839 +
13840 +/**
13841 + * atomic_add_unchecked - add integer to atomic variable
13842 + * @i: integer value to add
13843 + * @v: pointer of type atomic_unchecked_t
13844 + *
13845 + * Atomically adds @i to @v.
13846 + */
13847 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13848 +{
13849 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13850 : "+m" (v->counter)
13851 : "ir" (i));
13852 }
13853 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13854 */
13855 static inline void atomic_sub(int i, atomic_t *v)
13856 {
13857 - asm volatile(LOCK_PREFIX "subl %1,%0"
13858 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13859 +
13860 +#ifdef CONFIG_PAX_REFCOUNT
13861 + "jno 0f\n"
13862 + LOCK_PREFIX "addl %1,%0\n"
13863 + "int $4\n0:\n"
13864 + _ASM_EXTABLE(0b, 0b)
13865 +#endif
13866 +
13867 + : "+m" (v->counter)
13868 + : "ir" (i));
13869 +}
13870 +
13871 +/**
13872 + * atomic_sub_unchecked - subtract integer from atomic variable
13873 + * @i: integer value to subtract
13874 + * @v: pointer of type atomic_unchecked_t
13875 + *
13876 + * Atomically subtracts @i from @v.
13877 + */
13878 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13879 +{
13880 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13881 : "+m" (v->counter)
13882 : "ir" (i));
13883 }
13884 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13885 {
13886 unsigned char c;
13887
13888 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13889 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13890 +
13891 +#ifdef CONFIG_PAX_REFCOUNT
13892 + "jno 0f\n"
13893 + LOCK_PREFIX "addl %2,%0\n"
13894 + "int $4\n0:\n"
13895 + _ASM_EXTABLE(0b, 0b)
13896 +#endif
13897 +
13898 + "sete %1\n"
13899 : "+m" (v->counter), "=qm" (c)
13900 : "ir" (i) : "memory");
13901 return c;
13902 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13903 */
13904 static inline void atomic_inc(atomic_t *v)
13905 {
13906 - asm volatile(LOCK_PREFIX "incl %0"
13907 + asm volatile(LOCK_PREFIX "incl %0\n"
13908 +
13909 +#ifdef CONFIG_PAX_REFCOUNT
13910 + "jno 0f\n"
13911 + LOCK_PREFIX "decl %0\n"
13912 + "int $4\n0:\n"
13913 + _ASM_EXTABLE(0b, 0b)
13914 +#endif
13915 +
13916 + : "+m" (v->counter));
13917 +}
13918 +
13919 +/**
13920 + * atomic_inc_unchecked - increment atomic variable
13921 + * @v: pointer of type atomic_unchecked_t
13922 + *
13923 + * Atomically increments @v by 1.
13924 + */
13925 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13926 +{
13927 + asm volatile(LOCK_PREFIX "incl %0\n"
13928 : "+m" (v->counter));
13929 }
13930
13931 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13932 */
13933 static inline void atomic_dec(atomic_t *v)
13934 {
13935 - asm volatile(LOCK_PREFIX "decl %0"
13936 + asm volatile(LOCK_PREFIX "decl %0\n"
13937 +
13938 +#ifdef CONFIG_PAX_REFCOUNT
13939 + "jno 0f\n"
13940 + LOCK_PREFIX "incl %0\n"
13941 + "int $4\n0:\n"
13942 + _ASM_EXTABLE(0b, 0b)
13943 +#endif
13944 +
13945 + : "+m" (v->counter));
13946 +}
13947 +
13948 +/**
13949 + * atomic_dec_unchecked - decrement atomic variable
13950 + * @v: pointer of type atomic_unchecked_t
13951 + *
13952 + * Atomically decrements @v by 1.
13953 + */
13954 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13955 +{
13956 + asm volatile(LOCK_PREFIX "decl %0\n"
13957 : "+m" (v->counter));
13958 }
13959
13960 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13961 {
13962 unsigned char c;
13963
13964 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13965 + asm volatile(LOCK_PREFIX "decl %0\n"
13966 +
13967 +#ifdef CONFIG_PAX_REFCOUNT
13968 + "jno 0f\n"
13969 + LOCK_PREFIX "incl %0\n"
13970 + "int $4\n0:\n"
13971 + _ASM_EXTABLE(0b, 0b)
13972 +#endif
13973 +
13974 + "sete %1\n"
13975 : "+m" (v->counter), "=qm" (c)
13976 : : "memory");
13977 return c != 0;
13978 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13979 {
13980 unsigned char c;
13981
13982 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13983 + asm volatile(LOCK_PREFIX "incl %0\n"
13984 +
13985 +#ifdef CONFIG_PAX_REFCOUNT
13986 + "jno 0f\n"
13987 + LOCK_PREFIX "decl %0\n"
13988 + "int $4\n0:\n"
13989 + _ASM_EXTABLE(0b, 0b)
13990 +#endif
13991 +
13992 + "sete %1\n"
13993 + : "+m" (v->counter), "=qm" (c)
13994 + : : "memory");
13995 + return c != 0;
13996 +}
13997 +
13998 +/**
13999 + * atomic_inc_and_test_unchecked - increment and test
14000 + * @v: pointer of type atomic_unchecked_t
14001 + *
14002 + * Atomically increments @v by 1
14003 + * and returns true if the result is zero, or false for all
14004 + * other cases.
14005 + */
14006 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14007 +{
14008 + unsigned char c;
14009 +
14010 + asm volatile(LOCK_PREFIX "incl %0\n"
14011 + "sete %1\n"
14012 : "+m" (v->counter), "=qm" (c)
14013 : : "memory");
14014 return c != 0;
14015 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14016 {
14017 unsigned char c;
14018
14019 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14020 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14021 +
14022 +#ifdef CONFIG_PAX_REFCOUNT
14023 + "jno 0f\n"
14024 + LOCK_PREFIX "subl %2,%0\n"
14025 + "int $4\n0:\n"
14026 + _ASM_EXTABLE(0b, 0b)
14027 +#endif
14028 +
14029 + "sets %1\n"
14030 : "+m" (v->counter), "=qm" (c)
14031 : "ir" (i) : "memory");
14032 return c;
14033 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14034 */
14035 static inline int atomic_add_return(int i, atomic_t *v)
14036 {
14037 + return i + xadd_check_overflow(&v->counter, i);
14038 +}
14039 +
14040 +/**
14041 + * atomic_add_return_unchecked - add integer and return
14042 + * @i: integer value to add
14043 + * @v: pointer of type atomic_unchecked_t
14044 + *
14045 + * Atomically adds @i to @v and returns @i + @v
14046 + */
14047 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14048 +{
14049 return i + xadd(&v->counter, i);
14050 }
14051
14052 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14053 }
14054
14055 #define atomic_inc_return(v) (atomic_add_return(1, v))
14056 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14057 +{
14058 + return atomic_add_return_unchecked(1, v);
14059 +}
14060 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14061
14062 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14063 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14064 return cmpxchg(&v->counter, old, new);
14065 }
14066
14067 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14068 +{
14069 + return cmpxchg(&v->counter, old, new);
14070 +}
14071 +
14072 static inline int atomic_xchg(atomic_t *v, int new)
14073 {
14074 return xchg(&v->counter, new);
14075 }
14076
14077 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14078 +{
14079 + return xchg(&v->counter, new);
14080 +}
14081 +
14082 /**
14083 * __atomic_add_unless - add unless the number is already a given value
14084 * @v: pointer of type atomic_t
14085 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14086 */
14087 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14088 {
14089 - int c, old;
14090 + int c, old, new;
14091 c = atomic_read(v);
14092 for (;;) {
14093 - if (unlikely(c == (u)))
14094 + if (unlikely(c == u))
14095 break;
14096 - old = atomic_cmpxchg((v), c, c + (a));
14097 +
14098 + asm volatile("addl %2,%0\n"
14099 +
14100 +#ifdef CONFIG_PAX_REFCOUNT
14101 + "jno 0f\n"
14102 + "subl %2,%0\n"
14103 + "int $4\n0:\n"
14104 + _ASM_EXTABLE(0b, 0b)
14105 +#endif
14106 +
14107 + : "=r" (new)
14108 + : "0" (c), "ir" (a));
14109 +
14110 + old = atomic_cmpxchg(v, c, new);
14111 if (likely(old == c))
14112 break;
14113 c = old;
14114 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14115 }
14116
14117 /**
14118 + * atomic_inc_not_zero_hint - increment if not null
14119 + * @v: pointer of type atomic_t
14120 + * @hint: probable value of the atomic before the increment
14121 + *
14122 + * This version of atomic_inc_not_zero() gives a hint of probable
14123 + * value of the atomic. This helps processor to not read the memory
14124 + * before doing the atomic read/modify/write cycle, lowering
14125 + * number of bus transactions on some arches.
14126 + *
14127 + * Returns: 0 if increment was not done, 1 otherwise.
14128 + */
14129 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14130 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14131 +{
14132 + int val, c = hint, new;
14133 +
14134 + /* sanity test, should be removed by compiler if hint is a constant */
14135 + if (!hint)
14136 + return __atomic_add_unless(v, 1, 0);
14137 +
14138 + do {
14139 + asm volatile("incl %0\n"
14140 +
14141 +#ifdef CONFIG_PAX_REFCOUNT
14142 + "jno 0f\n"
14143 + "decl %0\n"
14144 + "int $4\n0:\n"
14145 + _ASM_EXTABLE(0b, 0b)
14146 +#endif
14147 +
14148 + : "=r" (new)
14149 + : "0" (c));
14150 +
14151 + val = atomic_cmpxchg(v, c, new);
14152 + if (val == c)
14153 + return 1;
14154 + c = val;
14155 + } while (c);
14156 +
14157 + return 0;
14158 +}
14159 +
14160 +/**
14161 * atomic_inc_short - increment of a short integer
14162 * @v: pointer to type int
14163 *
14164 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14165 #endif
14166
14167 /* These are x86-specific, used by some header files */
14168 -#define atomic_clear_mask(mask, addr) \
14169 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14170 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14171 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14172 +{
14173 + asm volatile(LOCK_PREFIX "andl %1,%0"
14174 + : "+m" (v->counter)
14175 + : "r" (~(mask))
14176 + : "memory");
14177 +}
14178
14179 -#define atomic_set_mask(mask, addr) \
14180 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14181 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14182 - : "memory")
14183 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14184 +{
14185 + asm volatile(LOCK_PREFIX "andl %1,%0"
14186 + : "+m" (v->counter)
14187 + : "r" (~(mask))
14188 + : "memory");
14189 +}
14190 +
14191 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14192 +{
14193 + asm volatile(LOCK_PREFIX "orl %1,%0"
14194 + : "+m" (v->counter)
14195 + : "r" (mask)
14196 + : "memory");
14197 +}
14198 +
14199 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14200 +{
14201 + asm volatile(LOCK_PREFIX "orl %1,%0"
14202 + : "+m" (v->counter)
14203 + : "r" (mask)
14204 + : "memory");
14205 +}
14206
14207 /* Atomic operations are already serializing on x86 */
14208 #define smp_mb__before_atomic_dec() barrier()
14209 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14210 index b154de7..aadebd8 100644
14211 --- a/arch/x86/include/asm/atomic64_32.h
14212 +++ b/arch/x86/include/asm/atomic64_32.h
14213 @@ -12,6 +12,14 @@ typedef struct {
14214 u64 __aligned(8) counter;
14215 } atomic64_t;
14216
14217 +#ifdef CONFIG_PAX_REFCOUNT
14218 +typedef struct {
14219 + u64 __aligned(8) counter;
14220 +} atomic64_unchecked_t;
14221 +#else
14222 +typedef atomic64_t atomic64_unchecked_t;
14223 +#endif
14224 +
14225 #define ATOMIC64_INIT(val) { (val) }
14226
14227 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14228 @@ -37,21 +45,31 @@ typedef struct {
14229 ATOMIC64_DECL_ONE(sym##_386)
14230
14231 ATOMIC64_DECL_ONE(add_386);
14232 +ATOMIC64_DECL_ONE(add_unchecked_386);
14233 ATOMIC64_DECL_ONE(sub_386);
14234 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14235 ATOMIC64_DECL_ONE(inc_386);
14236 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14237 ATOMIC64_DECL_ONE(dec_386);
14238 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14239 #endif
14240
14241 #define alternative_atomic64(f, out, in...) \
14242 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14243
14244 ATOMIC64_DECL(read);
14245 +ATOMIC64_DECL(read_unchecked);
14246 ATOMIC64_DECL(set);
14247 +ATOMIC64_DECL(set_unchecked);
14248 ATOMIC64_DECL(xchg);
14249 ATOMIC64_DECL(add_return);
14250 +ATOMIC64_DECL(add_return_unchecked);
14251 ATOMIC64_DECL(sub_return);
14252 +ATOMIC64_DECL(sub_return_unchecked);
14253 ATOMIC64_DECL(inc_return);
14254 +ATOMIC64_DECL(inc_return_unchecked);
14255 ATOMIC64_DECL(dec_return);
14256 +ATOMIC64_DECL(dec_return_unchecked);
14257 ATOMIC64_DECL(dec_if_positive);
14258 ATOMIC64_DECL(inc_not_zero);
14259 ATOMIC64_DECL(add_unless);
14260 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14261 }
14262
14263 /**
14264 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14265 + * @p: pointer to type atomic64_unchecked_t
14266 + * @o: expected value
14267 + * @n: new value
14268 + *
14269 + * Atomically sets @v to @n if it was equal to @o and returns
14270 + * the old value.
14271 + */
14272 +
14273 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14274 +{
14275 + return cmpxchg64(&v->counter, o, n);
14276 +}
14277 +
14278 +/**
14279 * atomic64_xchg - xchg atomic64 variable
14280 * @v: pointer to type atomic64_t
14281 * @n: value to assign
14282 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14283 }
14284
14285 /**
14286 + * atomic64_set_unchecked - set atomic64 variable
14287 + * @v: pointer to type atomic64_unchecked_t
14288 + * @n: value to assign
14289 + *
14290 + * Atomically sets the value of @v to @n.
14291 + */
14292 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14293 +{
14294 + unsigned high = (unsigned)(i >> 32);
14295 + unsigned low = (unsigned)i;
14296 + alternative_atomic64(set, /* no output */,
14297 + "S" (v), "b" (low), "c" (high)
14298 + : "eax", "edx", "memory");
14299 +}
14300 +
14301 +/**
14302 * atomic64_read - read atomic64 variable
14303 * @v: pointer to type atomic64_t
14304 *
14305 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14306 }
14307
14308 /**
14309 + * atomic64_read_unchecked - read atomic64 variable
14310 + * @v: pointer to type atomic64_unchecked_t
14311 + *
14312 + * Atomically reads the value of @v and returns it.
14313 + */
14314 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14315 +{
14316 + long long r;
14317 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14318 + return r;
14319 + }
14320 +
14321 +/**
14322 * atomic64_add_return - add and return
14323 * @i: integer value to add
14324 * @v: pointer to type atomic64_t
14325 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14326 return i;
14327 }
14328
14329 +/**
14330 + * atomic64_add_return_unchecked - add and return
14331 + * @i: integer value to add
14332 + * @v: pointer to type atomic64_unchecked_t
14333 + *
14334 + * Atomically adds @i to @v and returns @i + *@v
14335 + */
14336 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14337 +{
14338 + alternative_atomic64(add_return_unchecked,
14339 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14340 + ASM_NO_INPUT_CLOBBER("memory"));
14341 + return i;
14342 +}
14343 +
14344 /*
14345 * Other variants with different arithmetic operators:
14346 */
14347 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14348 return a;
14349 }
14350
14351 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14352 +{
14353 + long long a;
14354 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14355 + "S" (v) : "memory", "ecx");
14356 + return a;
14357 +}
14358 +
14359 static inline long long atomic64_dec_return(atomic64_t *v)
14360 {
14361 long long a;
14362 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14363 }
14364
14365 /**
14366 + * atomic64_add_unchecked - add integer to atomic64 variable
14367 + * @i: integer value to add
14368 + * @v: pointer to type atomic64_unchecked_t
14369 + *
14370 + * Atomically adds @i to @v.
14371 + */
14372 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14373 +{
14374 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14375 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14376 + ASM_NO_INPUT_CLOBBER("memory"));
14377 + return i;
14378 +}
14379 +
14380 +/**
14381 * atomic64_sub - subtract the atomic64 variable
14382 * @i: integer value to subtract
14383 * @v: pointer to type atomic64_t
14384 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14385 index 0e1cbfc..5623683 100644
14386 --- a/arch/x86/include/asm/atomic64_64.h
14387 +++ b/arch/x86/include/asm/atomic64_64.h
14388 @@ -18,7 +18,19 @@
14389 */
14390 static inline long atomic64_read(const atomic64_t *v)
14391 {
14392 - return (*(volatile long *)&(v)->counter);
14393 + return (*(volatile const long *)&(v)->counter);
14394 +}
14395 +
14396 +/**
14397 + * atomic64_read_unchecked - read atomic64 variable
14398 + * @v: pointer of type atomic64_unchecked_t
14399 + *
14400 + * Atomically reads the value of @v.
14401 + * Doesn't imply a read memory barrier.
14402 + */
14403 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14404 +{
14405 + return (*(volatile const long *)&(v)->counter);
14406 }
14407
14408 /**
14409 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14410 }
14411
14412 /**
14413 + * atomic64_set_unchecked - set atomic64 variable
14414 + * @v: pointer to type atomic64_unchecked_t
14415 + * @i: required value
14416 + *
14417 + * Atomically sets the value of @v to @i.
14418 + */
14419 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14420 +{
14421 + v->counter = i;
14422 +}
14423 +
14424 +/**
14425 * atomic64_add - add integer to atomic64 variable
14426 * @i: integer value to add
14427 * @v: pointer to type atomic64_t
14428 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14429 */
14430 static inline void atomic64_add(long i, atomic64_t *v)
14431 {
14432 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14433 +
14434 +#ifdef CONFIG_PAX_REFCOUNT
14435 + "jno 0f\n"
14436 + LOCK_PREFIX "subq %1,%0\n"
14437 + "int $4\n0:\n"
14438 + _ASM_EXTABLE(0b, 0b)
14439 +#endif
14440 +
14441 + : "=m" (v->counter)
14442 + : "er" (i), "m" (v->counter));
14443 +}
14444 +
14445 +/**
14446 + * atomic64_add_unchecked - add integer to atomic64 variable
14447 + * @i: integer value to add
14448 + * @v: pointer to type atomic64_unchecked_t
14449 + *
14450 + * Atomically adds @i to @v.
14451 + */
14452 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14453 +{
14454 asm volatile(LOCK_PREFIX "addq %1,%0"
14455 : "=m" (v->counter)
14456 : "er" (i), "m" (v->counter));
14457 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14458 */
14459 static inline void atomic64_sub(long i, atomic64_t *v)
14460 {
14461 - asm volatile(LOCK_PREFIX "subq %1,%0"
14462 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14463 +
14464 +#ifdef CONFIG_PAX_REFCOUNT
14465 + "jno 0f\n"
14466 + LOCK_PREFIX "addq %1,%0\n"
14467 + "int $4\n0:\n"
14468 + _ASM_EXTABLE(0b, 0b)
14469 +#endif
14470 +
14471 + : "=m" (v->counter)
14472 + : "er" (i), "m" (v->counter));
14473 +}
14474 +
14475 +/**
14476 + * atomic64_sub_unchecked - subtract the atomic64 variable
14477 + * @i: integer value to subtract
14478 + * @v: pointer to type atomic64_unchecked_t
14479 + *
14480 + * Atomically subtracts @i from @v.
14481 + */
14482 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14483 +{
14484 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14485 : "=m" (v->counter)
14486 : "er" (i), "m" (v->counter));
14487 }
14488 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14489 {
14490 unsigned char c;
14491
14492 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14493 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14494 +
14495 +#ifdef CONFIG_PAX_REFCOUNT
14496 + "jno 0f\n"
14497 + LOCK_PREFIX "addq %2,%0\n"
14498 + "int $4\n0:\n"
14499 + _ASM_EXTABLE(0b, 0b)
14500 +#endif
14501 +
14502 + "sete %1\n"
14503 : "=m" (v->counter), "=qm" (c)
14504 : "er" (i), "m" (v->counter) : "memory");
14505 return c;
14506 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14507 */
14508 static inline void atomic64_inc(atomic64_t *v)
14509 {
14510 + asm volatile(LOCK_PREFIX "incq %0\n"
14511 +
14512 +#ifdef CONFIG_PAX_REFCOUNT
14513 + "jno 0f\n"
14514 + LOCK_PREFIX "decq %0\n"
14515 + "int $4\n0:\n"
14516 + _ASM_EXTABLE(0b, 0b)
14517 +#endif
14518 +
14519 + : "=m" (v->counter)
14520 + : "m" (v->counter));
14521 +}
14522 +
14523 +/**
14524 + * atomic64_inc_unchecked - increment atomic64 variable
14525 + * @v: pointer to type atomic64_unchecked_t
14526 + *
14527 + * Atomically increments @v by 1.
14528 + */
14529 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14530 +{
14531 asm volatile(LOCK_PREFIX "incq %0"
14532 : "=m" (v->counter)
14533 : "m" (v->counter));
14534 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14535 */
14536 static inline void atomic64_dec(atomic64_t *v)
14537 {
14538 - asm volatile(LOCK_PREFIX "decq %0"
14539 + asm volatile(LOCK_PREFIX "decq %0\n"
14540 +
14541 +#ifdef CONFIG_PAX_REFCOUNT
14542 + "jno 0f\n"
14543 + LOCK_PREFIX "incq %0\n"
14544 + "int $4\n0:\n"
14545 + _ASM_EXTABLE(0b, 0b)
14546 +#endif
14547 +
14548 + : "=m" (v->counter)
14549 + : "m" (v->counter));
14550 +}
14551 +
14552 +/**
14553 + * atomic64_dec_unchecked - decrement atomic64 variable
14554 + * @v: pointer to type atomic64_t
14555 + *
14556 + * Atomically decrements @v by 1.
14557 + */
14558 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14559 +{
14560 + asm volatile(LOCK_PREFIX "decq %0\n"
14561 : "=m" (v->counter)
14562 : "m" (v->counter));
14563 }
14564 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14565 {
14566 unsigned char c;
14567
14568 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14569 + asm volatile(LOCK_PREFIX "decq %0\n"
14570 +
14571 +#ifdef CONFIG_PAX_REFCOUNT
14572 + "jno 0f\n"
14573 + LOCK_PREFIX "incq %0\n"
14574 + "int $4\n0:\n"
14575 + _ASM_EXTABLE(0b, 0b)
14576 +#endif
14577 +
14578 + "sete %1\n"
14579 : "=m" (v->counter), "=qm" (c)
14580 : "m" (v->counter) : "memory");
14581 return c != 0;
14582 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14583 {
14584 unsigned char c;
14585
14586 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14587 + asm volatile(LOCK_PREFIX "incq %0\n"
14588 +
14589 +#ifdef CONFIG_PAX_REFCOUNT
14590 + "jno 0f\n"
14591 + LOCK_PREFIX "decq %0\n"
14592 + "int $4\n0:\n"
14593 + _ASM_EXTABLE(0b, 0b)
14594 +#endif
14595 +
14596 + "sete %1\n"
14597 : "=m" (v->counter), "=qm" (c)
14598 : "m" (v->counter) : "memory");
14599 return c != 0;
14600 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14601 {
14602 unsigned char c;
14603
14604 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14605 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14606 +
14607 +#ifdef CONFIG_PAX_REFCOUNT
14608 + "jno 0f\n"
14609 + LOCK_PREFIX "subq %2,%0\n"
14610 + "int $4\n0:\n"
14611 + _ASM_EXTABLE(0b, 0b)
14612 +#endif
14613 +
14614 + "sets %1\n"
14615 : "=m" (v->counter), "=qm" (c)
14616 : "er" (i), "m" (v->counter) : "memory");
14617 return c;
14618 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14619 */
14620 static inline long atomic64_add_return(long i, atomic64_t *v)
14621 {
14622 + return i + xadd_check_overflow(&v->counter, i);
14623 +}
14624 +
14625 +/**
14626 + * atomic64_add_return_unchecked - add and return
14627 + * @i: integer value to add
14628 + * @v: pointer to type atomic64_unchecked_t
14629 + *
14630 + * Atomically adds @i to @v and returns @i + @v
14631 + */
14632 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14633 +{
14634 return i + xadd(&v->counter, i);
14635 }
14636
14637 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14638 }
14639
14640 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14641 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14642 +{
14643 + return atomic64_add_return_unchecked(1, v);
14644 +}
14645 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14646
14647 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14648 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14649 return cmpxchg(&v->counter, old, new);
14650 }
14651
14652 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14653 +{
14654 + return cmpxchg(&v->counter, old, new);
14655 +}
14656 +
14657 static inline long atomic64_xchg(atomic64_t *v, long new)
14658 {
14659 return xchg(&v->counter, new);
14660 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14661 */
14662 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14663 {
14664 - long c, old;
14665 + long c, old, new;
14666 c = atomic64_read(v);
14667 for (;;) {
14668 - if (unlikely(c == (u)))
14669 + if (unlikely(c == u))
14670 break;
14671 - old = atomic64_cmpxchg((v), c, c + (a));
14672 +
14673 + asm volatile("add %2,%0\n"
14674 +
14675 +#ifdef CONFIG_PAX_REFCOUNT
14676 + "jno 0f\n"
14677 + "sub %2,%0\n"
14678 + "int $4\n0:\n"
14679 + _ASM_EXTABLE(0b, 0b)
14680 +#endif
14681 +
14682 + : "=r" (new)
14683 + : "0" (c), "ir" (a));
14684 +
14685 + old = atomic64_cmpxchg(v, c, new);
14686 if (likely(old == c))
14687 break;
14688 c = old;
14689 }
14690 - return c != (u);
14691 + return c != u;
14692 }
14693
14694 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14695 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14696 index 41639ce..0bd8c87 100644
14697 --- a/arch/x86/include/asm/bitops.h
14698 +++ b/arch/x86/include/asm/bitops.h
14699 @@ -48,7 +48,7 @@
14700 * a mask operation on a byte.
14701 */
14702 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14703 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14704 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14705 #define CONST_MASK(nr) (1 << ((nr) & 7))
14706
14707 /**
14708 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
14709 *
14710 * Undefined if no bit exists, so code should check against 0 first.
14711 */
14712 -static inline unsigned long __ffs(unsigned long word)
14713 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
14714 {
14715 asm("rep; bsf %1,%0"
14716 : "=r" (word)
14717 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
14718 *
14719 * Undefined if no zero exists, so code should check against ~0UL first.
14720 */
14721 -static inline unsigned long ffz(unsigned long word)
14722 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
14723 {
14724 asm("rep; bsf %1,%0"
14725 : "=r" (word)
14726 @@ -494,7 +494,7 @@ static inline int fls(int x)
14727 * at position 64.
14728 */
14729 #ifdef CONFIG_X86_64
14730 -static __always_inline int fls64(__u64 x)
14731 +static __always_inline long fls64(__u64 x)
14732 {
14733 int bitpos = -1;
14734 /*
14735 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14736 index 4fa687a..60f2d39 100644
14737 --- a/arch/x86/include/asm/boot.h
14738 +++ b/arch/x86/include/asm/boot.h
14739 @@ -6,10 +6,15 @@
14740 #include <uapi/asm/boot.h>
14741
14742 /* Physical address where kernel should be loaded. */
14743 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14744 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14745 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14746 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14747
14748 +#ifndef __ASSEMBLY__
14749 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14750 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14751 +#endif
14752 +
14753 /* Minimum kernel alignment, as a power of two */
14754 #ifdef CONFIG_X86_64
14755 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14756 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14757 index 48f99f1..d78ebf9 100644
14758 --- a/arch/x86/include/asm/cache.h
14759 +++ b/arch/x86/include/asm/cache.h
14760 @@ -5,12 +5,13 @@
14761
14762 /* L1 cache line size */
14763 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14764 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14765 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14766
14767 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14768 +#define __read_only __attribute__((__section__(".data..read_only")))
14769
14770 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14771 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14772 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14773
14774 #ifdef CONFIG_X86_VSMP
14775 #ifdef CONFIG_SMP
14776 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14777 index 9863ee3..4a1f8e1 100644
14778 --- a/arch/x86/include/asm/cacheflush.h
14779 +++ b/arch/x86/include/asm/cacheflush.h
14780 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14781 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14782
14783 if (pg_flags == _PGMT_DEFAULT)
14784 - return -1;
14785 + return ~0UL;
14786 else if (pg_flags == _PGMT_WC)
14787 return _PAGE_CACHE_WC;
14788 else if (pg_flags == _PGMT_UC_MINUS)
14789 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14790 index f50de69..2b0a458 100644
14791 --- a/arch/x86/include/asm/checksum_32.h
14792 +++ b/arch/x86/include/asm/checksum_32.h
14793 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14794 int len, __wsum sum,
14795 int *src_err_ptr, int *dst_err_ptr);
14796
14797 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14798 + int len, __wsum sum,
14799 + int *src_err_ptr, int *dst_err_ptr);
14800 +
14801 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14802 + int len, __wsum sum,
14803 + int *src_err_ptr, int *dst_err_ptr);
14804 +
14805 /*
14806 * Note: when you get a NULL pointer exception here this means someone
14807 * passed in an incorrect kernel address to one of these functions.
14808 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14809
14810 might_sleep();
14811 stac();
14812 - ret = csum_partial_copy_generic((__force void *)src, dst,
14813 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14814 len, sum, err_ptr, NULL);
14815 clac();
14816
14817 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14818 might_sleep();
14819 if (access_ok(VERIFY_WRITE, dst, len)) {
14820 stac();
14821 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14822 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14823 len, sum, NULL, err_ptr);
14824 clac();
14825 return ret;
14826 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14827 index d47786a..ce1b05d 100644
14828 --- a/arch/x86/include/asm/cmpxchg.h
14829 +++ b/arch/x86/include/asm/cmpxchg.h
14830 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14831 __compiletime_error("Bad argument size for cmpxchg");
14832 extern void __xadd_wrong_size(void)
14833 __compiletime_error("Bad argument size for xadd");
14834 +extern void __xadd_check_overflow_wrong_size(void)
14835 + __compiletime_error("Bad argument size for xadd_check_overflow");
14836 extern void __add_wrong_size(void)
14837 __compiletime_error("Bad argument size for add");
14838 +extern void __add_check_overflow_wrong_size(void)
14839 + __compiletime_error("Bad argument size for add_check_overflow");
14840
14841 /*
14842 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14843 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14844 __ret; \
14845 })
14846
14847 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14848 + ({ \
14849 + __typeof__ (*(ptr)) __ret = (arg); \
14850 + switch (sizeof(*(ptr))) { \
14851 + case __X86_CASE_L: \
14852 + asm volatile (lock #op "l %0, %1\n" \
14853 + "jno 0f\n" \
14854 + "mov %0,%1\n" \
14855 + "int $4\n0:\n" \
14856 + _ASM_EXTABLE(0b, 0b) \
14857 + : "+r" (__ret), "+m" (*(ptr)) \
14858 + : : "memory", "cc"); \
14859 + break; \
14860 + case __X86_CASE_Q: \
14861 + asm volatile (lock #op "q %q0, %1\n" \
14862 + "jno 0f\n" \
14863 + "mov %0,%1\n" \
14864 + "int $4\n0:\n" \
14865 + _ASM_EXTABLE(0b, 0b) \
14866 + : "+r" (__ret), "+m" (*(ptr)) \
14867 + : : "memory", "cc"); \
14868 + break; \
14869 + default: \
14870 + __ ## op ## _check_overflow_wrong_size(); \
14871 + } \
14872 + __ret; \
14873 + })
14874 +
14875 /*
14876 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14877 * Since this is generally used to protect other memory information, we
14878 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14879 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14880 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14881
14882 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14883 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14884 +
14885 #define __add(ptr, inc, lock) \
14886 ({ \
14887 __typeof__ (*(ptr)) __ret = (inc); \
14888 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14889 index 59c6c40..5e0b22c 100644
14890 --- a/arch/x86/include/asm/compat.h
14891 +++ b/arch/x86/include/asm/compat.h
14892 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14893 typedef u32 compat_uint_t;
14894 typedef u32 compat_ulong_t;
14895 typedef u64 __attribute__((aligned(4))) compat_u64;
14896 -typedef u32 compat_uptr_t;
14897 +typedef u32 __user compat_uptr_t;
14898
14899 struct compat_timespec {
14900 compat_time_t tv_sec;
14901 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14902 index 89270b4..f0abf8e 100644
14903 --- a/arch/x86/include/asm/cpufeature.h
14904 +++ b/arch/x86/include/asm/cpufeature.h
14905 @@ -203,7 +203,7 @@
14906 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14907 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14908 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14909 -
14910 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14911
14912 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14913 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14914 @@ -211,7 +211,7 @@
14915 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14916 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14917 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14918 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14919 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14920 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14921 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14922 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14923 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14924 #undef cpu_has_centaur_mcr
14925 #define cpu_has_centaur_mcr 0
14926
14927 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14928 #endif /* CONFIG_X86_64 */
14929
14930 #if __GNUC__ >= 4
14931 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14932
14933 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14934 t_warn:
14935 - warn_pre_alternatives();
14936 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14937 + warn_pre_alternatives();
14938 return false;
14939 #endif
14940
14941 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14942 ".section .discard,\"aw\",@progbits\n"
14943 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14944 ".previous\n"
14945 - ".section .altinstr_replacement,\"ax\"\n"
14946 + ".section .altinstr_replacement,\"a\"\n"
14947 "3: movb $1,%0\n"
14948 "4:\n"
14949 ".previous\n"
14950 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14951 " .byte 2b - 1b\n" /* src len */
14952 " .byte 4f - 3f\n" /* repl len */
14953 ".previous\n"
14954 - ".section .altinstr_replacement,\"ax\"\n"
14955 + ".section .altinstr_replacement,\"a\"\n"
14956 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14957 "4:\n"
14958 ".previous\n"
14959 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14960 ".section .discard,\"aw\",@progbits\n"
14961 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14962 ".previous\n"
14963 - ".section .altinstr_replacement,\"ax\"\n"
14964 + ".section .altinstr_replacement,\"a\"\n"
14965 "3: movb $0,%0\n"
14966 "4:\n"
14967 ".previous\n"
14968 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14969 ".section .discard,\"aw\",@progbits\n"
14970 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14971 ".previous\n"
14972 - ".section .altinstr_replacement,\"ax\"\n"
14973 + ".section .altinstr_replacement,\"a\"\n"
14974 "5: movb $1,%0\n"
14975 "6:\n"
14976 ".previous\n"
14977 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14978 index b90e5df..b462c91 100644
14979 --- a/arch/x86/include/asm/desc.h
14980 +++ b/arch/x86/include/asm/desc.h
14981 @@ -4,6 +4,7 @@
14982 #include <asm/desc_defs.h>
14983 #include <asm/ldt.h>
14984 #include <asm/mmu.h>
14985 +#include <asm/pgtable.h>
14986
14987 #include <linux/smp.h>
14988 #include <linux/percpu.h>
14989 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14990
14991 desc->type = (info->read_exec_only ^ 1) << 1;
14992 desc->type |= info->contents << 2;
14993 + desc->type |= info->seg_not_present ^ 1;
14994
14995 desc->s = 1;
14996 desc->dpl = 0x3;
14997 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14998 }
14999
15000 extern struct desc_ptr idt_descr;
15001 -extern gate_desc idt_table[];
15002 -extern struct desc_ptr debug_idt_descr;
15003 -extern gate_desc debug_idt_table[];
15004 -
15005 -struct gdt_page {
15006 - struct desc_struct gdt[GDT_ENTRIES];
15007 -} __attribute__((aligned(PAGE_SIZE)));
15008 -
15009 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15010 +extern gate_desc idt_table[IDT_ENTRIES];
15011 +extern const struct desc_ptr debug_idt_descr;
15012 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15013
15014 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15015 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15016 {
15017 - return per_cpu(gdt_page, cpu).gdt;
15018 + return cpu_gdt_table[cpu];
15019 }
15020
15021 #ifdef CONFIG_X86_64
15022 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15023 unsigned long base, unsigned dpl, unsigned flags,
15024 unsigned short seg)
15025 {
15026 - gate->a = (seg << 16) | (base & 0xffff);
15027 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15028 + gate->gate.offset_low = base;
15029 + gate->gate.seg = seg;
15030 + gate->gate.reserved = 0;
15031 + gate->gate.type = type;
15032 + gate->gate.s = 0;
15033 + gate->gate.dpl = dpl;
15034 + gate->gate.p = 1;
15035 + gate->gate.offset_high = base >> 16;
15036 }
15037
15038 #endif
15039 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15040
15041 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15042 {
15043 + pax_open_kernel();
15044 memcpy(&idt[entry], gate, sizeof(*gate));
15045 + pax_close_kernel();
15046 }
15047
15048 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15049 {
15050 + pax_open_kernel();
15051 memcpy(&ldt[entry], desc, 8);
15052 + pax_close_kernel();
15053 }
15054
15055 static inline void
15056 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15057 default: size = sizeof(*gdt); break;
15058 }
15059
15060 + pax_open_kernel();
15061 memcpy(&gdt[entry], desc, size);
15062 + pax_close_kernel();
15063 }
15064
15065 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15066 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15067
15068 static inline void native_load_tr_desc(void)
15069 {
15070 + pax_open_kernel();
15071 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15072 + pax_close_kernel();
15073 }
15074
15075 static inline void native_load_gdt(const struct desc_ptr *dtr)
15076 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15077 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15078 unsigned int i;
15079
15080 + pax_open_kernel();
15081 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15082 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15083 + pax_close_kernel();
15084 }
15085
15086 #define _LDT_empty(info) \
15087 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15088 preempt_enable();
15089 }
15090
15091 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15092 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15093 {
15094 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15095 }
15096 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15097 }
15098
15099 #ifdef CONFIG_X86_64
15100 -static inline void set_nmi_gate(int gate, void *addr)
15101 +static inline void set_nmi_gate(int gate, const void *addr)
15102 {
15103 gate_desc s;
15104
15105 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15106 #endif
15107
15108 #ifdef CONFIG_TRACING
15109 -extern struct desc_ptr trace_idt_descr;
15110 -extern gate_desc trace_idt_table[];
15111 +extern const struct desc_ptr trace_idt_descr;
15112 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15113 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15114 {
15115 write_idt_entry(trace_idt_table, entry, gate);
15116 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15117 }
15118 #endif
15119
15120 -static inline void _set_gate(int gate, unsigned type, void *addr,
15121 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15122 unsigned dpl, unsigned ist, unsigned seg)
15123 {
15124 gate_desc s;
15125 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15126 * Pentium F0 0F bugfix can have resulted in the mapped
15127 * IDT being write-protected.
15128 */
15129 -static inline void set_intr_gate(unsigned int n, void *addr)
15130 +static inline void set_intr_gate(unsigned int n, const void *addr)
15131 {
15132 BUG_ON((unsigned)n > 0xFF);
15133 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15134 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15135 /*
15136 * This routine sets up an interrupt gate at directory privilege level 3.
15137 */
15138 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15139 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15140 {
15141 BUG_ON((unsigned)n > 0xFF);
15142 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15143 }
15144
15145 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15146 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15147 {
15148 BUG_ON((unsigned)n > 0xFF);
15149 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15150 }
15151
15152 -static inline void set_trap_gate(unsigned int n, void *addr)
15153 +static inline void set_trap_gate(unsigned int n, const void *addr)
15154 {
15155 BUG_ON((unsigned)n > 0xFF);
15156 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15157 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15158 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15159 {
15160 BUG_ON((unsigned)n > 0xFF);
15161 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15162 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15163 }
15164
15165 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15166 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15167 {
15168 BUG_ON((unsigned)n > 0xFF);
15169 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15170 }
15171
15172 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15173 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15174 {
15175 BUG_ON((unsigned)n > 0xFF);
15176 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15177 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15178 else
15179 load_idt((const struct desc_ptr *)&idt_descr);
15180 }
15181 +
15182 +#ifdef CONFIG_X86_32
15183 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15184 +{
15185 + struct desc_struct d;
15186 +
15187 + if (likely(limit))
15188 + limit = (limit - 1UL) >> PAGE_SHIFT;
15189 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15190 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15191 +}
15192 +#endif
15193 +
15194 #endif /* _ASM_X86_DESC_H */
15195 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15196 index 278441f..b95a174 100644
15197 --- a/arch/x86/include/asm/desc_defs.h
15198 +++ b/arch/x86/include/asm/desc_defs.h
15199 @@ -31,6 +31,12 @@ struct desc_struct {
15200 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15201 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15202 };
15203 + struct {
15204 + u16 offset_low;
15205 + u16 seg;
15206 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15207 + unsigned offset_high: 16;
15208 + } gate;
15209 };
15210 } __attribute__((packed));
15211
15212 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15213 index ced283a..ffe04cc 100644
15214 --- a/arch/x86/include/asm/div64.h
15215 +++ b/arch/x86/include/asm/div64.h
15216 @@ -39,7 +39,7 @@
15217 __mod; \
15218 })
15219
15220 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15221 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15222 {
15223 union {
15224 u64 v64;
15225 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15226 index 9c999c1..3860cb8 100644
15227 --- a/arch/x86/include/asm/elf.h
15228 +++ b/arch/x86/include/asm/elf.h
15229 @@ -243,7 +243,25 @@ extern int force_personality32;
15230 the loader. We need to make sure that it is out of the way of the program
15231 that it will "exec", and that there is sufficient room for the brk. */
15232
15233 +#ifdef CONFIG_PAX_SEGMEXEC
15234 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15235 +#else
15236 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15237 +#endif
15238 +
15239 +#ifdef CONFIG_PAX_ASLR
15240 +#ifdef CONFIG_X86_32
15241 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15242 +
15243 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15244 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15245 +#else
15246 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15247 +
15248 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15249 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15250 +#endif
15251 +#endif
15252
15253 /* This yields a mask that user programs can use to figure out what
15254 instruction set this CPU supports. This could be done in user space,
15255 @@ -296,16 +314,12 @@ do { \
15256
15257 #define ARCH_DLINFO \
15258 do { \
15259 - if (vdso_enabled) \
15260 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15261 - (unsigned long)current->mm->context.vdso); \
15262 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15263 } while (0)
15264
15265 #define ARCH_DLINFO_X32 \
15266 do { \
15267 - if (vdso_enabled) \
15268 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15269 - (unsigned long)current->mm->context.vdso); \
15270 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15271 } while (0)
15272
15273 #define AT_SYSINFO 32
15274 @@ -320,7 +334,7 @@ else \
15275
15276 #endif /* !CONFIG_X86_32 */
15277
15278 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15279 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15280
15281 #define VDSO_ENTRY \
15282 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15283 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15284 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15285 #define compat_arch_setup_additional_pages syscall32_setup_pages
15286
15287 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15288 -#define arch_randomize_brk arch_randomize_brk
15289 -
15290 /*
15291 * True on X86_32 or when emulating IA32 on X86_64
15292 */
15293 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15294 index 77a99ac..39ff7f5 100644
15295 --- a/arch/x86/include/asm/emergency-restart.h
15296 +++ b/arch/x86/include/asm/emergency-restart.h
15297 @@ -1,6 +1,6 @@
15298 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15299 #define _ASM_X86_EMERGENCY_RESTART_H
15300
15301 -extern void machine_emergency_restart(void);
15302 +extern void machine_emergency_restart(void) __noreturn;
15303
15304 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15305 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15306 index 4d0bda7..221da4d 100644
15307 --- a/arch/x86/include/asm/fpu-internal.h
15308 +++ b/arch/x86/include/asm/fpu-internal.h
15309 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15310 #define user_insn(insn, output, input...) \
15311 ({ \
15312 int err; \
15313 + pax_open_userland(); \
15314 asm volatile(ASM_STAC "\n" \
15315 - "1:" #insn "\n\t" \
15316 + "1:" \
15317 + __copyuser_seg \
15318 + #insn "\n\t" \
15319 "2: " ASM_CLAC "\n" \
15320 ".section .fixup,\"ax\"\n" \
15321 "3: movl $-1,%[err]\n" \
15322 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15323 _ASM_EXTABLE(1b, 3b) \
15324 : [err] "=r" (err), output \
15325 : "0"(0), input); \
15326 + pax_close_userland(); \
15327 err; \
15328 })
15329
15330 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15331 "emms\n\t" /* clear stack tags */
15332 "fildl %P[addr]", /* set F?P to defined value */
15333 X86_FEATURE_FXSAVE_LEAK,
15334 - [addr] "m" (tsk->thread.fpu.has_fpu));
15335 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15336
15337 return fpu_restore_checking(&tsk->thread.fpu);
15338 }
15339 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15340 index be27ba1..04a8801 100644
15341 --- a/arch/x86/include/asm/futex.h
15342 +++ b/arch/x86/include/asm/futex.h
15343 @@ -12,6 +12,7 @@
15344 #include <asm/smap.h>
15345
15346 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15347 + typecheck(u32 __user *, uaddr); \
15348 asm volatile("\t" ASM_STAC "\n" \
15349 "1:\t" insn "\n" \
15350 "2:\t" ASM_CLAC "\n" \
15351 @@ -20,15 +21,16 @@
15352 "\tjmp\t2b\n" \
15353 "\t.previous\n" \
15354 _ASM_EXTABLE(1b, 3b) \
15355 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15356 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15357 : "i" (-EFAULT), "0" (oparg), "1" (0))
15358
15359 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15360 + typecheck(u32 __user *, uaddr); \
15361 asm volatile("\t" ASM_STAC "\n" \
15362 "1:\tmovl %2, %0\n" \
15363 "\tmovl\t%0, %3\n" \
15364 "\t" insn "\n" \
15365 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15366 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15367 "\tjnz\t1b\n" \
15368 "3:\t" ASM_CLAC "\n" \
15369 "\t.section .fixup,\"ax\"\n" \
15370 @@ -38,7 +40,7 @@
15371 _ASM_EXTABLE(1b, 4b) \
15372 _ASM_EXTABLE(2b, 4b) \
15373 : "=&a" (oldval), "=&r" (ret), \
15374 - "+m" (*uaddr), "=&r" (tem) \
15375 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15376 : "r" (oparg), "i" (-EFAULT), "1" (0))
15377
15378 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15379 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15380
15381 pagefault_disable();
15382
15383 + pax_open_userland();
15384 switch (op) {
15385 case FUTEX_OP_SET:
15386 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15387 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15388 break;
15389 case FUTEX_OP_ADD:
15390 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15391 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15392 uaddr, oparg);
15393 break;
15394 case FUTEX_OP_OR:
15395 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15396 default:
15397 ret = -ENOSYS;
15398 }
15399 + pax_close_userland();
15400
15401 pagefault_enable();
15402
15403 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15404 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15405 return -EFAULT;
15406
15407 + pax_open_userland();
15408 asm volatile("\t" ASM_STAC "\n"
15409 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15410 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15411 "2:\t" ASM_CLAC "\n"
15412 "\t.section .fixup, \"ax\"\n"
15413 "3:\tmov %3, %0\n"
15414 "\tjmp 2b\n"
15415 "\t.previous\n"
15416 _ASM_EXTABLE(1b, 3b)
15417 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15418 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15419 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15420 : "memory"
15421 );
15422 + pax_close_userland();
15423
15424 *uval = oldval;
15425 return ret;
15426 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15427 index 92b3bae..3866449 100644
15428 --- a/arch/x86/include/asm/hw_irq.h
15429 +++ b/arch/x86/include/asm/hw_irq.h
15430 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15431 extern void enable_IO_APIC(void);
15432
15433 /* Statistics */
15434 -extern atomic_t irq_err_count;
15435 -extern atomic_t irq_mis_count;
15436 +extern atomic_unchecked_t irq_err_count;
15437 +extern atomic_unchecked_t irq_mis_count;
15438
15439 /* EISA */
15440 extern void eisa_set_level_irq(unsigned int irq);
15441 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15442 index a203659..9889f1c 100644
15443 --- a/arch/x86/include/asm/i8259.h
15444 +++ b/arch/x86/include/asm/i8259.h
15445 @@ -62,7 +62,7 @@ struct legacy_pic {
15446 void (*init)(int auto_eoi);
15447 int (*irq_pending)(unsigned int irq);
15448 void (*make_irq)(unsigned int irq);
15449 -};
15450 +} __do_const;
15451
15452 extern struct legacy_pic *legacy_pic;
15453 extern struct legacy_pic null_legacy_pic;
15454 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15455 index 34f69cb..6d95446 100644
15456 --- a/arch/x86/include/asm/io.h
15457 +++ b/arch/x86/include/asm/io.h
15458 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15459 "m" (*(volatile type __force *)addr) barrier); }
15460
15461 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15462 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15463 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15464 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15465 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15466
15467 build_mmio_read(__readb, "b", unsigned char, "=q", )
15468 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15469 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15470 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15471 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15472
15473 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15474 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15475 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15476 return ioremap_nocache(offset, size);
15477 }
15478
15479 -extern void iounmap(volatile void __iomem *addr);
15480 +extern void iounmap(const volatile void __iomem *addr);
15481
15482 extern void set_iounmap_nonlazy(void);
15483
15484 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15485
15486 #include <linux/vmalloc.h>
15487
15488 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15489 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15490 +{
15491 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15492 +}
15493 +
15494 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15495 +{
15496 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15497 +}
15498 +
15499 /*
15500 * Convert a virtual cached pointer to an uncached pointer
15501 */
15502 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15503 index bba3cf8..06bc8da 100644
15504 --- a/arch/x86/include/asm/irqflags.h
15505 +++ b/arch/x86/include/asm/irqflags.h
15506 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15507 sti; \
15508 sysexit
15509
15510 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15511 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15512 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15513 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15514 +
15515 #else
15516 #define INTERRUPT_RETURN iret
15517 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15518 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15519 index 9454c16..e4100e3 100644
15520 --- a/arch/x86/include/asm/kprobes.h
15521 +++ b/arch/x86/include/asm/kprobes.h
15522 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15523 #define RELATIVEJUMP_SIZE 5
15524 #define RELATIVECALL_OPCODE 0xe8
15525 #define RELATIVE_ADDR_SIZE 4
15526 -#define MAX_STACK_SIZE 64
15527 -#define MIN_STACK_SIZE(ADDR) \
15528 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15529 - THREAD_SIZE - (unsigned long)(ADDR))) \
15530 - ? (MAX_STACK_SIZE) \
15531 - : (((unsigned long)current_thread_info()) + \
15532 - THREAD_SIZE - (unsigned long)(ADDR)))
15533 +#define MAX_STACK_SIZE 64UL
15534 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15535
15536 #define flush_insn_slot(p) do { } while (0)
15537
15538 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15539 index 2d89e39..baee879 100644
15540 --- a/arch/x86/include/asm/local.h
15541 +++ b/arch/x86/include/asm/local.h
15542 @@ -10,33 +10,97 @@ typedef struct {
15543 atomic_long_t a;
15544 } local_t;
15545
15546 +typedef struct {
15547 + atomic_long_unchecked_t a;
15548 +} local_unchecked_t;
15549 +
15550 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15551
15552 #define local_read(l) atomic_long_read(&(l)->a)
15553 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15554 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15555 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15556
15557 static inline void local_inc(local_t *l)
15558 {
15559 - asm volatile(_ASM_INC "%0"
15560 + asm volatile(_ASM_INC "%0\n"
15561 +
15562 +#ifdef CONFIG_PAX_REFCOUNT
15563 + "jno 0f\n"
15564 + _ASM_DEC "%0\n"
15565 + "int $4\n0:\n"
15566 + _ASM_EXTABLE(0b, 0b)
15567 +#endif
15568 +
15569 + : "+m" (l->a.counter));
15570 +}
15571 +
15572 +static inline void local_inc_unchecked(local_unchecked_t *l)
15573 +{
15574 + asm volatile(_ASM_INC "%0\n"
15575 : "+m" (l->a.counter));
15576 }
15577
15578 static inline void local_dec(local_t *l)
15579 {
15580 - asm volatile(_ASM_DEC "%0"
15581 + asm volatile(_ASM_DEC "%0\n"
15582 +
15583 +#ifdef CONFIG_PAX_REFCOUNT
15584 + "jno 0f\n"
15585 + _ASM_INC "%0\n"
15586 + "int $4\n0:\n"
15587 + _ASM_EXTABLE(0b, 0b)
15588 +#endif
15589 +
15590 + : "+m" (l->a.counter));
15591 +}
15592 +
15593 +static inline void local_dec_unchecked(local_unchecked_t *l)
15594 +{
15595 + asm volatile(_ASM_DEC "%0\n"
15596 : "+m" (l->a.counter));
15597 }
15598
15599 static inline void local_add(long i, local_t *l)
15600 {
15601 - asm volatile(_ASM_ADD "%1,%0"
15602 + asm volatile(_ASM_ADD "%1,%0\n"
15603 +
15604 +#ifdef CONFIG_PAX_REFCOUNT
15605 + "jno 0f\n"
15606 + _ASM_SUB "%1,%0\n"
15607 + "int $4\n0:\n"
15608 + _ASM_EXTABLE(0b, 0b)
15609 +#endif
15610 +
15611 + : "+m" (l->a.counter)
15612 + : "ir" (i));
15613 +}
15614 +
15615 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15616 +{
15617 + asm volatile(_ASM_ADD "%1,%0\n"
15618 : "+m" (l->a.counter)
15619 : "ir" (i));
15620 }
15621
15622 static inline void local_sub(long i, local_t *l)
15623 {
15624 - asm volatile(_ASM_SUB "%1,%0"
15625 + asm volatile(_ASM_SUB "%1,%0\n"
15626 +
15627 +#ifdef CONFIG_PAX_REFCOUNT
15628 + "jno 0f\n"
15629 + _ASM_ADD "%1,%0\n"
15630 + "int $4\n0:\n"
15631 + _ASM_EXTABLE(0b, 0b)
15632 +#endif
15633 +
15634 + : "+m" (l->a.counter)
15635 + : "ir" (i));
15636 +}
15637 +
15638 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15639 +{
15640 + asm volatile(_ASM_SUB "%1,%0\n"
15641 : "+m" (l->a.counter)
15642 : "ir" (i));
15643 }
15644 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15645 {
15646 unsigned char c;
15647
15648 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15649 + asm volatile(_ASM_SUB "%2,%0\n"
15650 +
15651 +#ifdef CONFIG_PAX_REFCOUNT
15652 + "jno 0f\n"
15653 + _ASM_ADD "%2,%0\n"
15654 + "int $4\n0:\n"
15655 + _ASM_EXTABLE(0b, 0b)
15656 +#endif
15657 +
15658 + "sete %1\n"
15659 : "+m" (l->a.counter), "=qm" (c)
15660 : "ir" (i) : "memory");
15661 return c;
15662 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15663 {
15664 unsigned char c;
15665
15666 - asm volatile(_ASM_DEC "%0; sete %1"
15667 + asm volatile(_ASM_DEC "%0\n"
15668 +
15669 +#ifdef CONFIG_PAX_REFCOUNT
15670 + "jno 0f\n"
15671 + _ASM_INC "%0\n"
15672 + "int $4\n0:\n"
15673 + _ASM_EXTABLE(0b, 0b)
15674 +#endif
15675 +
15676 + "sete %1\n"
15677 : "+m" (l->a.counter), "=qm" (c)
15678 : : "memory");
15679 return c != 0;
15680 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15681 {
15682 unsigned char c;
15683
15684 - asm volatile(_ASM_INC "%0; sete %1"
15685 + asm volatile(_ASM_INC "%0\n"
15686 +
15687 +#ifdef CONFIG_PAX_REFCOUNT
15688 + "jno 0f\n"
15689 + _ASM_DEC "%0\n"
15690 + "int $4\n0:\n"
15691 + _ASM_EXTABLE(0b, 0b)
15692 +#endif
15693 +
15694 + "sete %1\n"
15695 : "+m" (l->a.counter), "=qm" (c)
15696 : : "memory");
15697 return c != 0;
15698 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15699 {
15700 unsigned char c;
15701
15702 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15703 + asm volatile(_ASM_ADD "%2,%0\n"
15704 +
15705 +#ifdef CONFIG_PAX_REFCOUNT
15706 + "jno 0f\n"
15707 + _ASM_SUB "%2,%0\n"
15708 + "int $4\n0:\n"
15709 + _ASM_EXTABLE(0b, 0b)
15710 +#endif
15711 +
15712 + "sets %1\n"
15713 : "+m" (l->a.counter), "=qm" (c)
15714 : "ir" (i) : "memory");
15715 return c;
15716 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15717 static inline long local_add_return(long i, local_t *l)
15718 {
15719 long __i = i;
15720 + asm volatile(_ASM_XADD "%0, %1\n"
15721 +
15722 +#ifdef CONFIG_PAX_REFCOUNT
15723 + "jno 0f\n"
15724 + _ASM_MOV "%0,%1\n"
15725 + "int $4\n0:\n"
15726 + _ASM_EXTABLE(0b, 0b)
15727 +#endif
15728 +
15729 + : "+r" (i), "+m" (l->a.counter)
15730 + : : "memory");
15731 + return i + __i;
15732 +}
15733 +
15734 +/**
15735 + * local_add_return_unchecked - add and return
15736 + * @i: integer value to add
15737 + * @l: pointer to type local_unchecked_t
15738 + *
15739 + * Atomically adds @i to @l and returns @i + @l
15740 + */
15741 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15742 +{
15743 + long __i = i;
15744 asm volatile(_ASM_XADD "%0, %1;"
15745 : "+r" (i), "+m" (l->a.counter)
15746 : : "memory");
15747 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15748
15749 #define local_cmpxchg(l, o, n) \
15750 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15751 +#define local_cmpxchg_unchecked(l, o, n) \
15752 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15753 /* Always has a lock prefix */
15754 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15755
15756 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15757 new file mode 100644
15758 index 0000000..2bfd3ba
15759 --- /dev/null
15760 +++ b/arch/x86/include/asm/mman.h
15761 @@ -0,0 +1,15 @@
15762 +#ifndef _X86_MMAN_H
15763 +#define _X86_MMAN_H
15764 +
15765 +#include <uapi/asm/mman.h>
15766 +
15767 +#ifdef __KERNEL__
15768 +#ifndef __ASSEMBLY__
15769 +#ifdef CONFIG_X86_32
15770 +#define arch_mmap_check i386_mmap_check
15771 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15772 +#endif
15773 +#endif
15774 +#endif
15775 +
15776 +#endif /* X86_MMAN_H */
15777 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15778 index 5f55e69..e20bfb1 100644
15779 --- a/arch/x86/include/asm/mmu.h
15780 +++ b/arch/x86/include/asm/mmu.h
15781 @@ -9,7 +9,7 @@
15782 * we put the segment information here.
15783 */
15784 typedef struct {
15785 - void *ldt;
15786 + struct desc_struct *ldt;
15787 int size;
15788
15789 #ifdef CONFIG_X86_64
15790 @@ -18,7 +18,19 @@ typedef struct {
15791 #endif
15792
15793 struct mutex lock;
15794 - void *vdso;
15795 + unsigned long vdso;
15796 +
15797 +#ifdef CONFIG_X86_32
15798 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15799 + unsigned long user_cs_base;
15800 + unsigned long user_cs_limit;
15801 +
15802 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15803 + cpumask_t cpu_user_cs_mask;
15804 +#endif
15805 +
15806 +#endif
15807 +#endif
15808 } mm_context_t;
15809
15810 #ifdef CONFIG_SMP
15811 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15812 index be12c53..4d24039 100644
15813 --- a/arch/x86/include/asm/mmu_context.h
15814 +++ b/arch/x86/include/asm/mmu_context.h
15815 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15816
15817 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15818 {
15819 +
15820 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15821 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15822 + unsigned int i;
15823 + pgd_t *pgd;
15824 +
15825 + pax_open_kernel();
15826 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15827 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15828 + set_pgd_batched(pgd+i, native_make_pgd(0));
15829 + pax_close_kernel();
15830 + }
15831 +#endif
15832 +
15833 #ifdef CONFIG_SMP
15834 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15835 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15836 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15837 struct task_struct *tsk)
15838 {
15839 unsigned cpu = smp_processor_id();
15840 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15841 + int tlbstate = TLBSTATE_OK;
15842 +#endif
15843
15844 if (likely(prev != next)) {
15845 #ifdef CONFIG_SMP
15846 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15847 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15848 +#endif
15849 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15850 this_cpu_write(cpu_tlbstate.active_mm, next);
15851 #endif
15852 cpumask_set_cpu(cpu, mm_cpumask(next));
15853
15854 /* Re-load page tables */
15855 +#ifdef CONFIG_PAX_PER_CPU_PGD
15856 + pax_open_kernel();
15857 +
15858 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15859 + if (static_cpu_has(X86_FEATURE_PCID))
15860 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15861 + else
15862 +#endif
15863 +
15864 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15865 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15866 + pax_close_kernel();
15867 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15868 +
15869 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15870 + if (static_cpu_has(X86_FEATURE_PCID)) {
15871 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15872 + u64 descriptor[2];
15873 + descriptor[0] = PCID_USER;
15874 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15875 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15876 + descriptor[0] = PCID_KERNEL;
15877 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15878 + }
15879 + } else {
15880 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15881 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15882 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15883 + else
15884 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15885 + }
15886 + } else
15887 +#endif
15888 +
15889 + load_cr3(get_cpu_pgd(cpu, kernel));
15890 +#else
15891 load_cr3(next->pgd);
15892 +#endif
15893
15894 /* Stop flush ipis for the previous mm */
15895 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15896 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15897 /* Load the LDT, if the LDT is different: */
15898 if (unlikely(prev->context.ldt != next->context.ldt))
15899 load_LDT_nolock(&next->context);
15900 +
15901 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15902 + if (!(__supported_pte_mask & _PAGE_NX)) {
15903 + smp_mb__before_clear_bit();
15904 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15905 + smp_mb__after_clear_bit();
15906 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15907 + }
15908 +#endif
15909 +
15910 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15911 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15912 + prev->context.user_cs_limit != next->context.user_cs_limit))
15913 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15914 +#ifdef CONFIG_SMP
15915 + else if (unlikely(tlbstate != TLBSTATE_OK))
15916 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15917 +#endif
15918 +#endif
15919 +
15920 }
15921 + else {
15922 +
15923 +#ifdef CONFIG_PAX_PER_CPU_PGD
15924 + pax_open_kernel();
15925 +
15926 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15927 + if (static_cpu_has(X86_FEATURE_PCID))
15928 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15929 + else
15930 +#endif
15931 +
15932 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15933 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15934 + pax_close_kernel();
15935 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15936 +
15937 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15938 + if (static_cpu_has(X86_FEATURE_PCID)) {
15939 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15940 + u64 descriptor[2];
15941 + descriptor[0] = PCID_USER;
15942 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15943 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15944 + descriptor[0] = PCID_KERNEL;
15945 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15946 + }
15947 + } else {
15948 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15949 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15950 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15951 + else
15952 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15953 + }
15954 + } else
15955 +#endif
15956 +
15957 + load_cr3(get_cpu_pgd(cpu, kernel));
15958 +#endif
15959 +
15960 #ifdef CONFIG_SMP
15961 - else {
15962 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15963 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15964
15965 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15966 * tlb flush IPI delivery. We must reload CR3
15967 * to make sure to use no freed page tables.
15968 */
15969 +
15970 +#ifndef CONFIG_PAX_PER_CPU_PGD
15971 load_cr3(next->pgd);
15972 +#endif
15973 +
15974 load_LDT_nolock(&next->context);
15975 +
15976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15977 + if (!(__supported_pte_mask & _PAGE_NX))
15978 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15979 +#endif
15980 +
15981 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15982 +#ifdef CONFIG_PAX_PAGEEXEC
15983 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15984 +#endif
15985 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15986 +#endif
15987 +
15988 }
15989 +#endif
15990 }
15991 -#endif
15992 }
15993
15994 #define activate_mm(prev, next) \
15995 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15996 index e3b7819..b257c64 100644
15997 --- a/arch/x86/include/asm/module.h
15998 +++ b/arch/x86/include/asm/module.h
15999 @@ -5,6 +5,7 @@
16000
16001 #ifdef CONFIG_X86_64
16002 /* X86_64 does not define MODULE_PROC_FAMILY */
16003 +#define MODULE_PROC_FAMILY ""
16004 #elif defined CONFIG_M486
16005 #define MODULE_PROC_FAMILY "486 "
16006 #elif defined CONFIG_M586
16007 @@ -57,8 +58,20 @@
16008 #error unknown processor family
16009 #endif
16010
16011 -#ifdef CONFIG_X86_32
16012 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16013 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16014 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16015 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16016 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16017 +#else
16018 +#define MODULE_PAX_KERNEXEC ""
16019 #endif
16020
16021 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16022 +#define MODULE_PAX_UDEREF "UDEREF "
16023 +#else
16024 +#define MODULE_PAX_UDEREF ""
16025 +#endif
16026 +
16027 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16028 +
16029 #endif /* _ASM_X86_MODULE_H */
16030 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16031 index 86f9301..b365cda 100644
16032 --- a/arch/x86/include/asm/nmi.h
16033 +++ b/arch/x86/include/asm/nmi.h
16034 @@ -40,11 +40,11 @@ struct nmiaction {
16035 nmi_handler_t handler;
16036 unsigned long flags;
16037 const char *name;
16038 -};
16039 +} __do_const;
16040
16041 #define register_nmi_handler(t, fn, fg, n, init...) \
16042 ({ \
16043 - static struct nmiaction init fn##_na = { \
16044 + static const struct nmiaction init fn##_na = { \
16045 .handler = (fn), \
16046 .name = (n), \
16047 .flags = (fg), \
16048 @@ -52,7 +52,7 @@ struct nmiaction {
16049 __register_nmi_handler((t), &fn##_na); \
16050 })
16051
16052 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16053 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16054
16055 void unregister_nmi_handler(unsigned int, const char *);
16056
16057 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16058 index c878924..21f4889 100644
16059 --- a/arch/x86/include/asm/page.h
16060 +++ b/arch/x86/include/asm/page.h
16061 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16062 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16063
16064 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16065 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16066
16067 #define __boot_va(x) __va(x)
16068 #define __boot_pa(x) __pa(x)
16069 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16070 index 0f1ddee..e2fc3d1 100644
16071 --- a/arch/x86/include/asm/page_64.h
16072 +++ b/arch/x86/include/asm/page_64.h
16073 @@ -7,9 +7,9 @@
16074
16075 /* duplicated to the one in bootmem.h */
16076 extern unsigned long max_pfn;
16077 -extern unsigned long phys_base;
16078 +extern const unsigned long phys_base;
16079
16080 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16081 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16082 {
16083 unsigned long y = x - __START_KERNEL_map;
16084
16085 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16086 index 401f350..dee5d13 100644
16087 --- a/arch/x86/include/asm/paravirt.h
16088 +++ b/arch/x86/include/asm/paravirt.h
16089 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16090 return (pmd_t) { ret };
16091 }
16092
16093 -static inline pmdval_t pmd_val(pmd_t pmd)
16094 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16095 {
16096 pmdval_t ret;
16097
16098 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16099 val);
16100 }
16101
16102 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16103 +{
16104 + pgdval_t val = native_pgd_val(pgd);
16105 +
16106 + if (sizeof(pgdval_t) > sizeof(long))
16107 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16108 + val, (u64)val >> 32);
16109 + else
16110 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16111 + val);
16112 +}
16113 +
16114 static inline void pgd_clear(pgd_t *pgdp)
16115 {
16116 set_pgd(pgdp, __pgd(0));
16117 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16118 pv_mmu_ops.set_fixmap(idx, phys, flags);
16119 }
16120
16121 +#ifdef CONFIG_PAX_KERNEXEC
16122 +static inline unsigned long pax_open_kernel(void)
16123 +{
16124 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16125 +}
16126 +
16127 +static inline unsigned long pax_close_kernel(void)
16128 +{
16129 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16130 +}
16131 +#else
16132 +static inline unsigned long pax_open_kernel(void) { return 0; }
16133 +static inline unsigned long pax_close_kernel(void) { return 0; }
16134 +#endif
16135 +
16136 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16137
16138 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16139 @@ -906,7 +933,7 @@ extern void default_banner(void);
16140
16141 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16142 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16143 -#define PARA_INDIRECT(addr) *%cs:addr
16144 +#define PARA_INDIRECT(addr) *%ss:addr
16145 #endif
16146
16147 #define INTERRUPT_RETURN \
16148 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16149 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16150 CLBR_NONE, \
16151 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16152 +
16153 +#define GET_CR0_INTO_RDI \
16154 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16155 + mov %rax,%rdi
16156 +
16157 +#define SET_RDI_INTO_CR0 \
16158 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16159 +
16160 +#define GET_CR3_INTO_RDI \
16161 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16162 + mov %rax,%rdi
16163 +
16164 +#define SET_RDI_INTO_CR3 \
16165 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16166 +
16167 #endif /* CONFIG_X86_32 */
16168
16169 #endif /* __ASSEMBLY__ */
16170 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16171 index aab8f67..2531748 100644
16172 --- a/arch/x86/include/asm/paravirt_types.h
16173 +++ b/arch/x86/include/asm/paravirt_types.h
16174 @@ -84,7 +84,7 @@ struct pv_init_ops {
16175 */
16176 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16177 unsigned long addr, unsigned len);
16178 -};
16179 +} __no_const;
16180
16181
16182 struct pv_lazy_ops {
16183 @@ -98,7 +98,7 @@ struct pv_time_ops {
16184 unsigned long long (*sched_clock)(void);
16185 unsigned long long (*steal_clock)(int cpu);
16186 unsigned long (*get_tsc_khz)(void);
16187 -};
16188 +} __no_const;
16189
16190 struct pv_cpu_ops {
16191 /* hooks for various privileged instructions */
16192 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16193
16194 void (*start_context_switch)(struct task_struct *prev);
16195 void (*end_context_switch)(struct task_struct *next);
16196 -};
16197 +} __no_const;
16198
16199 struct pv_irq_ops {
16200 /*
16201 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16202 unsigned long start_eip,
16203 unsigned long start_esp);
16204 #endif
16205 -};
16206 +} __no_const;
16207
16208 struct pv_mmu_ops {
16209 unsigned long (*read_cr2)(void);
16210 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16211 struct paravirt_callee_save make_pud;
16212
16213 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16214 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16215 #endif /* PAGETABLE_LEVELS == 4 */
16216 #endif /* PAGETABLE_LEVELS >= 3 */
16217
16218 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16219 an mfn. We can tell which is which from the index. */
16220 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16221 phys_addr_t phys, pgprot_t flags);
16222 +
16223 +#ifdef CONFIG_PAX_KERNEXEC
16224 + unsigned long (*pax_open_kernel)(void);
16225 + unsigned long (*pax_close_kernel)(void);
16226 +#endif
16227 +
16228 };
16229
16230 struct arch_spinlock;
16231 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16232 index b4389a4..7024269 100644
16233 --- a/arch/x86/include/asm/pgalloc.h
16234 +++ b/arch/x86/include/asm/pgalloc.h
16235 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16236 pmd_t *pmd, pte_t *pte)
16237 {
16238 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16239 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16240 +}
16241 +
16242 +static inline void pmd_populate_user(struct mm_struct *mm,
16243 + pmd_t *pmd, pte_t *pte)
16244 +{
16245 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16246 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16247 }
16248
16249 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16250
16251 #ifdef CONFIG_X86_PAE
16252 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16253 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16254 +{
16255 + pud_populate(mm, pudp, pmd);
16256 +}
16257 #else /* !CONFIG_X86_PAE */
16258 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16259 {
16260 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16261 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16262 }
16263 +
16264 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16265 +{
16266 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16267 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16268 +}
16269 #endif /* CONFIG_X86_PAE */
16270
16271 #if PAGETABLE_LEVELS > 3
16272 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16273 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16274 }
16275
16276 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16277 +{
16278 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16279 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16280 +}
16281 +
16282 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16283 {
16284 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16285 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16286 index 3bf2dd0..23d2a9f 100644
16287 --- a/arch/x86/include/asm/pgtable-2level.h
16288 +++ b/arch/x86/include/asm/pgtable-2level.h
16289 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16290
16291 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16292 {
16293 + pax_open_kernel();
16294 *pmdp = pmd;
16295 + pax_close_kernel();
16296 }
16297
16298 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16299 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16300 index 81bb91b..9392125 100644
16301 --- a/arch/x86/include/asm/pgtable-3level.h
16302 +++ b/arch/x86/include/asm/pgtable-3level.h
16303 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16304
16305 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16306 {
16307 + pax_open_kernel();
16308 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16309 + pax_close_kernel();
16310 }
16311
16312 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16313 {
16314 + pax_open_kernel();
16315 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16316 + pax_close_kernel();
16317 }
16318
16319 /*
16320 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16321 index 3d19994..732a48c 100644
16322 --- a/arch/x86/include/asm/pgtable.h
16323 +++ b/arch/x86/include/asm/pgtable.h
16324 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16325
16326 #ifndef __PAGETABLE_PUD_FOLDED
16327 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16328 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16329 #define pgd_clear(pgd) native_pgd_clear(pgd)
16330 #endif
16331
16332 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16333
16334 #define arch_end_context_switch(prev) do {} while(0)
16335
16336 +#define pax_open_kernel() native_pax_open_kernel()
16337 +#define pax_close_kernel() native_pax_close_kernel()
16338 #endif /* CONFIG_PARAVIRT */
16339
16340 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16341 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16342 +
16343 +#ifdef CONFIG_PAX_KERNEXEC
16344 +static inline unsigned long native_pax_open_kernel(void)
16345 +{
16346 + unsigned long cr0;
16347 +
16348 + preempt_disable();
16349 + barrier();
16350 + cr0 = read_cr0() ^ X86_CR0_WP;
16351 + BUG_ON(cr0 & X86_CR0_WP);
16352 + write_cr0(cr0);
16353 + return cr0 ^ X86_CR0_WP;
16354 +}
16355 +
16356 +static inline unsigned long native_pax_close_kernel(void)
16357 +{
16358 + unsigned long cr0;
16359 +
16360 + cr0 = read_cr0() ^ X86_CR0_WP;
16361 + BUG_ON(!(cr0 & X86_CR0_WP));
16362 + write_cr0(cr0);
16363 + barrier();
16364 + preempt_enable_no_resched();
16365 + return cr0 ^ X86_CR0_WP;
16366 +}
16367 +#else
16368 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16369 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16370 +#endif
16371 +
16372 /*
16373 * The following only work if pte_present() is true.
16374 * Undefined behaviour if not..
16375 */
16376 +static inline int pte_user(pte_t pte)
16377 +{
16378 + return pte_val(pte) & _PAGE_USER;
16379 +}
16380 +
16381 static inline int pte_dirty(pte_t pte)
16382 {
16383 return pte_flags(pte) & _PAGE_DIRTY;
16384 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16385 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16386 }
16387
16388 +static inline unsigned long pgd_pfn(pgd_t pgd)
16389 +{
16390 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16391 +}
16392 +
16393 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16394
16395 static inline int pmd_large(pmd_t pte)
16396 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16397 return pte_clear_flags(pte, _PAGE_RW);
16398 }
16399
16400 +static inline pte_t pte_mkread(pte_t pte)
16401 +{
16402 + return __pte(pte_val(pte) | _PAGE_USER);
16403 +}
16404 +
16405 static inline pte_t pte_mkexec(pte_t pte)
16406 {
16407 - return pte_clear_flags(pte, _PAGE_NX);
16408 +#ifdef CONFIG_X86_PAE
16409 + if (__supported_pte_mask & _PAGE_NX)
16410 + return pte_clear_flags(pte, _PAGE_NX);
16411 + else
16412 +#endif
16413 + return pte_set_flags(pte, _PAGE_USER);
16414 +}
16415 +
16416 +static inline pte_t pte_exprotect(pte_t pte)
16417 +{
16418 +#ifdef CONFIG_X86_PAE
16419 + if (__supported_pte_mask & _PAGE_NX)
16420 + return pte_set_flags(pte, _PAGE_NX);
16421 + else
16422 +#endif
16423 + return pte_clear_flags(pte, _PAGE_USER);
16424 }
16425
16426 static inline pte_t pte_mkdirty(pte_t pte)
16427 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16428 #endif
16429
16430 #ifndef __ASSEMBLY__
16431 +
16432 +#ifdef CONFIG_PAX_PER_CPU_PGD
16433 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16434 +enum cpu_pgd_type {kernel = 0, user = 1};
16435 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16436 +{
16437 + return cpu_pgd[cpu][type];
16438 +}
16439 +#endif
16440 +
16441 #include <linux/mm_types.h>
16442 #include <linux/mmdebug.h>
16443 #include <linux/log2.h>
16444 @@ -563,7 +638,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16445 * Currently stuck as a macro due to indirect forward reference to
16446 * linux/mmzone.h's __section_mem_map_addr() definition:
16447 */
16448 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16449 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16450
16451 /* Find an entry in the second-level page table.. */
16452 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16453 @@ -603,7 +678,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16454 * Currently stuck as a macro due to indirect forward reference to
16455 * linux/mmzone.h's __section_mem_map_addr() definition:
16456 */
16457 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16458 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16459
16460 /* to find an entry in a page-table-directory. */
16461 static inline unsigned long pud_index(unsigned long address)
16462 @@ -618,7 +693,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16463
16464 static inline int pgd_bad(pgd_t pgd)
16465 {
16466 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16467 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16468 }
16469
16470 static inline int pgd_none(pgd_t pgd)
16471 @@ -641,7 +716,12 @@ static inline int pgd_none(pgd_t pgd)
16472 * pgd_offset() returns a (pgd_t *)
16473 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16474 */
16475 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16476 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16477 +
16478 +#ifdef CONFIG_PAX_PER_CPU_PGD
16479 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16480 +#endif
16481 +
16482 /*
16483 * a shortcut which implies the use of the kernel's pgd, instead
16484 * of a process's
16485 @@ -652,6 +732,23 @@ static inline int pgd_none(pgd_t pgd)
16486 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16487 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16488
16489 +#ifdef CONFIG_X86_32
16490 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16491 +#else
16492 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16493 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16494 +
16495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16496 +#ifdef __ASSEMBLY__
16497 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16498 +#else
16499 +extern unsigned long pax_user_shadow_base;
16500 +extern pgdval_t clone_pgd_mask;
16501 +#endif
16502 +#endif
16503 +
16504 +#endif
16505 +
16506 #ifndef __ASSEMBLY__
16507
16508 extern int direct_gbpages;
16509 @@ -818,11 +915,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16510 * dst and src can be on the same page, but the range must not overlap,
16511 * and must not cross a page boundary.
16512 */
16513 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16514 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16515 {
16516 - memcpy(dst, src, count * sizeof(pgd_t));
16517 + pax_open_kernel();
16518 + while (count--)
16519 + *dst++ = *src++;
16520 + pax_close_kernel();
16521 }
16522
16523 +#ifdef CONFIG_PAX_PER_CPU_PGD
16524 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16525 +#endif
16526 +
16527 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16528 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16529 +#else
16530 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16531 +#endif
16532 +
16533 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16534 static inline int page_level_shift(enum pg_level level)
16535 {
16536 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16537 index 9ee3221..b979c6b 100644
16538 --- a/arch/x86/include/asm/pgtable_32.h
16539 +++ b/arch/x86/include/asm/pgtable_32.h
16540 @@ -25,9 +25,6 @@
16541 struct mm_struct;
16542 struct vm_area_struct;
16543
16544 -extern pgd_t swapper_pg_dir[1024];
16545 -extern pgd_t initial_page_table[1024];
16546 -
16547 static inline void pgtable_cache_init(void) { }
16548 static inline void check_pgt_cache(void) { }
16549 void paging_init(void);
16550 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16551 # include <asm/pgtable-2level.h>
16552 #endif
16553
16554 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16555 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16556 +#ifdef CONFIG_X86_PAE
16557 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16558 +#endif
16559 +
16560 #if defined(CONFIG_HIGHPTE)
16561 #define pte_offset_map(dir, address) \
16562 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16563 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16564 /* Clear a kernel PTE and flush it from the TLB */
16565 #define kpte_clear_flush(ptep, vaddr) \
16566 do { \
16567 + pax_open_kernel(); \
16568 pte_clear(&init_mm, (vaddr), (ptep)); \
16569 + pax_close_kernel(); \
16570 __flush_tlb_one((vaddr)); \
16571 } while (0)
16572
16573 #endif /* !__ASSEMBLY__ */
16574
16575 +#define HAVE_ARCH_UNMAPPED_AREA
16576 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16577 +
16578 /*
16579 * kern_addr_valid() is (1) for FLATMEM and (0) for
16580 * SPARSEMEM and DISCONTIGMEM
16581 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16582 index ed5903b..c7fe163 100644
16583 --- a/arch/x86/include/asm/pgtable_32_types.h
16584 +++ b/arch/x86/include/asm/pgtable_32_types.h
16585 @@ -8,7 +8,7 @@
16586 */
16587 #ifdef CONFIG_X86_PAE
16588 # include <asm/pgtable-3level_types.h>
16589 -# define PMD_SIZE (1UL << PMD_SHIFT)
16590 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16591 # define PMD_MASK (~(PMD_SIZE - 1))
16592 #else
16593 # include <asm/pgtable-2level_types.h>
16594 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16595 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16596 #endif
16597
16598 +#ifdef CONFIG_PAX_KERNEXEC
16599 +#ifndef __ASSEMBLY__
16600 +extern unsigned char MODULES_EXEC_VADDR[];
16601 +extern unsigned char MODULES_EXEC_END[];
16602 +#endif
16603 +#include <asm/boot.h>
16604 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16605 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16606 +#else
16607 +#define ktla_ktva(addr) (addr)
16608 +#define ktva_ktla(addr) (addr)
16609 +#endif
16610 +
16611 #define MODULES_VADDR VMALLOC_START
16612 #define MODULES_END VMALLOC_END
16613 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16614 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16615 index e22c1db..23a625a 100644
16616 --- a/arch/x86/include/asm/pgtable_64.h
16617 +++ b/arch/x86/include/asm/pgtable_64.h
16618 @@ -16,10 +16,14 @@
16619
16620 extern pud_t level3_kernel_pgt[512];
16621 extern pud_t level3_ident_pgt[512];
16622 +extern pud_t level3_vmalloc_start_pgt[512];
16623 +extern pud_t level3_vmalloc_end_pgt[512];
16624 +extern pud_t level3_vmemmap_pgt[512];
16625 +extern pud_t level2_vmemmap_pgt[512];
16626 extern pmd_t level2_kernel_pgt[512];
16627 extern pmd_t level2_fixmap_pgt[512];
16628 -extern pmd_t level2_ident_pgt[512];
16629 -extern pgd_t init_level4_pgt[];
16630 +extern pmd_t level2_ident_pgt[512*2];
16631 +extern pgd_t init_level4_pgt[512];
16632
16633 #define swapper_pg_dir init_level4_pgt
16634
16635 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16636
16637 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16638 {
16639 + pax_open_kernel();
16640 *pmdp = pmd;
16641 + pax_close_kernel();
16642 }
16643
16644 static inline void native_pmd_clear(pmd_t *pmd)
16645 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16646
16647 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16648 {
16649 + pax_open_kernel();
16650 *pudp = pud;
16651 + pax_close_kernel();
16652 }
16653
16654 static inline void native_pud_clear(pud_t *pud)
16655 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16656
16657 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16658 {
16659 + pax_open_kernel();
16660 + *pgdp = pgd;
16661 + pax_close_kernel();
16662 +}
16663 +
16664 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16665 +{
16666 *pgdp = pgd;
16667 }
16668
16669 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16670 index 2d88344..4679fc3 100644
16671 --- a/arch/x86/include/asm/pgtable_64_types.h
16672 +++ b/arch/x86/include/asm/pgtable_64_types.h
16673 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16674 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16675 #define MODULES_END _AC(0xffffffffff000000, UL)
16676 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16677 +#define MODULES_EXEC_VADDR MODULES_VADDR
16678 +#define MODULES_EXEC_END MODULES_END
16679 +
16680 +#define ktla_ktva(addr) (addr)
16681 +#define ktva_ktla(addr) (addr)
16682
16683 #define EARLY_DYNAMIC_PAGE_TABLES 64
16684
16685 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16686 index 0ecac25..306c276 100644
16687 --- a/arch/x86/include/asm/pgtable_types.h
16688 +++ b/arch/x86/include/asm/pgtable_types.h
16689 @@ -16,13 +16,12 @@
16690 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16691 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16692 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16693 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16694 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16695 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16696 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16697 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16698 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16699 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16700 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16701 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16702 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16703 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16704
16705 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16706 @@ -40,7 +39,6 @@
16707 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16708 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16709 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16710 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16711 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16712 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16713 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16714 @@ -87,8 +85,10 @@
16715
16716 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16717 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16718 -#else
16719 +#elif defined(CONFIG_KMEMCHECK)
16720 #define _PAGE_NX (_AT(pteval_t, 0))
16721 +#else
16722 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16723 #endif
16724
16725 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16726 @@ -146,6 +146,9 @@
16727 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16728 _PAGE_ACCESSED)
16729
16730 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16731 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16732 +
16733 #define __PAGE_KERNEL_EXEC \
16734 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16735 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16736 @@ -156,7 +159,7 @@
16737 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16738 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16739 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16740 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16741 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16742 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16743 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16744 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16745 @@ -218,8 +221,8 @@
16746 * bits are combined, this will alow user to access the high address mapped
16747 * VDSO in the presence of CONFIG_COMPAT_VDSO
16748 */
16749 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16750 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16751 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16752 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16753 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16754 #endif
16755
16756 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16757 {
16758 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16759 }
16760 +#endif
16761
16762 +#if PAGETABLE_LEVELS == 3
16763 +#include <asm-generic/pgtable-nopud.h>
16764 +#endif
16765 +
16766 +#if PAGETABLE_LEVELS == 2
16767 +#include <asm-generic/pgtable-nopmd.h>
16768 +#endif
16769 +
16770 +#ifndef __ASSEMBLY__
16771 #if PAGETABLE_LEVELS > 3
16772 typedef struct { pudval_t pud; } pud_t;
16773
16774 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16775 return pud.pud;
16776 }
16777 #else
16778 -#include <asm-generic/pgtable-nopud.h>
16779 -
16780 static inline pudval_t native_pud_val(pud_t pud)
16781 {
16782 return native_pgd_val(pud.pgd);
16783 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16784 return pmd.pmd;
16785 }
16786 #else
16787 -#include <asm-generic/pgtable-nopmd.h>
16788 -
16789 static inline pmdval_t native_pmd_val(pmd_t pmd)
16790 {
16791 return native_pgd_val(pmd.pud.pgd);
16792 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
16793
16794 extern pteval_t __supported_pte_mask;
16795 extern void set_nx(void);
16796 -extern int nx_enabled;
16797
16798 #define pgprot_writecombine pgprot_writecombine
16799 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16800 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16801 index 987c75e..2723054 100644
16802 --- a/arch/x86/include/asm/processor.h
16803 +++ b/arch/x86/include/asm/processor.h
16804 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16805 : "memory");
16806 }
16807
16808 +/* invpcid (%rdx),%rax */
16809 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16810 +
16811 +#define INVPCID_SINGLE_ADDRESS 0UL
16812 +#define INVPCID_SINGLE_CONTEXT 1UL
16813 +#define INVPCID_ALL_GLOBAL 2UL
16814 +#define INVPCID_ALL_MONGLOBAL 3UL
16815 +
16816 +#define PCID_KERNEL 0UL
16817 +#define PCID_USER 1UL
16818 +#define PCID_NOFLUSH (1UL << 63)
16819 +
16820 static inline void load_cr3(pgd_t *pgdir)
16821 {
16822 - write_cr3(__pa(pgdir));
16823 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16824 }
16825
16826 #ifdef CONFIG_X86_32
16827 @@ -283,7 +295,7 @@ struct tss_struct {
16828
16829 } ____cacheline_aligned;
16830
16831 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16832 +extern struct tss_struct init_tss[NR_CPUS];
16833
16834 /*
16835 * Save the original ist values for checking stack pointers during debugging
16836 @@ -453,6 +465,7 @@ struct thread_struct {
16837 unsigned short ds;
16838 unsigned short fsindex;
16839 unsigned short gsindex;
16840 + unsigned short ss;
16841 #endif
16842 #ifdef CONFIG_X86_32
16843 unsigned long ip;
16844 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16845 extern unsigned long mmu_cr4_features;
16846 extern u32 *trampoline_cr4_features;
16847
16848 -static inline void set_in_cr4(unsigned long mask)
16849 -{
16850 - unsigned long cr4;
16851 -
16852 - mmu_cr4_features |= mask;
16853 - if (trampoline_cr4_features)
16854 - *trampoline_cr4_features = mmu_cr4_features;
16855 - cr4 = read_cr4();
16856 - cr4 |= mask;
16857 - write_cr4(cr4);
16858 -}
16859 -
16860 -static inline void clear_in_cr4(unsigned long mask)
16861 -{
16862 - unsigned long cr4;
16863 -
16864 - mmu_cr4_features &= ~mask;
16865 - if (trampoline_cr4_features)
16866 - *trampoline_cr4_features = mmu_cr4_features;
16867 - cr4 = read_cr4();
16868 - cr4 &= ~mask;
16869 - write_cr4(cr4);
16870 -}
16871 +extern void set_in_cr4(unsigned long mask);
16872 +extern void clear_in_cr4(unsigned long mask);
16873
16874 typedef struct {
16875 unsigned long seg;
16876 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16877 */
16878 #define TASK_SIZE PAGE_OFFSET
16879 #define TASK_SIZE_MAX TASK_SIZE
16880 +
16881 +#ifdef CONFIG_PAX_SEGMEXEC
16882 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16883 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16884 +#else
16885 #define STACK_TOP TASK_SIZE
16886 -#define STACK_TOP_MAX STACK_TOP
16887 +#endif
16888 +
16889 +#define STACK_TOP_MAX TASK_SIZE
16890
16891 #define INIT_THREAD { \
16892 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16893 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16894 .vm86_info = NULL, \
16895 .sysenter_cs = __KERNEL_CS, \
16896 .io_bitmap_ptr = NULL, \
16897 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16898 */
16899 #define INIT_TSS { \
16900 .x86_tss = { \
16901 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16902 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16903 .ss0 = __KERNEL_DS, \
16904 .ss1 = __KERNEL_CS, \
16905 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16906 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16907 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16908
16909 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16910 -#define KSTK_TOP(info) \
16911 -({ \
16912 - unsigned long *__ptr = (unsigned long *)(info); \
16913 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16914 -})
16915 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16916
16917 /*
16918 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16919 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16920 #define task_pt_regs(task) \
16921 ({ \
16922 struct pt_regs *__regs__; \
16923 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16924 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16925 __regs__ - 1; \
16926 })
16927
16928 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16929 /*
16930 * User space process size. 47bits minus one guard page.
16931 */
16932 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16933 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16934
16935 /* This decides where the kernel will search for a free chunk of vm
16936 * space during mmap's.
16937 */
16938 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16939 - 0xc0000000 : 0xFFFFe000)
16940 + 0xc0000000 : 0xFFFFf000)
16941
16942 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16943 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16944 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16945 #define STACK_TOP_MAX TASK_SIZE_MAX
16946
16947 #define INIT_THREAD { \
16948 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16949 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16950 }
16951
16952 #define INIT_TSS { \
16953 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16954 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16955 }
16956
16957 /*
16958 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16959 */
16960 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16961
16962 +#ifdef CONFIG_PAX_SEGMEXEC
16963 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16964 +#endif
16965 +
16966 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16967
16968 /* Get/set a process' ability to use the timestamp counter instruction */
16969 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
16970 return 0;
16971 }
16972
16973 -extern unsigned long arch_align_stack(unsigned long sp);
16974 +#define arch_align_stack(x) ((x) & ~0xfUL)
16975 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16976
16977 void default_idle(void);
16978 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
16979 #define xen_set_default_idle 0
16980 #endif
16981
16982 -void stop_this_cpu(void *dummy);
16983 +void stop_this_cpu(void *dummy) __noreturn;
16984 void df_debug(struct pt_regs *regs, long error_code);
16985 #endif /* _ASM_X86_PROCESSOR_H */
16986 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16987 index 942a086..6c26446 100644
16988 --- a/arch/x86/include/asm/ptrace.h
16989 +++ b/arch/x86/include/asm/ptrace.h
16990 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16991 }
16992
16993 /*
16994 - * user_mode_vm(regs) determines whether a register set came from user mode.
16995 + * user_mode(regs) determines whether a register set came from user mode.
16996 * This is true if V8086 mode was enabled OR if the register set was from
16997 * protected mode with RPL-3 CS value. This tricky test checks that with
16998 * one comparison. Many places in the kernel can bypass this full check
16999 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17000 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17001 + * be used.
17002 */
17003 -static inline int user_mode(struct pt_regs *regs)
17004 +static inline int user_mode_novm(struct pt_regs *regs)
17005 {
17006 #ifdef CONFIG_X86_32
17007 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17008 #else
17009 - return !!(regs->cs & 3);
17010 + return !!(regs->cs & SEGMENT_RPL_MASK);
17011 #endif
17012 }
17013
17014 -static inline int user_mode_vm(struct pt_regs *regs)
17015 +static inline int user_mode(struct pt_regs *regs)
17016 {
17017 #ifdef CONFIG_X86_32
17018 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17019 USER_RPL;
17020 #else
17021 - return user_mode(regs);
17022 + return user_mode_novm(regs);
17023 #endif
17024 }
17025
17026 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17027 #ifdef CONFIG_X86_64
17028 static inline bool user_64bit_mode(struct pt_regs *regs)
17029 {
17030 + unsigned long cs = regs->cs & 0xffff;
17031 #ifndef CONFIG_PARAVIRT
17032 /*
17033 * On non-paravirt systems, this is the only long mode CPL 3
17034 * selector. We do not allow long mode selectors in the LDT.
17035 */
17036 - return regs->cs == __USER_CS;
17037 + return cs == __USER_CS;
17038 #else
17039 /* Headers are too twisted for this to go in paravirt.h. */
17040 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17041 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17042 #endif
17043 }
17044
17045 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17046 * Traps from the kernel do not save sp and ss.
17047 * Use the helper function to retrieve sp.
17048 */
17049 - if (offset == offsetof(struct pt_regs, sp) &&
17050 - regs->cs == __KERNEL_CS)
17051 - return kernel_stack_pointer(regs);
17052 + if (offset == offsetof(struct pt_regs, sp)) {
17053 + unsigned long cs = regs->cs & 0xffff;
17054 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17055 + return kernel_stack_pointer(regs);
17056 + }
17057 #endif
17058 return *(unsigned long *)((unsigned long)regs + offset);
17059 }
17060 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17061 index 9c6b890..5305f53 100644
17062 --- a/arch/x86/include/asm/realmode.h
17063 +++ b/arch/x86/include/asm/realmode.h
17064 @@ -22,16 +22,14 @@ struct real_mode_header {
17065 #endif
17066 /* APM/BIOS reboot */
17067 u32 machine_real_restart_asm;
17068 -#ifdef CONFIG_X86_64
17069 u32 machine_real_restart_seg;
17070 -#endif
17071 };
17072
17073 /* This must match data at trampoline_32/64.S */
17074 struct trampoline_header {
17075 #ifdef CONFIG_X86_32
17076 u32 start;
17077 - u16 gdt_pad;
17078 + u16 boot_cs;
17079 u16 gdt_limit;
17080 u32 gdt_base;
17081 #else
17082 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17083 index a82c4f1..ac45053 100644
17084 --- a/arch/x86/include/asm/reboot.h
17085 +++ b/arch/x86/include/asm/reboot.h
17086 @@ -6,13 +6,13 @@
17087 struct pt_regs;
17088
17089 struct machine_ops {
17090 - void (*restart)(char *cmd);
17091 - void (*halt)(void);
17092 - void (*power_off)(void);
17093 + void (* __noreturn restart)(char *cmd);
17094 + void (* __noreturn halt)(void);
17095 + void (* __noreturn power_off)(void);
17096 void (*shutdown)(void);
17097 void (*crash_shutdown)(struct pt_regs *);
17098 - void (*emergency_restart)(void);
17099 -};
17100 + void (* __noreturn emergency_restart)(void);
17101 +} __no_const;
17102
17103 extern struct machine_ops machine_ops;
17104
17105 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17106 index cad82c9..2e5c5c1 100644
17107 --- a/arch/x86/include/asm/rwsem.h
17108 +++ b/arch/x86/include/asm/rwsem.h
17109 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17110 {
17111 asm volatile("# beginning down_read\n\t"
17112 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17113 +
17114 +#ifdef CONFIG_PAX_REFCOUNT
17115 + "jno 0f\n"
17116 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17117 + "int $4\n0:\n"
17118 + _ASM_EXTABLE(0b, 0b)
17119 +#endif
17120 +
17121 /* adds 0x00000001 */
17122 " jns 1f\n"
17123 " call call_rwsem_down_read_failed\n"
17124 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17125 "1:\n\t"
17126 " mov %1,%2\n\t"
17127 " add %3,%2\n\t"
17128 +
17129 +#ifdef CONFIG_PAX_REFCOUNT
17130 + "jno 0f\n"
17131 + "sub %3,%2\n"
17132 + "int $4\n0:\n"
17133 + _ASM_EXTABLE(0b, 0b)
17134 +#endif
17135 +
17136 " jle 2f\n\t"
17137 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17138 " jnz 1b\n\t"
17139 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17140 long tmp;
17141 asm volatile("# beginning down_write\n\t"
17142 LOCK_PREFIX " xadd %1,(%2)\n\t"
17143 +
17144 +#ifdef CONFIG_PAX_REFCOUNT
17145 + "jno 0f\n"
17146 + "mov %1,(%2)\n"
17147 + "int $4\n0:\n"
17148 + _ASM_EXTABLE(0b, 0b)
17149 +#endif
17150 +
17151 /* adds 0xffff0001, returns the old value */
17152 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17153 /* was the active mask 0 before? */
17154 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17155 long tmp;
17156 asm volatile("# beginning __up_read\n\t"
17157 LOCK_PREFIX " xadd %1,(%2)\n\t"
17158 +
17159 +#ifdef CONFIG_PAX_REFCOUNT
17160 + "jno 0f\n"
17161 + "mov %1,(%2)\n"
17162 + "int $4\n0:\n"
17163 + _ASM_EXTABLE(0b, 0b)
17164 +#endif
17165 +
17166 /* subtracts 1, returns the old value */
17167 " jns 1f\n\t"
17168 " call call_rwsem_wake\n" /* expects old value in %edx */
17169 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17170 long tmp;
17171 asm volatile("# beginning __up_write\n\t"
17172 LOCK_PREFIX " xadd %1,(%2)\n\t"
17173 +
17174 +#ifdef CONFIG_PAX_REFCOUNT
17175 + "jno 0f\n"
17176 + "mov %1,(%2)\n"
17177 + "int $4\n0:\n"
17178 + _ASM_EXTABLE(0b, 0b)
17179 +#endif
17180 +
17181 /* subtracts 0xffff0001, returns the old value */
17182 " jns 1f\n\t"
17183 " call call_rwsem_wake\n" /* expects old value in %edx */
17184 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17185 {
17186 asm volatile("# beginning __downgrade_write\n\t"
17187 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17188 +
17189 +#ifdef CONFIG_PAX_REFCOUNT
17190 + "jno 0f\n"
17191 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17192 + "int $4\n0:\n"
17193 + _ASM_EXTABLE(0b, 0b)
17194 +#endif
17195 +
17196 /*
17197 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17198 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17199 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17200 */
17201 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17202 {
17203 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17204 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17205 +
17206 +#ifdef CONFIG_PAX_REFCOUNT
17207 + "jno 0f\n"
17208 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17209 + "int $4\n0:\n"
17210 + _ASM_EXTABLE(0b, 0b)
17211 +#endif
17212 +
17213 : "+m" (sem->count)
17214 : "er" (delta));
17215 }
17216 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17217 */
17218 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17219 {
17220 - return delta + xadd(&sem->count, delta);
17221 + return delta + xadd_check_overflow(&sem->count, delta);
17222 }
17223
17224 #endif /* __KERNEL__ */
17225 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17226 index c48a950..bc40804 100644
17227 --- a/arch/x86/include/asm/segment.h
17228 +++ b/arch/x86/include/asm/segment.h
17229 @@ -64,10 +64,15 @@
17230 * 26 - ESPFIX small SS
17231 * 27 - per-cpu [ offset to per-cpu data area ]
17232 * 28 - stack_canary-20 [ for stack protector ]
17233 - * 29 - unused
17234 - * 30 - unused
17235 + * 29 - PCI BIOS CS
17236 + * 30 - PCI BIOS DS
17237 * 31 - TSS for double fault handler
17238 */
17239 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17240 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17241 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17242 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17243 +
17244 #define GDT_ENTRY_TLS_MIN 6
17245 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17246
17247 @@ -79,6 +84,8 @@
17248
17249 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17250
17251 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17252 +
17253 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17254
17255 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17256 @@ -104,6 +111,12 @@
17257 #define __KERNEL_STACK_CANARY 0
17258 #endif
17259
17260 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17261 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17262 +
17263 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17264 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17265 +
17266 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17267
17268 /*
17269 @@ -141,7 +154,7 @@
17270 */
17271
17272 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17273 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17274 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17275
17276
17277 #else
17278 @@ -165,6 +178,8 @@
17279 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17280 #define __USER32_DS __USER_DS
17281
17282 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17283 +
17284 #define GDT_ENTRY_TSS 8 /* needs two entries */
17285 #define GDT_ENTRY_LDT 10 /* needs two entries */
17286 #define GDT_ENTRY_TLS_MIN 12
17287 @@ -173,6 +188,8 @@
17288 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17289 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17290
17291 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17292 +
17293 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17294 #define FS_TLS 0
17295 #define GS_TLS 1
17296 @@ -180,12 +197,14 @@
17297 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17298 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17299
17300 -#define GDT_ENTRIES 16
17301 +#define GDT_ENTRIES 17
17302
17303 #endif
17304
17305 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17306 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17307 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17308 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17309 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17310 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17311 #ifndef CONFIG_PARAVIRT
17312 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17313 {
17314 unsigned long __limit;
17315 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17316 - return __limit + 1;
17317 + return __limit;
17318 }
17319
17320 #endif /* !__ASSEMBLY__ */
17321 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17322 index 8d3120f..352b440 100644
17323 --- a/arch/x86/include/asm/smap.h
17324 +++ b/arch/x86/include/asm/smap.h
17325 @@ -25,11 +25,40 @@
17326
17327 #include <asm/alternative-asm.h>
17328
17329 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17330 +#define ASM_PAX_OPEN_USERLAND \
17331 + 661: jmp 663f; \
17332 + .pushsection .altinstr_replacement, "a" ; \
17333 + 662: pushq %rax; nop; \
17334 + .popsection ; \
17335 + .pushsection .altinstructions, "a" ; \
17336 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17337 + .popsection ; \
17338 + call __pax_open_userland; \
17339 + popq %rax; \
17340 + 663:
17341 +
17342 +#define ASM_PAX_CLOSE_USERLAND \
17343 + 661: jmp 663f; \
17344 + .pushsection .altinstr_replacement, "a" ; \
17345 + 662: pushq %rax; nop; \
17346 + .popsection; \
17347 + .pushsection .altinstructions, "a" ; \
17348 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17349 + .popsection; \
17350 + call __pax_close_userland; \
17351 + popq %rax; \
17352 + 663:
17353 +#else
17354 +#define ASM_PAX_OPEN_USERLAND
17355 +#define ASM_PAX_CLOSE_USERLAND
17356 +#endif
17357 +
17358 #ifdef CONFIG_X86_SMAP
17359
17360 #define ASM_CLAC \
17361 661: ASM_NOP3 ; \
17362 - .pushsection .altinstr_replacement, "ax" ; \
17363 + .pushsection .altinstr_replacement, "a" ; \
17364 662: __ASM_CLAC ; \
17365 .popsection ; \
17366 .pushsection .altinstructions, "a" ; \
17367 @@ -38,7 +67,7 @@
17368
17369 #define ASM_STAC \
17370 661: ASM_NOP3 ; \
17371 - .pushsection .altinstr_replacement, "ax" ; \
17372 + .pushsection .altinstr_replacement, "a" ; \
17373 662: __ASM_STAC ; \
17374 .popsection ; \
17375 .pushsection .altinstructions, "a" ; \
17376 @@ -56,6 +85,37 @@
17377
17378 #include <asm/alternative.h>
17379
17380 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17381 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17382 +
17383 +extern void __pax_open_userland(void);
17384 +static __always_inline unsigned long pax_open_userland(void)
17385 +{
17386 +
17387 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17388 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17389 + :
17390 + : [open] "i" (__pax_open_userland)
17391 + : "memory", "rax");
17392 +#endif
17393 +
17394 + return 0;
17395 +}
17396 +
17397 +extern void __pax_close_userland(void);
17398 +static __always_inline unsigned long pax_close_userland(void)
17399 +{
17400 +
17401 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17402 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17403 + :
17404 + : [close] "i" (__pax_close_userland)
17405 + : "memory", "rax");
17406 +#endif
17407 +
17408 + return 0;
17409 +}
17410 +
17411 #ifdef CONFIG_X86_SMAP
17412
17413 static __always_inline void clac(void)
17414 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17415 index 4137890..03fa172 100644
17416 --- a/arch/x86/include/asm/smp.h
17417 +++ b/arch/x86/include/asm/smp.h
17418 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17419 /* cpus sharing the last level cache: */
17420 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17421 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17422 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17423 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17424
17425 static inline struct cpumask *cpu_sibling_mask(int cpu)
17426 {
17427 @@ -79,7 +79,7 @@ struct smp_ops {
17428
17429 void (*send_call_func_ipi)(const struct cpumask *mask);
17430 void (*send_call_func_single_ipi)(int cpu);
17431 -};
17432 +} __no_const;
17433
17434 /* Globals due to paravirt */
17435 extern void set_cpu_sibling_map(int cpu);
17436 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17437 extern int safe_smp_processor_id(void);
17438
17439 #elif defined(CONFIG_X86_64_SMP)
17440 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17441 -
17442 -#define stack_smp_processor_id() \
17443 -({ \
17444 - struct thread_info *ti; \
17445 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17446 - ti->cpu; \
17447 -})
17448 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17449 +#define stack_smp_processor_id() raw_smp_processor_id()
17450 #define safe_smp_processor_id() smp_processor_id()
17451
17452 #endif
17453 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17454 index bf156de..1a782ab 100644
17455 --- a/arch/x86/include/asm/spinlock.h
17456 +++ b/arch/x86/include/asm/spinlock.h
17457 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17458 static inline void arch_read_lock(arch_rwlock_t *rw)
17459 {
17460 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17461 +
17462 +#ifdef CONFIG_PAX_REFCOUNT
17463 + "jno 0f\n"
17464 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17465 + "int $4\n0:\n"
17466 + _ASM_EXTABLE(0b, 0b)
17467 +#endif
17468 +
17469 "jns 1f\n"
17470 "call __read_lock_failed\n\t"
17471 "1:\n"
17472 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17473 static inline void arch_write_lock(arch_rwlock_t *rw)
17474 {
17475 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17476 +
17477 +#ifdef CONFIG_PAX_REFCOUNT
17478 + "jno 0f\n"
17479 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17480 + "int $4\n0:\n"
17481 + _ASM_EXTABLE(0b, 0b)
17482 +#endif
17483 +
17484 "jz 1f\n"
17485 "call __write_lock_failed\n\t"
17486 "1:\n"
17487 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17488
17489 static inline void arch_read_unlock(arch_rwlock_t *rw)
17490 {
17491 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17492 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17493 +
17494 +#ifdef CONFIG_PAX_REFCOUNT
17495 + "jno 0f\n"
17496 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17497 + "int $4\n0:\n"
17498 + _ASM_EXTABLE(0b, 0b)
17499 +#endif
17500 +
17501 :"+m" (rw->lock) : : "memory");
17502 }
17503
17504 static inline void arch_write_unlock(arch_rwlock_t *rw)
17505 {
17506 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17507 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17508 +
17509 +#ifdef CONFIG_PAX_REFCOUNT
17510 + "jno 0f\n"
17511 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17512 + "int $4\n0:\n"
17513 + _ASM_EXTABLE(0b, 0b)
17514 +#endif
17515 +
17516 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17517 }
17518
17519 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17520 index 6a99859..03cb807 100644
17521 --- a/arch/x86/include/asm/stackprotector.h
17522 +++ b/arch/x86/include/asm/stackprotector.h
17523 @@ -47,7 +47,7 @@
17524 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17525 */
17526 #define GDT_STACK_CANARY_INIT \
17527 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17528 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17529
17530 /*
17531 * Initialize the stackprotector canary value.
17532 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17533
17534 static inline void load_stack_canary_segment(void)
17535 {
17536 -#ifdef CONFIG_X86_32
17537 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17538 asm volatile ("mov %0, %%gs" : : "r" (0));
17539 #endif
17540 }
17541 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17542 index 70bbe39..4ae2bd4 100644
17543 --- a/arch/x86/include/asm/stacktrace.h
17544 +++ b/arch/x86/include/asm/stacktrace.h
17545 @@ -11,28 +11,20 @@
17546
17547 extern int kstack_depth_to_print;
17548
17549 -struct thread_info;
17550 +struct task_struct;
17551 struct stacktrace_ops;
17552
17553 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17554 - unsigned long *stack,
17555 - unsigned long bp,
17556 - const struct stacktrace_ops *ops,
17557 - void *data,
17558 - unsigned long *end,
17559 - int *graph);
17560 +typedef unsigned long walk_stack_t(struct task_struct *task,
17561 + void *stack_start,
17562 + unsigned long *stack,
17563 + unsigned long bp,
17564 + const struct stacktrace_ops *ops,
17565 + void *data,
17566 + unsigned long *end,
17567 + int *graph);
17568
17569 -extern unsigned long
17570 -print_context_stack(struct thread_info *tinfo,
17571 - unsigned long *stack, unsigned long bp,
17572 - const struct stacktrace_ops *ops, void *data,
17573 - unsigned long *end, int *graph);
17574 -
17575 -extern unsigned long
17576 -print_context_stack_bp(struct thread_info *tinfo,
17577 - unsigned long *stack, unsigned long bp,
17578 - const struct stacktrace_ops *ops, void *data,
17579 - unsigned long *end, int *graph);
17580 +extern walk_stack_t print_context_stack;
17581 +extern walk_stack_t print_context_stack_bp;
17582
17583 /* Generic stack tracer with callbacks */
17584
17585 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17586 void (*address)(void *data, unsigned long address, int reliable);
17587 /* On negative return stop dumping */
17588 int (*stack)(void *data, char *name);
17589 - walk_stack_t walk_stack;
17590 + walk_stack_t *walk_stack;
17591 };
17592
17593 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17594 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17595 index d7f3b3b..3cc39f1 100644
17596 --- a/arch/x86/include/asm/switch_to.h
17597 +++ b/arch/x86/include/asm/switch_to.h
17598 @@ -108,7 +108,7 @@ do { \
17599 "call __switch_to\n\t" \
17600 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17601 __switch_canary \
17602 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17603 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17604 "movq %%rax,%%rdi\n\t" \
17605 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17606 "jnz ret_from_fork\n\t" \
17607 @@ -119,7 +119,7 @@ do { \
17608 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17609 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17610 [_tif_fork] "i" (_TIF_FORK), \
17611 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17612 + [thread_info] "m" (current_tinfo), \
17613 [current_task] "m" (current_task) \
17614 __switch_canary_iparam \
17615 : "memory", "cc" __EXTRA_CLOBBER)
17616 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17617 index 2781119..618b59b 100644
17618 --- a/arch/x86/include/asm/thread_info.h
17619 +++ b/arch/x86/include/asm/thread_info.h
17620 @@ -10,6 +10,7 @@
17621 #include <linux/compiler.h>
17622 #include <asm/page.h>
17623 #include <asm/types.h>
17624 +#include <asm/percpu.h>
17625
17626 /*
17627 * low level task data that entry.S needs immediate access to
17628 @@ -23,7 +24,6 @@ struct exec_domain;
17629 #include <linux/atomic.h>
17630
17631 struct thread_info {
17632 - struct task_struct *task; /* main task structure */
17633 struct exec_domain *exec_domain; /* execution domain */
17634 __u32 flags; /* low level flags */
17635 __u32 status; /* thread synchronous flags */
17636 @@ -33,19 +33,13 @@ struct thread_info {
17637 mm_segment_t addr_limit;
17638 struct restart_block restart_block;
17639 void __user *sysenter_return;
17640 -#ifdef CONFIG_X86_32
17641 - unsigned long previous_esp; /* ESP of the previous stack in
17642 - case of nested (IRQ) stacks
17643 - */
17644 - __u8 supervisor_stack[0];
17645 -#endif
17646 + unsigned long lowest_stack;
17647 unsigned int sig_on_uaccess_error:1;
17648 unsigned int uaccess_err:1; /* uaccess failed */
17649 };
17650
17651 -#define INIT_THREAD_INFO(tsk) \
17652 +#define INIT_THREAD_INFO \
17653 { \
17654 - .task = &tsk, \
17655 .exec_domain = &default_exec_domain, \
17656 .flags = 0, \
17657 .cpu = 0, \
17658 @@ -56,7 +50,7 @@ struct thread_info {
17659 }, \
17660 }
17661
17662 -#define init_thread_info (init_thread_union.thread_info)
17663 +#define init_thread_info (init_thread_union.stack)
17664 #define init_stack (init_thread_union.stack)
17665
17666 #else /* !__ASSEMBLY__ */
17667 @@ -96,6 +90,7 @@ struct thread_info {
17668 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17669 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17670 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17671 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17672
17673 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17674 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17675 @@ -119,17 +114,18 @@ struct thread_info {
17676 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17677 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17678 #define _TIF_X32 (1 << TIF_X32)
17679 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17680
17681 /* work to do in syscall_trace_enter() */
17682 #define _TIF_WORK_SYSCALL_ENTRY \
17683 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17684 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17685 - _TIF_NOHZ)
17686 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17687
17688 /* work to do in syscall_trace_leave() */
17689 #define _TIF_WORK_SYSCALL_EXIT \
17690 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17691 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17692 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17693
17694 /* work to do on interrupt/exception return */
17695 #define _TIF_WORK_MASK \
17696 @@ -140,7 +136,7 @@ struct thread_info {
17697 /* work to do on any return to user space */
17698 #define _TIF_ALLWORK_MASK \
17699 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17700 - _TIF_NOHZ)
17701 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17702
17703 /* Only used for 64 bit */
17704 #define _TIF_DO_NOTIFY_MASK \
17705 @@ -156,45 +152,40 @@ struct thread_info {
17706
17707 #define PREEMPT_ACTIVE 0x10000000
17708
17709 -#ifdef CONFIG_X86_32
17710 -
17711 -#define STACK_WARN (THREAD_SIZE/8)
17712 -/*
17713 - * macros/functions for gaining access to the thread information structure
17714 - *
17715 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17716 - */
17717 -#ifndef __ASSEMBLY__
17718 -
17719 -
17720 -/* how to get the current stack pointer from C */
17721 -register unsigned long current_stack_pointer asm("esp") __used;
17722 -
17723 -/* how to get the thread information struct from C */
17724 -static inline struct thread_info *current_thread_info(void)
17725 -{
17726 - return (struct thread_info *)
17727 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17728 -}
17729 -
17730 -#else /* !__ASSEMBLY__ */
17731 -
17732 +#ifdef __ASSEMBLY__
17733 /* how to get the thread information struct from ASM */
17734 #define GET_THREAD_INFO(reg) \
17735 - movl $-THREAD_SIZE, reg; \
17736 - andl %esp, reg
17737 + mov PER_CPU_VAR(current_tinfo), reg
17738
17739 /* use this one if reg already contains %esp */
17740 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17741 - andl $-THREAD_SIZE, reg
17742 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17743 +#else
17744 +/* how to get the thread information struct from C */
17745 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17746 +
17747 +static __always_inline struct thread_info *current_thread_info(void)
17748 +{
17749 + return this_cpu_read_stable(current_tinfo);
17750 +}
17751 +#endif
17752 +
17753 +#ifdef CONFIG_X86_32
17754 +
17755 +#define STACK_WARN (THREAD_SIZE/8)
17756 +/*
17757 + * macros/functions for gaining access to the thread information structure
17758 + *
17759 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17760 + */
17761 +#ifndef __ASSEMBLY__
17762 +
17763 +/* how to get the current stack pointer from C */
17764 +register unsigned long current_stack_pointer asm("esp") __used;
17765
17766 #endif
17767
17768 #else /* X86_32 */
17769
17770 -#include <asm/percpu.h>
17771 -#define KERNEL_STACK_OFFSET (5*8)
17772 -
17773 /*
17774 * macros/functions for gaining access to the thread information structure
17775 * preempt_count needs to be 1 initially, until the scheduler is functional.
17776 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17777 #ifndef __ASSEMBLY__
17778 DECLARE_PER_CPU(unsigned long, kernel_stack);
17779
17780 -static inline struct thread_info *current_thread_info(void)
17781 -{
17782 - struct thread_info *ti;
17783 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17784 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17785 - return ti;
17786 -}
17787 -
17788 -#else /* !__ASSEMBLY__ */
17789 -
17790 -/* how to get the thread information struct from ASM */
17791 -#define GET_THREAD_INFO(reg) \
17792 - movq PER_CPU_VAR(kernel_stack),reg ; \
17793 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17794 -
17795 -/*
17796 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17797 - * a certain register (to be used in assembler memory operands).
17798 - */
17799 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17800 -
17801 +/* how to get the current stack pointer from C */
17802 +register unsigned long current_stack_pointer asm("rsp") __used;
17803 #endif
17804
17805 #endif /* !X86_32 */
17806 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17807 extern void arch_task_cache_init(void);
17808 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17809 extern void arch_release_task_struct(struct task_struct *tsk);
17810 +
17811 +#define __HAVE_THREAD_FUNCTIONS
17812 +#define task_thread_info(task) (&(task)->tinfo)
17813 +#define task_stack_page(task) ((task)->stack)
17814 +#define setup_thread_stack(p, org) do {} while (0)
17815 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17816 +
17817 #endif
17818 #endif /* _ASM_X86_THREAD_INFO_H */
17819 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17820 index e6d90ba..0897f44 100644
17821 --- a/arch/x86/include/asm/tlbflush.h
17822 +++ b/arch/x86/include/asm/tlbflush.h
17823 @@ -17,18 +17,44 @@
17824
17825 static inline void __native_flush_tlb(void)
17826 {
17827 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17828 + u64 descriptor[2];
17829 +
17830 + descriptor[0] = PCID_KERNEL;
17831 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17832 + return;
17833 + }
17834 +
17835 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17836 + if (static_cpu_has(X86_FEATURE_PCID)) {
17837 + unsigned int cpu = raw_get_cpu();
17838 +
17839 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17840 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17841 + raw_put_cpu_no_resched();
17842 + return;
17843 + }
17844 +#endif
17845 +
17846 native_write_cr3(native_read_cr3());
17847 }
17848
17849 static inline void __native_flush_tlb_global_irq_disabled(void)
17850 {
17851 - unsigned long cr4;
17852 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17853 + u64 descriptor[2];
17854
17855 - cr4 = native_read_cr4();
17856 - /* clear PGE */
17857 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17858 - /* write old PGE again and flush TLBs */
17859 - native_write_cr4(cr4);
17860 + descriptor[0] = PCID_KERNEL;
17861 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17862 + } else {
17863 + unsigned long cr4;
17864 +
17865 + cr4 = native_read_cr4();
17866 + /* clear PGE */
17867 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17868 + /* write old PGE again and flush TLBs */
17869 + native_write_cr4(cr4);
17870 + }
17871 }
17872
17873 static inline void __native_flush_tlb_global(void)
17874 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17875
17876 static inline void __native_flush_tlb_single(unsigned long addr)
17877 {
17878 +
17879 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17880 + u64 descriptor[2];
17881 +
17882 + descriptor[0] = PCID_KERNEL;
17883 + descriptor[1] = addr;
17884 +
17885 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17886 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17887 + if (addr < TASK_SIZE_MAX)
17888 + descriptor[1] += pax_user_shadow_base;
17889 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17890 + }
17891 +
17892 + descriptor[0] = PCID_USER;
17893 + descriptor[1] = addr;
17894 +#endif
17895 +
17896 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17897 + return;
17898 + }
17899 +
17900 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17901 + if (static_cpu_has(X86_FEATURE_PCID)) {
17902 + unsigned int cpu = raw_get_cpu();
17903 +
17904 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17905 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17906 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17907 + raw_put_cpu_no_resched();
17908 +
17909 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17910 + addr += pax_user_shadow_base;
17911 + }
17912 +#endif
17913 +
17914 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17915 }
17916
17917 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17918 index 5838fa9..f7ae572 100644
17919 --- a/arch/x86/include/asm/uaccess.h
17920 +++ b/arch/x86/include/asm/uaccess.h
17921 @@ -7,6 +7,7 @@
17922 #include <linux/compiler.h>
17923 #include <linux/thread_info.h>
17924 #include <linux/string.h>
17925 +#include <linux/sched.h>
17926 #include <asm/asm.h>
17927 #include <asm/page.h>
17928 #include <asm/smap.h>
17929 @@ -29,7 +30,12 @@
17930
17931 #define get_ds() (KERNEL_DS)
17932 #define get_fs() (current_thread_info()->addr_limit)
17933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17934 +void __set_fs(mm_segment_t x);
17935 +void set_fs(mm_segment_t x);
17936 +#else
17937 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17938 +#endif
17939
17940 #define segment_eq(a, b) ((a).seg == (b).seg)
17941
17942 @@ -77,8 +83,33 @@
17943 * checks that the pointer is in the user space range - after calling
17944 * this function, memory access functions may still return -EFAULT.
17945 */
17946 -#define access_ok(type, addr, size) \
17947 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17948 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17949 +#define access_ok(type, addr, size) \
17950 +({ \
17951 + long __size = size; \
17952 + unsigned long __addr = (unsigned long)addr; \
17953 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17954 + unsigned long __end_ao = __addr + __size - 1; \
17955 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17956 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17957 + while(__addr_ao <= __end_ao) { \
17958 + char __c_ao; \
17959 + __addr_ao += PAGE_SIZE; \
17960 + if (__size > PAGE_SIZE) \
17961 + cond_resched(); \
17962 + if (__get_user(__c_ao, (char __user *)__addr)) \
17963 + break; \
17964 + if (type != VERIFY_WRITE) { \
17965 + __addr = __addr_ao; \
17966 + continue; \
17967 + } \
17968 + if (__put_user(__c_ao, (char __user *)__addr)) \
17969 + break; \
17970 + __addr = __addr_ao; \
17971 + } \
17972 + } \
17973 + __ret_ao; \
17974 +})
17975
17976 /*
17977 * The exception table consists of pairs of addresses relative to the
17978 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17979 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
17980 __chk_user_ptr(ptr); \
17981 might_fault(); \
17982 + pax_open_userland(); \
17983 asm volatile("call __get_user_%P3" \
17984 : "=a" (__ret_gu), "=r" (__val_gu) \
17985 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17986 (x) = (__typeof__(*(ptr))) __val_gu; \
17987 + pax_close_userland(); \
17988 __ret_gu; \
17989 })
17990
17991 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17992 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17993 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17994
17995 -
17996 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17997 +#define __copyuser_seg "gs;"
17998 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17999 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18000 +#else
18001 +#define __copyuser_seg
18002 +#define __COPYUSER_SET_ES
18003 +#define __COPYUSER_RESTORE_ES
18004 +#endif
18005
18006 #ifdef CONFIG_X86_32
18007 #define __put_user_asm_u64(x, addr, err, errret) \
18008 asm volatile(ASM_STAC "\n" \
18009 - "1: movl %%eax,0(%2)\n" \
18010 - "2: movl %%edx,4(%2)\n" \
18011 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18012 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18013 "3: " ASM_CLAC "\n" \
18014 ".section .fixup,\"ax\"\n" \
18015 "4: movl %3,%0\n" \
18016 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18017
18018 #define __put_user_asm_ex_u64(x, addr) \
18019 asm volatile(ASM_STAC "\n" \
18020 - "1: movl %%eax,0(%1)\n" \
18021 - "2: movl %%edx,4(%1)\n" \
18022 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18023 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18024 "3: " ASM_CLAC "\n" \
18025 _ASM_EXTABLE_EX(1b, 2b) \
18026 _ASM_EXTABLE_EX(2b, 3b) \
18027 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18028 __typeof__(*(ptr)) __pu_val; \
18029 __chk_user_ptr(ptr); \
18030 might_fault(); \
18031 - __pu_val = x; \
18032 + __pu_val = (x); \
18033 + pax_open_userland(); \
18034 switch (sizeof(*(ptr))) { \
18035 case 1: \
18036 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18037 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18038 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18039 break; \
18040 } \
18041 + pax_close_userland(); \
18042 __ret_pu; \
18043 })
18044
18045 @@ -347,8 +390,10 @@ do { \
18046 } while (0)
18047
18048 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18049 +do { \
18050 + pax_open_userland(); \
18051 asm volatile(ASM_STAC "\n" \
18052 - "1: mov"itype" %2,%"rtype"1\n" \
18053 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18054 "2: " ASM_CLAC "\n" \
18055 ".section .fixup,\"ax\"\n" \
18056 "3: mov %3,%0\n" \
18057 @@ -356,8 +401,10 @@ do { \
18058 " jmp 2b\n" \
18059 ".previous\n" \
18060 _ASM_EXTABLE(1b, 3b) \
18061 - : "=r" (err), ltype(x) \
18062 - : "m" (__m(addr)), "i" (errret), "0" (err))
18063 + : "=r" (err), ltype (x) \
18064 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18065 + pax_close_userland(); \
18066 +} while (0)
18067
18068 #define __get_user_size_ex(x, ptr, size) \
18069 do { \
18070 @@ -381,7 +428,7 @@ do { \
18071 } while (0)
18072
18073 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18074 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18075 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18076 "2:\n" \
18077 _ASM_EXTABLE_EX(1b, 2b) \
18078 : ltype(x) : "m" (__m(addr)))
18079 @@ -398,13 +445,24 @@ do { \
18080 int __gu_err; \
18081 unsigned long __gu_val; \
18082 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18083 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18084 + (x) = (__typeof__(*(ptr)))__gu_val; \
18085 __gu_err; \
18086 })
18087
18088 /* FIXME: this hack is definitely wrong -AK */
18089 struct __large_struct { unsigned long buf[100]; };
18090 -#define __m(x) (*(struct __large_struct __user *)(x))
18091 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18092 +#define ____m(x) \
18093 +({ \
18094 + unsigned long ____x = (unsigned long)(x); \
18095 + if (____x < pax_user_shadow_base) \
18096 + ____x += pax_user_shadow_base; \
18097 + (typeof(x))____x; \
18098 +})
18099 +#else
18100 +#define ____m(x) (x)
18101 +#endif
18102 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18103
18104 /*
18105 * Tell gcc we read from memory instead of writing: this is because
18106 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18107 * aliasing issues.
18108 */
18109 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18110 +do { \
18111 + pax_open_userland(); \
18112 asm volatile(ASM_STAC "\n" \
18113 - "1: mov"itype" %"rtype"1,%2\n" \
18114 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18115 "2: " ASM_CLAC "\n" \
18116 ".section .fixup,\"ax\"\n" \
18117 "3: mov %3,%0\n" \
18118 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18119 ".previous\n" \
18120 _ASM_EXTABLE(1b, 3b) \
18121 : "=r"(err) \
18122 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18123 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18124 + pax_close_userland(); \
18125 +} while (0)
18126
18127 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18128 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18129 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18130 "2:\n" \
18131 _ASM_EXTABLE_EX(1b, 2b) \
18132 : : ltype(x), "m" (__m(addr)))
18133 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18134 */
18135 #define uaccess_try do { \
18136 current_thread_info()->uaccess_err = 0; \
18137 + pax_open_userland(); \
18138 stac(); \
18139 barrier();
18140
18141 #define uaccess_catch(err) \
18142 clac(); \
18143 + pax_close_userland(); \
18144 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18145 } while (0)
18146
18147 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18148 * On error, the variable @x is set to zero.
18149 */
18150
18151 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18152 +#define __get_user(x, ptr) get_user((x), (ptr))
18153 +#else
18154 #define __get_user(x, ptr) \
18155 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18156 +#endif
18157
18158 /**
18159 * __put_user: - Write a simple value into user space, with less checking.
18160 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18161 * Returns zero on success, or -EFAULT on error.
18162 */
18163
18164 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18165 +#define __put_user(x, ptr) put_user((x), (ptr))
18166 +#else
18167 #define __put_user(x, ptr) \
18168 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18169 +#endif
18170
18171 #define __get_user_unaligned __get_user
18172 #define __put_user_unaligned __put_user
18173 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18174 #define get_user_ex(x, ptr) do { \
18175 unsigned long __gue_val; \
18176 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18177 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18178 + (x) = (__typeof__(*(ptr)))__gue_val; \
18179 } while (0)
18180
18181 #define put_user_try uaccess_try
18182 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18183 index 7f760a9..b596b9a 100644
18184 --- a/arch/x86/include/asm/uaccess_32.h
18185 +++ b/arch/x86/include/asm/uaccess_32.h
18186 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18187 static __always_inline unsigned long __must_check
18188 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18189 {
18190 + if ((long)n < 0)
18191 + return n;
18192 +
18193 + check_object_size(from, n, true);
18194 +
18195 if (__builtin_constant_p(n)) {
18196 unsigned long ret;
18197
18198 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18199 __copy_to_user(void __user *to, const void *from, unsigned long n)
18200 {
18201 might_fault();
18202 +
18203 return __copy_to_user_inatomic(to, from, n);
18204 }
18205
18206 static __always_inline unsigned long
18207 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18208 {
18209 + if ((long)n < 0)
18210 + return n;
18211 +
18212 /* Avoid zeroing the tail if the copy fails..
18213 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18214 * but as the zeroing behaviour is only significant when n is not
18215 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18216 __copy_from_user(void *to, const void __user *from, unsigned long n)
18217 {
18218 might_fault();
18219 +
18220 + if ((long)n < 0)
18221 + return n;
18222 +
18223 + check_object_size(to, n, false);
18224 +
18225 if (__builtin_constant_p(n)) {
18226 unsigned long ret;
18227
18228 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18229 const void __user *from, unsigned long n)
18230 {
18231 might_fault();
18232 +
18233 + if ((long)n < 0)
18234 + return n;
18235 +
18236 if (__builtin_constant_p(n)) {
18237 unsigned long ret;
18238
18239 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18240 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18241 unsigned long n)
18242 {
18243 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18244 + if ((long)n < 0)
18245 + return n;
18246 +
18247 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18248 }
18249
18250 -unsigned long __must_check copy_to_user(void __user *to,
18251 - const void *from, unsigned long n);
18252 -unsigned long __must_check _copy_from_user(void *to,
18253 - const void __user *from,
18254 - unsigned long n);
18255 -
18256 +extern void copy_to_user_overflow(void)
18257 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18258 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18259 +#else
18260 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18261 +#endif
18262 +;
18263
18264 extern void copy_from_user_overflow(void)
18265 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18266 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18267 #endif
18268 ;
18269
18270 -static inline unsigned long __must_check copy_from_user(void *to,
18271 - const void __user *from,
18272 - unsigned long n)
18273 +/**
18274 + * copy_to_user: - Copy a block of data into user space.
18275 + * @to: Destination address, in user space.
18276 + * @from: Source address, in kernel space.
18277 + * @n: Number of bytes to copy.
18278 + *
18279 + * Context: User context only. This function may sleep.
18280 + *
18281 + * Copy data from kernel space to user space.
18282 + *
18283 + * Returns number of bytes that could not be copied.
18284 + * On success, this will be zero.
18285 + */
18286 +static inline unsigned long __must_check
18287 +copy_to_user(void __user *to, const void *from, unsigned long n)
18288 {
18289 - int sz = __compiletime_object_size(to);
18290 + size_t sz = __compiletime_object_size(from);
18291
18292 - if (likely(sz == -1 || sz >= n))
18293 - n = _copy_from_user(to, from, n);
18294 - else
18295 + if (unlikely(sz != (size_t)-1 && sz < n))
18296 + copy_to_user_overflow();
18297 + else if (access_ok(VERIFY_WRITE, to, n))
18298 + n = __copy_to_user(to, from, n);
18299 + return n;
18300 +}
18301 +
18302 +/**
18303 + * copy_from_user: - Copy a block of data from user space.
18304 + * @to: Destination address, in kernel space.
18305 + * @from: Source address, in user space.
18306 + * @n: Number of bytes to copy.
18307 + *
18308 + * Context: User context only. This function may sleep.
18309 + *
18310 + * Copy data from user space to kernel space.
18311 + *
18312 + * Returns number of bytes that could not be copied.
18313 + * On success, this will be zero.
18314 + *
18315 + * If some data could not be copied, this function will pad the copied
18316 + * data to the requested size using zero bytes.
18317 + */
18318 +static inline unsigned long __must_check
18319 +copy_from_user(void *to, const void __user *from, unsigned long n)
18320 +{
18321 + size_t sz = __compiletime_object_size(to);
18322 +
18323 + check_object_size(to, n, false);
18324 +
18325 + if (unlikely(sz != (size_t)-1 && sz < n))
18326 copy_from_user_overflow();
18327 -
18328 + else if (access_ok(VERIFY_READ, from, n))
18329 + n = __copy_from_user(to, from, n);
18330 + else if ((long)n > 0)
18331 + memset(to, 0, n);
18332 return n;
18333 }
18334
18335 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18336 index 4f7923d..201b58d 100644
18337 --- a/arch/x86/include/asm/uaccess_64.h
18338 +++ b/arch/x86/include/asm/uaccess_64.h
18339 @@ -10,6 +10,9 @@
18340 #include <asm/alternative.h>
18341 #include <asm/cpufeature.h>
18342 #include <asm/page.h>
18343 +#include <asm/pgtable.h>
18344 +
18345 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18346
18347 /*
18348 * Copy To/From Userspace
18349 @@ -17,14 +20,14 @@
18350
18351 /* Handles exceptions in both to and from, but doesn't do access_ok */
18352 __must_check unsigned long
18353 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18354 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18355 __must_check unsigned long
18356 -copy_user_generic_string(void *to, const void *from, unsigned len);
18357 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18358 __must_check unsigned long
18359 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18360 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18361
18362 -static __always_inline __must_check unsigned long
18363 -copy_user_generic(void *to, const void *from, unsigned len)
18364 +static __always_inline __must_check unsigned long
18365 +copy_user_generic(void *to, const void *from, unsigned long len)
18366 {
18367 unsigned ret;
18368
18369 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18370 return ret;
18371 }
18372
18373 +static __always_inline __must_check unsigned long
18374 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18375 +static __always_inline __must_check unsigned long
18376 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18377 __must_check unsigned long
18378 -_copy_to_user(void __user *to, const void *from, unsigned len);
18379 -__must_check unsigned long
18380 -_copy_from_user(void *to, const void __user *from, unsigned len);
18381 -__must_check unsigned long
18382 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18383 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18384 +
18385 +extern void copy_to_user_overflow(void)
18386 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18387 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18388 +#else
18389 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18390 +#endif
18391 +;
18392 +
18393 +extern void copy_from_user_overflow(void)
18394 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18395 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18396 +#else
18397 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18398 +#endif
18399 +;
18400
18401 static inline unsigned long __must_check copy_from_user(void *to,
18402 const void __user *from,
18403 unsigned long n)
18404 {
18405 - int sz = __compiletime_object_size(to);
18406 -
18407 might_fault();
18408 - if (likely(sz == -1 || sz >= n))
18409 - n = _copy_from_user(to, from, n);
18410 -#ifdef CONFIG_DEBUG_VM
18411 - else
18412 - WARN(1, "Buffer overflow detected!\n");
18413 -#endif
18414 +
18415 + check_object_size(to, n, false);
18416 +
18417 + if (access_ok(VERIFY_READ, from, n))
18418 + n = __copy_from_user(to, from, n);
18419 + else if (n < INT_MAX)
18420 + memset(to, 0, n);
18421 return n;
18422 }
18423
18424 static __always_inline __must_check
18425 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18426 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18427 {
18428 might_fault();
18429
18430 - return _copy_to_user(dst, src, size);
18431 + if (access_ok(VERIFY_WRITE, dst, size))
18432 + size = __copy_to_user(dst, src, size);
18433 + return size;
18434 }
18435
18436 static __always_inline __must_check
18437 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18438 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18439 {
18440 - int ret = 0;
18441 + size_t sz = __compiletime_object_size(dst);
18442 + unsigned ret = 0;
18443
18444 might_fault();
18445 +
18446 + if (size > INT_MAX)
18447 + return size;
18448 +
18449 + check_object_size(dst, size, false);
18450 +
18451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18452 + if (!__access_ok(VERIFY_READ, src, size))
18453 + return size;
18454 +#endif
18455 +
18456 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18457 + copy_from_user_overflow();
18458 + return size;
18459 + }
18460 +
18461 if (!__builtin_constant_p(size))
18462 - return copy_user_generic(dst, (__force void *)src, size);
18463 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18464 switch (size) {
18465 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18466 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18467 ret, "b", "b", "=q", 1);
18468 return ret;
18469 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18470 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18471 ret, "w", "w", "=r", 2);
18472 return ret;
18473 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18474 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18475 ret, "l", "k", "=r", 4);
18476 return ret;
18477 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18478 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18479 ret, "q", "", "=r", 8);
18480 return ret;
18481 case 10:
18482 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18483 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18484 ret, "q", "", "=r", 10);
18485 if (unlikely(ret))
18486 return ret;
18487 __get_user_asm(*(u16 *)(8 + (char *)dst),
18488 - (u16 __user *)(8 + (char __user *)src),
18489 + (const u16 __user *)(8 + (const char __user *)src),
18490 ret, "w", "w", "=r", 2);
18491 return ret;
18492 case 16:
18493 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18494 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18495 ret, "q", "", "=r", 16);
18496 if (unlikely(ret))
18497 return ret;
18498 __get_user_asm(*(u64 *)(8 + (char *)dst),
18499 - (u64 __user *)(8 + (char __user *)src),
18500 + (const u64 __user *)(8 + (const char __user *)src),
18501 ret, "q", "", "=r", 8);
18502 return ret;
18503 default:
18504 - return copy_user_generic(dst, (__force void *)src, size);
18505 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18506 }
18507 }
18508
18509 static __always_inline __must_check
18510 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18511 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18512 {
18513 - int ret = 0;
18514 + size_t sz = __compiletime_object_size(src);
18515 + unsigned ret = 0;
18516
18517 might_fault();
18518 +
18519 + if (size > INT_MAX)
18520 + return size;
18521 +
18522 + check_object_size(src, size, true);
18523 +
18524 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18525 + if (!__access_ok(VERIFY_WRITE, dst, size))
18526 + return size;
18527 +#endif
18528 +
18529 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18530 + copy_to_user_overflow();
18531 + return size;
18532 + }
18533 +
18534 if (!__builtin_constant_p(size))
18535 - return copy_user_generic((__force void *)dst, src, size);
18536 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18537 switch (size) {
18538 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18539 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18540 ret, "b", "b", "iq", 1);
18541 return ret;
18542 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18543 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18544 ret, "w", "w", "ir", 2);
18545 return ret;
18546 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18547 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18548 ret, "l", "k", "ir", 4);
18549 return ret;
18550 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18551 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18552 ret, "q", "", "er", 8);
18553 return ret;
18554 case 10:
18555 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18556 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18557 ret, "q", "", "er", 10);
18558 if (unlikely(ret))
18559 return ret;
18560 asm("":::"memory");
18561 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18562 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18563 ret, "w", "w", "ir", 2);
18564 return ret;
18565 case 16:
18566 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18567 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18568 ret, "q", "", "er", 16);
18569 if (unlikely(ret))
18570 return ret;
18571 asm("":::"memory");
18572 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18573 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18574 ret, "q", "", "er", 8);
18575 return ret;
18576 default:
18577 - return copy_user_generic((__force void *)dst, src, size);
18578 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18579 }
18580 }
18581
18582 static __always_inline __must_check
18583 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18584 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18585 {
18586 - int ret = 0;
18587 + unsigned ret = 0;
18588
18589 might_fault();
18590 +
18591 + if (size > INT_MAX)
18592 + return size;
18593 +
18594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18595 + if (!__access_ok(VERIFY_READ, src, size))
18596 + return size;
18597 + if (!__access_ok(VERIFY_WRITE, dst, size))
18598 + return size;
18599 +#endif
18600 +
18601 if (!__builtin_constant_p(size))
18602 - return copy_user_generic((__force void *)dst,
18603 - (__force void *)src, size);
18604 + return copy_user_generic((__force_kernel void *)____m(dst),
18605 + (__force_kernel const void *)____m(src), size);
18606 switch (size) {
18607 case 1: {
18608 u8 tmp;
18609 - __get_user_asm(tmp, (u8 __user *)src,
18610 + __get_user_asm(tmp, (const u8 __user *)src,
18611 ret, "b", "b", "=q", 1);
18612 if (likely(!ret))
18613 __put_user_asm(tmp, (u8 __user *)dst,
18614 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18615 }
18616 case 2: {
18617 u16 tmp;
18618 - __get_user_asm(tmp, (u16 __user *)src,
18619 + __get_user_asm(tmp, (const u16 __user *)src,
18620 ret, "w", "w", "=r", 2);
18621 if (likely(!ret))
18622 __put_user_asm(tmp, (u16 __user *)dst,
18623 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18624
18625 case 4: {
18626 u32 tmp;
18627 - __get_user_asm(tmp, (u32 __user *)src,
18628 + __get_user_asm(tmp, (const u32 __user *)src,
18629 ret, "l", "k", "=r", 4);
18630 if (likely(!ret))
18631 __put_user_asm(tmp, (u32 __user *)dst,
18632 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18633 }
18634 case 8: {
18635 u64 tmp;
18636 - __get_user_asm(tmp, (u64 __user *)src,
18637 + __get_user_asm(tmp, (const u64 __user *)src,
18638 ret, "q", "", "=r", 8);
18639 if (likely(!ret))
18640 __put_user_asm(tmp, (u64 __user *)dst,
18641 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18642 return ret;
18643 }
18644 default:
18645 - return copy_user_generic((__force void *)dst,
18646 - (__force void *)src, size);
18647 + return copy_user_generic((__force_kernel void *)____m(dst),
18648 + (__force_kernel const void *)____m(src), size);
18649 }
18650 }
18651
18652 -static __must_check __always_inline int
18653 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18654 +static __must_check __always_inline unsigned long
18655 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18656 {
18657 - return copy_user_generic(dst, (__force const void *)src, size);
18658 + if (size > INT_MAX)
18659 + return size;
18660 +
18661 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18662 + if (!__access_ok(VERIFY_READ, src, size))
18663 + return size;
18664 +#endif
18665 +
18666 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18667 }
18668
18669 -static __must_check __always_inline int
18670 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18671 +static __must_check __always_inline unsigned long
18672 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18673 {
18674 - return copy_user_generic((__force void *)dst, src, size);
18675 + if (size > INT_MAX)
18676 + return size;
18677 +
18678 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18679 + if (!__access_ok(VERIFY_WRITE, dst, size))
18680 + return size;
18681 +#endif
18682 +
18683 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18684 }
18685
18686 -extern long __copy_user_nocache(void *dst, const void __user *src,
18687 - unsigned size, int zerorest);
18688 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18689 + unsigned long size, int zerorest);
18690
18691 -static inline int
18692 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18693 +static inline unsigned long
18694 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18695 {
18696 might_fault();
18697 +
18698 + if (size > INT_MAX)
18699 + return size;
18700 +
18701 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18702 + if (!__access_ok(VERIFY_READ, src, size))
18703 + return size;
18704 +#endif
18705 +
18706 return __copy_user_nocache(dst, src, size, 1);
18707 }
18708
18709 -static inline int
18710 +static inline unsigned long
18711 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18712 - unsigned size)
18713 + unsigned long size)
18714 {
18715 + if (size > INT_MAX)
18716 + return size;
18717 +
18718 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18719 + if (!__access_ok(VERIFY_READ, src, size))
18720 + return size;
18721 +#endif
18722 +
18723 return __copy_user_nocache(dst, src, size, 0);
18724 }
18725
18726 unsigned long
18727 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18728 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18729
18730 #endif /* _ASM_X86_UACCESS_64_H */
18731 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18732 index 5b238981..77fdd78 100644
18733 --- a/arch/x86/include/asm/word-at-a-time.h
18734 +++ b/arch/x86/include/asm/word-at-a-time.h
18735 @@ -11,7 +11,7 @@
18736 * and shift, for example.
18737 */
18738 struct word_at_a_time {
18739 - const unsigned long one_bits, high_bits;
18740 + unsigned long one_bits, high_bits;
18741 };
18742
18743 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18744 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18745 index 828a156..650e625 100644
18746 --- a/arch/x86/include/asm/x86_init.h
18747 +++ b/arch/x86/include/asm/x86_init.h
18748 @@ -129,7 +129,7 @@ struct x86_init_ops {
18749 struct x86_init_timers timers;
18750 struct x86_init_iommu iommu;
18751 struct x86_init_pci pci;
18752 -};
18753 +} __no_const;
18754
18755 /**
18756 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18757 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18758 void (*setup_percpu_clockev)(void);
18759 void (*early_percpu_clock_init)(void);
18760 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18761 -};
18762 +} __no_const;
18763
18764 struct timespec;
18765
18766 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18767 void (*save_sched_clock_state)(void);
18768 void (*restore_sched_clock_state)(void);
18769 void (*apic_post_init)(void);
18770 -};
18771 +} __no_const;
18772
18773 struct pci_dev;
18774 struct msi_msg;
18775 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18776 void (*teardown_msi_irqs)(struct pci_dev *dev);
18777 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18778 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18779 -};
18780 +} __no_const;
18781
18782 struct IO_APIC_route_entry;
18783 struct io_apic_irq_attr;
18784 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18785 unsigned int destination, int vector,
18786 struct io_apic_irq_attr *attr);
18787 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18788 -};
18789 +} __no_const;
18790
18791 extern struct x86_init_ops x86_init;
18792 extern struct x86_cpuinit_ops x86_cpuinit;
18793 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
18794 index b913915..4f5a581 100644
18795 --- a/arch/x86/include/asm/xen/page.h
18796 +++ b/arch/x86/include/asm/xen/page.h
18797 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
18798 extern struct page *m2p_find_override(unsigned long mfn);
18799 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
18800
18801 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
18802 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
18803 {
18804 unsigned long mfn;
18805
18806 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18807 index 0415cda..3b22adc 100644
18808 --- a/arch/x86/include/asm/xsave.h
18809 +++ b/arch/x86/include/asm/xsave.h
18810 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18811 if (unlikely(err))
18812 return -EFAULT;
18813
18814 + pax_open_userland();
18815 __asm__ __volatile__(ASM_STAC "\n"
18816 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18817 + "1:"
18818 + __copyuser_seg
18819 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18820 "2: " ASM_CLAC "\n"
18821 ".section .fixup,\"ax\"\n"
18822 "3: movl $-1,%[err]\n"
18823 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18824 : [err] "=r" (err)
18825 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18826 : "memory");
18827 + pax_close_userland();
18828 return err;
18829 }
18830
18831 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18832 {
18833 int err;
18834 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18835 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18836 u32 lmask = mask;
18837 u32 hmask = mask >> 32;
18838
18839 + pax_open_userland();
18840 __asm__ __volatile__(ASM_STAC "\n"
18841 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18842 + "1:"
18843 + __copyuser_seg
18844 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18845 "2: " ASM_CLAC "\n"
18846 ".section .fixup,\"ax\"\n"
18847 "3: movl $-1,%[err]\n"
18848 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18849 : [err] "=r" (err)
18850 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18851 : "memory"); /* memory required? */
18852 + pax_close_userland();
18853 return err;
18854 }
18855
18856 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18857 index bbae024..e1528f9 100644
18858 --- a/arch/x86/include/uapi/asm/e820.h
18859 +++ b/arch/x86/include/uapi/asm/e820.h
18860 @@ -63,7 +63,7 @@ struct e820map {
18861 #define ISA_START_ADDRESS 0xa0000
18862 #define ISA_END_ADDRESS 0x100000
18863
18864 -#define BIOS_BEGIN 0x000a0000
18865 +#define BIOS_BEGIN 0x000c0000
18866 #define BIOS_END 0x00100000
18867
18868 #define BIOS_ROM_BASE 0xffe00000
18869 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18870 index a5408b9..5133813 100644
18871 --- a/arch/x86/kernel/Makefile
18872 +++ b/arch/x86/kernel/Makefile
18873 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18874 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18875 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18876 obj-y += probe_roms.o
18877 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18878 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18879 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18880 obj-y += syscall_$(BITS).o
18881 obj-$(CONFIG_X86_64) += vsyscall_64.o
18882 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18883 index 40c7660..f709f4b 100644
18884 --- a/arch/x86/kernel/acpi/boot.c
18885 +++ b/arch/x86/kernel/acpi/boot.c
18886 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18887 * If your system is blacklisted here, but you find that acpi=force
18888 * works for you, please contact linux-acpi@vger.kernel.org
18889 */
18890 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18891 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18892 /*
18893 * Boxes that need ACPI disabled
18894 */
18895 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18896 };
18897
18898 /* second table for DMI checks that should run after early-quirks */
18899 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18900 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18901 /*
18902 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18903 * which includes some code which overrides all temperature
18904 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18905 index 3312010..a65ca7b 100644
18906 --- a/arch/x86/kernel/acpi/sleep.c
18907 +++ b/arch/x86/kernel/acpi/sleep.c
18908 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18909 #else /* CONFIG_64BIT */
18910 #ifdef CONFIG_SMP
18911 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18912 +
18913 + pax_open_kernel();
18914 early_gdt_descr.address =
18915 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18916 + pax_close_kernel();
18917 +
18918 initial_gs = per_cpu_offset(smp_processor_id());
18919 #endif
18920 initial_code = (unsigned long)wakeup_long64;
18921 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18922 index d1daa66..59fecba 100644
18923 --- a/arch/x86/kernel/acpi/wakeup_32.S
18924 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18925 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18926 # and restore the stack ... but you need gdt for this to work
18927 movl saved_context_esp, %esp
18928
18929 - movl %cs:saved_magic, %eax
18930 - cmpl $0x12345678, %eax
18931 + cmpl $0x12345678, saved_magic
18932 jne bogus_magic
18933
18934 # jump to place where we left off
18935 - movl saved_eip, %eax
18936 - jmp *%eax
18937 + jmp *(saved_eip)
18938
18939 bogus_magic:
18940 jmp bogus_magic
18941 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18942 index 15e8563..323cbe1 100644
18943 --- a/arch/x86/kernel/alternative.c
18944 +++ b/arch/x86/kernel/alternative.c
18945 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18946 */
18947 for (a = start; a < end; a++) {
18948 instr = (u8 *)&a->instr_offset + a->instr_offset;
18949 +
18950 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18951 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18952 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18953 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18954 +#endif
18955 +
18956 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18957 BUG_ON(a->replacementlen > a->instrlen);
18958 BUG_ON(a->instrlen > sizeof(insnbuf));
18959 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18960 for (poff = start; poff < end; poff++) {
18961 u8 *ptr = (u8 *)poff + *poff;
18962
18963 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18964 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18965 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18966 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18967 +#endif
18968 +
18969 if (!*poff || ptr < text || ptr >= text_end)
18970 continue;
18971 /* turn DS segment override prefix into lock prefix */
18972 - if (*ptr == 0x3e)
18973 + if (*ktla_ktva(ptr) == 0x3e)
18974 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18975 }
18976 mutex_unlock(&text_mutex);
18977 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18978 for (poff = start; poff < end; poff++) {
18979 u8 *ptr = (u8 *)poff + *poff;
18980
18981 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18982 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18983 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18984 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18985 +#endif
18986 +
18987 if (!*poff || ptr < text || ptr >= text_end)
18988 continue;
18989 /* turn lock prefix into DS segment override prefix */
18990 - if (*ptr == 0xf0)
18991 + if (*ktla_ktva(ptr) == 0xf0)
18992 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18993 }
18994 mutex_unlock(&text_mutex);
18995 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18996
18997 BUG_ON(p->len > MAX_PATCH_LEN);
18998 /* prep the buffer with the original instructions */
18999 - memcpy(insnbuf, p->instr, p->len);
19000 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19001 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19002 (unsigned long)p->instr, p->len);
19003
19004 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19005 if (!uniproc_patched || num_possible_cpus() == 1)
19006 free_init_pages("SMP alternatives",
19007 (unsigned long)__smp_locks,
19008 - (unsigned long)__smp_locks_end);
19009 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19010 #endif
19011
19012 apply_paravirt(__parainstructions, __parainstructions_end);
19013 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19014 * instructions. And on the local CPU you need to be protected again NMI or MCE
19015 * handlers seeing an inconsistent instruction while you patch.
19016 */
19017 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19018 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19019 size_t len)
19020 {
19021 unsigned long flags;
19022 local_irq_save(flags);
19023 - memcpy(addr, opcode, len);
19024 +
19025 + pax_open_kernel();
19026 + memcpy(ktla_ktva(addr), opcode, len);
19027 sync_core();
19028 + pax_close_kernel();
19029 +
19030 local_irq_restore(flags);
19031 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19032 that causes hangs on some VIA CPUs. */
19033 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19034 */
19035 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19036 {
19037 - unsigned long flags;
19038 - char *vaddr;
19039 + unsigned char *vaddr = ktla_ktva(addr);
19040 struct page *pages[2];
19041 - int i;
19042 + size_t i;
19043
19044 if (!core_kernel_text((unsigned long)addr)) {
19045 - pages[0] = vmalloc_to_page(addr);
19046 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19047 + pages[0] = vmalloc_to_page(vaddr);
19048 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19049 } else {
19050 - pages[0] = virt_to_page(addr);
19051 + pages[0] = virt_to_page(vaddr);
19052 WARN_ON(!PageReserved(pages[0]));
19053 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19054 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19055 }
19056 BUG_ON(!pages[0]);
19057 - local_irq_save(flags);
19058 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19059 - if (pages[1])
19060 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19061 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19062 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19063 - clear_fixmap(FIX_TEXT_POKE0);
19064 - if (pages[1])
19065 - clear_fixmap(FIX_TEXT_POKE1);
19066 - local_flush_tlb();
19067 - sync_core();
19068 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19069 - that causes hangs on some VIA CPUs. */
19070 + text_poke_early(addr, opcode, len);
19071 for (i = 0; i < len; i++)
19072 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19073 - local_irq_restore(flags);
19074 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19075 return addr;
19076 }
19077
19078 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19079 if (likely(!bp_patching_in_progress))
19080 return 0;
19081
19082 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19083 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19084 return 0;
19085
19086 /* set up the specified breakpoint handler */
19087 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19088 */
19089 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19090 {
19091 - unsigned char int3 = 0xcc;
19092 + const unsigned char int3 = 0xcc;
19093
19094 bp_int3_handler = handler;
19095 bp_int3_addr = (u8 *)addr + sizeof(int3);
19096 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19097 index a7eb82d..f6e52d4 100644
19098 --- a/arch/x86/kernel/apic/apic.c
19099 +++ b/arch/x86/kernel/apic/apic.c
19100 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19101 /*
19102 * Debug level, exported for io_apic.c
19103 */
19104 -unsigned int apic_verbosity;
19105 +int apic_verbosity;
19106
19107 int pic_mode;
19108
19109 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19110 apic_write(APIC_ESR, 0);
19111 v1 = apic_read(APIC_ESR);
19112 ack_APIC_irq();
19113 - atomic_inc(&irq_err_count);
19114 + atomic_inc_unchecked(&irq_err_count);
19115
19116 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19117 smp_processor_id(), v0 , v1);
19118 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19119 index 00c77cf..2dc6a2d 100644
19120 --- a/arch/x86/kernel/apic/apic_flat_64.c
19121 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19122 @@ -157,7 +157,7 @@ static int flat_probe(void)
19123 return 1;
19124 }
19125
19126 -static struct apic apic_flat = {
19127 +static struct apic apic_flat __read_only = {
19128 .name = "flat",
19129 .probe = flat_probe,
19130 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19131 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19132 return 0;
19133 }
19134
19135 -static struct apic apic_physflat = {
19136 +static struct apic apic_physflat __read_only = {
19137
19138 .name = "physical flat",
19139 .probe = physflat_probe,
19140 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19141 index e145f28..2752888 100644
19142 --- a/arch/x86/kernel/apic/apic_noop.c
19143 +++ b/arch/x86/kernel/apic/apic_noop.c
19144 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19145 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19146 }
19147
19148 -struct apic apic_noop = {
19149 +struct apic apic_noop __read_only = {
19150 .name = "noop",
19151 .probe = noop_probe,
19152 .acpi_madt_oem_check = NULL,
19153 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19154 index d50e364..543bee3 100644
19155 --- a/arch/x86/kernel/apic/bigsmp_32.c
19156 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19157 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19158 return dmi_bigsmp;
19159 }
19160
19161 -static struct apic apic_bigsmp = {
19162 +static struct apic apic_bigsmp __read_only = {
19163
19164 .name = "bigsmp",
19165 .probe = probe_bigsmp,
19166 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19167 index c552247..587a316 100644
19168 --- a/arch/x86/kernel/apic/es7000_32.c
19169 +++ b/arch/x86/kernel/apic/es7000_32.c
19170 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19171 return ret && es7000_apic_is_cluster();
19172 }
19173
19174 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19175 -static struct apic __refdata apic_es7000_cluster = {
19176 +static struct apic apic_es7000_cluster __read_only = {
19177
19178 .name = "es7000",
19179 .probe = probe_es7000,
19180 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19181 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19182 };
19183
19184 -static struct apic __refdata apic_es7000 = {
19185 +static struct apic apic_es7000 __read_only = {
19186
19187 .name = "es7000",
19188 .probe = probe_es7000,
19189 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19190 index e63a5bd..c0babf8 100644
19191 --- a/arch/x86/kernel/apic/io_apic.c
19192 +++ b/arch/x86/kernel/apic/io_apic.c
19193 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19194 }
19195 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19196
19197 -void lock_vector_lock(void)
19198 +void lock_vector_lock(void) __acquires(vector_lock)
19199 {
19200 /* Used to the online set of cpus does not change
19201 * during assign_irq_vector.
19202 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19203 raw_spin_lock(&vector_lock);
19204 }
19205
19206 -void unlock_vector_lock(void)
19207 +void unlock_vector_lock(void) __releases(vector_lock)
19208 {
19209 raw_spin_unlock(&vector_lock);
19210 }
19211 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
19212 ack_APIC_irq();
19213 }
19214
19215 -atomic_t irq_mis_count;
19216 +atomic_unchecked_t irq_mis_count;
19217
19218 #ifdef CONFIG_GENERIC_PENDING_IRQ
19219 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19220 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
19221 * at the cpu.
19222 */
19223 if (!(v & (1 << (i & 0x1f)))) {
19224 - atomic_inc(&irq_mis_count);
19225 + atomic_inc_unchecked(&irq_mis_count);
19226
19227 eoi_ioapic_irq(irq, cfg);
19228 }
19229 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19230 index 1e42e8f..daacf44 100644
19231 --- a/arch/x86/kernel/apic/numaq_32.c
19232 +++ b/arch/x86/kernel/apic/numaq_32.c
19233 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19234 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19235 }
19236
19237 -/* Use __refdata to keep false positive warning calm. */
19238 -static struct apic __refdata apic_numaq = {
19239 +static struct apic apic_numaq __read_only = {
19240
19241 .name = "NUMAQ",
19242 .probe = probe_numaq,
19243 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19244 index eb35ef9..f184a21 100644
19245 --- a/arch/x86/kernel/apic/probe_32.c
19246 +++ b/arch/x86/kernel/apic/probe_32.c
19247 @@ -72,7 +72,7 @@ static int probe_default(void)
19248 return 1;
19249 }
19250
19251 -static struct apic apic_default = {
19252 +static struct apic apic_default __read_only = {
19253
19254 .name = "default",
19255 .probe = probe_default,
19256 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19257 index 77c95c0..434f8a4 100644
19258 --- a/arch/x86/kernel/apic/summit_32.c
19259 +++ b/arch/x86/kernel/apic/summit_32.c
19260 @@ -486,7 +486,7 @@ void setup_summit(void)
19261 }
19262 #endif
19263
19264 -static struct apic apic_summit = {
19265 +static struct apic apic_summit __read_only = {
19266
19267 .name = "summit",
19268 .probe = probe_summit,
19269 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19270 index 140e29d..d88bc95 100644
19271 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19272 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19273 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19274 return notifier_from_errno(err);
19275 }
19276
19277 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19278 +static struct notifier_block x2apic_cpu_notifier = {
19279 .notifier_call = update_clusterinfo,
19280 };
19281
19282 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19283 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19284 }
19285
19286 -static struct apic apic_x2apic_cluster = {
19287 +static struct apic apic_x2apic_cluster __read_only = {
19288
19289 .name = "cluster x2apic",
19290 .probe = x2apic_cluster_probe,
19291 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19292 index 562a76d..a003c0f 100644
19293 --- a/arch/x86/kernel/apic/x2apic_phys.c
19294 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19295 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19296 return apic == &apic_x2apic_phys;
19297 }
19298
19299 -static struct apic apic_x2apic_phys = {
19300 +static struct apic apic_x2apic_phys __read_only = {
19301
19302 .name = "physical x2apic",
19303 .probe = x2apic_phys_probe,
19304 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19305 index a419814..1dd34a0 100644
19306 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19307 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19308 @@ -357,7 +357,7 @@ static int uv_probe(void)
19309 return apic == &apic_x2apic_uv_x;
19310 }
19311
19312 -static struct apic __refdata apic_x2apic_uv_x = {
19313 +static struct apic apic_x2apic_uv_x __read_only = {
19314
19315 .name = "UV large system",
19316 .probe = uv_probe,
19317 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19318 index 3ab0343..814c4787 100644
19319 --- a/arch/x86/kernel/apm_32.c
19320 +++ b/arch/x86/kernel/apm_32.c
19321 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19322 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19323 * even though they are called in protected mode.
19324 */
19325 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19326 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19327 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19328
19329 static const char driver_version[] = "1.16ac"; /* no spaces */
19330 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19331 BUG_ON(cpu != 0);
19332 gdt = get_cpu_gdt_table(cpu);
19333 save_desc_40 = gdt[0x40 / 8];
19334 +
19335 + pax_open_kernel();
19336 gdt[0x40 / 8] = bad_bios_desc;
19337 + pax_close_kernel();
19338
19339 apm_irq_save(flags);
19340 APM_DO_SAVE_SEGS;
19341 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19342 &call->esi);
19343 APM_DO_RESTORE_SEGS;
19344 apm_irq_restore(flags);
19345 +
19346 + pax_open_kernel();
19347 gdt[0x40 / 8] = save_desc_40;
19348 + pax_close_kernel();
19349 +
19350 put_cpu();
19351
19352 return call->eax & 0xff;
19353 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19354 BUG_ON(cpu != 0);
19355 gdt = get_cpu_gdt_table(cpu);
19356 save_desc_40 = gdt[0x40 / 8];
19357 +
19358 + pax_open_kernel();
19359 gdt[0x40 / 8] = bad_bios_desc;
19360 + pax_close_kernel();
19361
19362 apm_irq_save(flags);
19363 APM_DO_SAVE_SEGS;
19364 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19365 &call->eax);
19366 APM_DO_RESTORE_SEGS;
19367 apm_irq_restore(flags);
19368 +
19369 + pax_open_kernel();
19370 gdt[0x40 / 8] = save_desc_40;
19371 + pax_close_kernel();
19372 +
19373 put_cpu();
19374 return error;
19375 }
19376 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19377 * code to that CPU.
19378 */
19379 gdt = get_cpu_gdt_table(0);
19380 +
19381 + pax_open_kernel();
19382 set_desc_base(&gdt[APM_CS >> 3],
19383 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19384 set_desc_base(&gdt[APM_CS_16 >> 3],
19385 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19386 set_desc_base(&gdt[APM_DS >> 3],
19387 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19388 + pax_close_kernel();
19389
19390 proc_create("apm", 0, NULL, &apm_file_ops);
19391
19392 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19393 index 2861082..6d4718e 100644
19394 --- a/arch/x86/kernel/asm-offsets.c
19395 +++ b/arch/x86/kernel/asm-offsets.c
19396 @@ -33,6 +33,8 @@ void common(void) {
19397 OFFSET(TI_status, thread_info, status);
19398 OFFSET(TI_addr_limit, thread_info, addr_limit);
19399 OFFSET(TI_preempt_count, thread_info, preempt_count);
19400 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19401 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19402
19403 BLANK();
19404 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19405 @@ -53,8 +55,26 @@ void common(void) {
19406 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19407 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19408 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19409 +
19410 +#ifdef CONFIG_PAX_KERNEXEC
19411 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19412 #endif
19413
19414 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19415 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19416 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19417 +#ifdef CONFIG_X86_64
19418 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19419 +#endif
19420 +#endif
19421 +
19422 +#endif
19423 +
19424 + BLANK();
19425 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19426 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19427 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19428 +
19429 #ifdef CONFIG_XEN
19430 BLANK();
19431 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19432 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19433 index e7c798b..2b2019b 100644
19434 --- a/arch/x86/kernel/asm-offsets_64.c
19435 +++ b/arch/x86/kernel/asm-offsets_64.c
19436 @@ -77,6 +77,7 @@ int main(void)
19437 BLANK();
19438 #undef ENTRY
19439
19440 + DEFINE(TSS_size, sizeof(struct tss_struct));
19441 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19442 BLANK();
19443
19444 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19445 index 47b56a7..efc2bc6 100644
19446 --- a/arch/x86/kernel/cpu/Makefile
19447 +++ b/arch/x86/kernel/cpu/Makefile
19448 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19449 CFLAGS_REMOVE_perf_event.o = -pg
19450 endif
19451
19452 -# Make sure load_percpu_segment has no stackprotector
19453 -nostackp := $(call cc-option, -fno-stack-protector)
19454 -CFLAGS_common.o := $(nostackp)
19455 -
19456 obj-y := intel_cacheinfo.o scattered.o topology.o
19457 obj-y += proc.o capflags.o powerflags.o common.o
19458 obj-y += rdrand.o
19459 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19460 index 903a264..fc955f3 100644
19461 --- a/arch/x86/kernel/cpu/amd.c
19462 +++ b/arch/x86/kernel/cpu/amd.c
19463 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19464 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19465 {
19466 /* AMD errata T13 (order #21922) */
19467 - if ((c->x86 == 6)) {
19468 + if (c->x86 == 6) {
19469 /* Duron Rev A0 */
19470 if (c->x86_model == 3 && c->x86_mask == 0)
19471 size = 64;
19472 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19473 index 2793d1f..5c04a30 100644
19474 --- a/arch/x86/kernel/cpu/common.c
19475 +++ b/arch/x86/kernel/cpu/common.c
19476 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19477
19478 static const struct cpu_dev *this_cpu = &default_cpu;
19479
19480 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19481 -#ifdef CONFIG_X86_64
19482 - /*
19483 - * We need valid kernel segments for data and code in long mode too
19484 - * IRET will check the segment types kkeil 2000/10/28
19485 - * Also sysret mandates a special GDT layout
19486 - *
19487 - * TLS descriptors are currently at a different place compared to i386.
19488 - * Hopefully nobody expects them at a fixed place (Wine?)
19489 - */
19490 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19491 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19492 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19493 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19494 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19495 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19496 -#else
19497 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19498 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19499 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19500 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19501 - /*
19502 - * Segments used for calling PnP BIOS have byte granularity.
19503 - * They code segments and data segments have fixed 64k limits,
19504 - * the transfer segment sizes are set at run time.
19505 - */
19506 - /* 32-bit code */
19507 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19508 - /* 16-bit code */
19509 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19510 - /* 16-bit data */
19511 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19512 - /* 16-bit data */
19513 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19514 - /* 16-bit data */
19515 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19516 - /*
19517 - * The APM segments have byte granularity and their bases
19518 - * are set at run time. All have 64k limits.
19519 - */
19520 - /* 32-bit code */
19521 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19522 - /* 16-bit code */
19523 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19524 - /* data */
19525 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19526 -
19527 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19528 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19529 - GDT_STACK_CANARY_INIT
19530 -#endif
19531 -} };
19532 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19533 -
19534 static int __init x86_xsave_setup(char *s)
19535 {
19536 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19537 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19538 set_in_cr4(X86_CR4_SMAP);
19539 }
19540
19541 +#ifdef CONFIG_X86_64
19542 +static __init int setup_disable_pcid(char *arg)
19543 +{
19544 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19545 +
19546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19547 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19548 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19549 +#endif
19550 +
19551 + return 1;
19552 +}
19553 +__setup("nopcid", setup_disable_pcid);
19554 +
19555 +static void setup_pcid(struct cpuinfo_x86 *c)
19556 +{
19557 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19558 +
19559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19560 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19561 + pax_open_kernel();
19562 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19563 + pax_close_kernel();
19564 + printk("PAX: slow and weak UDEREF enabled\n");
19565 + } else
19566 + printk("PAX: UDEREF disabled\n");
19567 +#endif
19568 +
19569 + return;
19570 + }
19571 +
19572 + printk("PAX: PCID detected\n");
19573 + set_in_cr4(X86_CR4_PCIDE);
19574 +
19575 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19576 + pax_open_kernel();
19577 + clone_pgd_mask = ~(pgdval_t)0UL;
19578 + pax_close_kernel();
19579 + if (pax_user_shadow_base)
19580 + printk("PAX: weak UDEREF enabled\n");
19581 + else {
19582 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19583 + printk("PAX: strong UDEREF enabled\n");
19584 + }
19585 +#endif
19586 +
19587 + if (cpu_has(c, X86_FEATURE_INVPCID))
19588 + printk("PAX: INVPCID detected\n");
19589 +}
19590 +#endif
19591 +
19592 /*
19593 * Some CPU features depend on higher CPUID levels, which may not always
19594 * be available due to CPUID level capping or broken virtualization
19595 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19596 {
19597 struct desc_ptr gdt_descr;
19598
19599 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19600 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19601 gdt_descr.size = GDT_SIZE - 1;
19602 load_gdt(&gdt_descr);
19603 /* Reload the per-cpu base */
19604 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19605 setup_smep(c);
19606 setup_smap(c);
19607
19608 +#ifdef CONFIG_X86_64
19609 + setup_pcid(c);
19610 +#endif
19611 +
19612 /*
19613 * The vendor-specific functions might have changed features.
19614 * Now we do "generic changes."
19615 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19616 /* Filter out anything that depends on CPUID levels we don't have */
19617 filter_cpuid_features(c, true);
19618
19619 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19620 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19621 +#endif
19622 +
19623 /* If the model name is still unset, do table lookup. */
19624 if (!c->x86_model_id[0]) {
19625 const char *p;
19626 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19627 }
19628 __setup("clearcpuid=", setup_disablecpuid);
19629
19630 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19631 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19632 +
19633 #ifdef CONFIG_X86_64
19634 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19635 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19636 - (unsigned long) debug_idt_table };
19637 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19638 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19639
19640 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19641 irq_stack_union) __aligned(PAGE_SIZE) __visible;
19642 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19643 EXPORT_PER_CPU_SYMBOL(current_task);
19644
19645 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19646 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19647 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19648 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19649
19650 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19651 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19652 load_ucode_ap();
19653
19654 cpu = stack_smp_processor_id();
19655 - t = &per_cpu(init_tss, cpu);
19656 + t = init_tss + cpu;
19657 oist = &per_cpu(orig_ist, cpu);
19658
19659 #ifdef CONFIG_NUMA
19660 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19661 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19662 barrier();
19663
19664 - x86_configure_nx();
19665 enable_x2apic();
19666
19667 /*
19668 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19669 {
19670 int cpu = smp_processor_id();
19671 struct task_struct *curr = current;
19672 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19673 + struct tss_struct *t = init_tss + cpu;
19674 struct thread_struct *thread = &curr->thread;
19675
19676 show_ucode_info_early();
19677 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19678 index 1414c90..1159406 100644
19679 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19680 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19681 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19682 };
19683
19684 #ifdef CONFIG_AMD_NB
19685 +static struct attribute *default_attrs_amd_nb[] = {
19686 + &type.attr,
19687 + &level.attr,
19688 + &coherency_line_size.attr,
19689 + &physical_line_partition.attr,
19690 + &ways_of_associativity.attr,
19691 + &number_of_sets.attr,
19692 + &size.attr,
19693 + &shared_cpu_map.attr,
19694 + &shared_cpu_list.attr,
19695 + NULL,
19696 + NULL,
19697 + NULL,
19698 + NULL
19699 +};
19700 +
19701 static struct attribute **amd_l3_attrs(void)
19702 {
19703 static struct attribute **attrs;
19704 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19705
19706 n = ARRAY_SIZE(default_attrs);
19707
19708 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19709 - n += 2;
19710 -
19711 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19712 - n += 1;
19713 -
19714 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19715 - if (attrs == NULL)
19716 - return attrs = default_attrs;
19717 -
19718 - for (n = 0; default_attrs[n]; n++)
19719 - attrs[n] = default_attrs[n];
19720 + attrs = default_attrs_amd_nb;
19721
19722 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19723 attrs[n++] = &cache_disable_0.attr;
19724 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19725 .default_attrs = default_attrs,
19726 };
19727
19728 +#ifdef CONFIG_AMD_NB
19729 +static struct kobj_type ktype_cache_amd_nb = {
19730 + .sysfs_ops = &sysfs_ops,
19731 + .default_attrs = default_attrs_amd_nb,
19732 +};
19733 +#endif
19734 +
19735 static struct kobj_type ktype_percpu_entry = {
19736 .sysfs_ops = &sysfs_ops,
19737 };
19738 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19739 return retval;
19740 }
19741
19742 +#ifdef CONFIG_AMD_NB
19743 + amd_l3_attrs();
19744 +#endif
19745 +
19746 for (i = 0; i < num_cache_leaves; i++) {
19747 + struct kobj_type *ktype;
19748 +
19749 this_object = INDEX_KOBJECT_PTR(cpu, i);
19750 this_object->cpu = cpu;
19751 this_object->index = i;
19752
19753 this_leaf = CPUID4_INFO_IDX(cpu, i);
19754
19755 - ktype_cache.default_attrs = default_attrs;
19756 + ktype = &ktype_cache;
19757 #ifdef CONFIG_AMD_NB
19758 if (this_leaf->base.nb)
19759 - ktype_cache.default_attrs = amd_l3_attrs();
19760 + ktype = &ktype_cache_amd_nb;
19761 #endif
19762 retval = kobject_init_and_add(&(this_object->kobj),
19763 - &ktype_cache,
19764 + ktype,
19765 per_cpu(ici_cache_kobject, cpu),
19766 "index%1lu", i);
19767 if (unlikely(retval)) {
19768 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19769 index b3218cd..99a75de 100644
19770 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19771 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19772 @@ -45,6 +45,7 @@
19773 #include <asm/processor.h>
19774 #include <asm/mce.h>
19775 #include <asm/msr.h>
19776 +#include <asm/local.h>
19777
19778 #include "mce-internal.h"
19779
19780 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
19781 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19782 m->cs, m->ip);
19783
19784 - if (m->cs == __KERNEL_CS)
19785 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19786 print_symbol("{%s}", m->ip);
19787 pr_cont("\n");
19788 }
19789 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
19790
19791 #define PANIC_TIMEOUT 5 /* 5 seconds */
19792
19793 -static atomic_t mce_paniced;
19794 +static atomic_unchecked_t mce_paniced;
19795
19796 static int fake_panic;
19797 -static atomic_t mce_fake_paniced;
19798 +static atomic_unchecked_t mce_fake_paniced;
19799
19800 /* Panic in progress. Enable interrupts and wait for final IPI */
19801 static void wait_for_panic(void)
19802 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19803 /*
19804 * Make sure only one CPU runs in machine check panic
19805 */
19806 - if (atomic_inc_return(&mce_paniced) > 1)
19807 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19808 wait_for_panic();
19809 barrier();
19810
19811 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19812 console_verbose();
19813 } else {
19814 /* Don't log too much for fake panic */
19815 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19816 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19817 return;
19818 }
19819 /* First print corrected ones that are still unlogged */
19820 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19821 if (!fake_panic) {
19822 if (panic_timeout == 0)
19823 panic_timeout = mca_cfg.panic_timeout;
19824 - panic(msg);
19825 + panic("%s", msg);
19826 } else
19827 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19828 }
19829 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
19830 * might have been modified by someone else.
19831 */
19832 rmb();
19833 - if (atomic_read(&mce_paniced))
19834 + if (atomic_read_unchecked(&mce_paniced))
19835 wait_for_panic();
19836 if (!mca_cfg.monarch_timeout)
19837 goto out;
19838 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19839 }
19840
19841 /* Call the installed machine check handler for this CPU setup. */
19842 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19843 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19844 unexpected_machine_check;
19845
19846 /*
19847 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19848 return;
19849 }
19850
19851 + pax_open_kernel();
19852 machine_check_vector = do_machine_check;
19853 + pax_close_kernel();
19854
19855 __mcheck_cpu_init_generic();
19856 __mcheck_cpu_init_vendor(c);
19857 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19858 */
19859
19860 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19861 -static int mce_chrdev_open_count; /* #times opened */
19862 +static local_t mce_chrdev_open_count; /* #times opened */
19863 static int mce_chrdev_open_exclu; /* already open exclusive? */
19864
19865 static int mce_chrdev_open(struct inode *inode, struct file *file)
19866 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19867 spin_lock(&mce_chrdev_state_lock);
19868
19869 if (mce_chrdev_open_exclu ||
19870 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19871 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19872 spin_unlock(&mce_chrdev_state_lock);
19873
19874 return -EBUSY;
19875 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19876
19877 if (file->f_flags & O_EXCL)
19878 mce_chrdev_open_exclu = 1;
19879 - mce_chrdev_open_count++;
19880 + local_inc(&mce_chrdev_open_count);
19881
19882 spin_unlock(&mce_chrdev_state_lock);
19883
19884 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19885 {
19886 spin_lock(&mce_chrdev_state_lock);
19887
19888 - mce_chrdev_open_count--;
19889 + local_dec(&mce_chrdev_open_count);
19890 mce_chrdev_open_exclu = 0;
19891
19892 spin_unlock(&mce_chrdev_state_lock);
19893 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
19894
19895 for (i = 0; i < mca_cfg.banks; i++) {
19896 struct mce_bank *b = &mce_banks[i];
19897 - struct device_attribute *a = &b->attr;
19898 + device_attribute_no_const *a = &b->attr;
19899
19900 sysfs_attr_init(&a->attr);
19901 a->attr.name = b->attrname;
19902 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
19903 static void mce_reset(void)
19904 {
19905 cpu_missing = 0;
19906 - atomic_set(&mce_fake_paniced, 0);
19907 + atomic_set_unchecked(&mce_fake_paniced, 0);
19908 atomic_set(&mce_executing, 0);
19909 atomic_set(&mce_callin, 0);
19910 atomic_set(&global_nwo, 0);
19911 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19912 index 1c044b1..37a2a43 100644
19913 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19914 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19915 @@ -11,6 +11,7 @@
19916 #include <asm/processor.h>
19917 #include <asm/mce.h>
19918 #include <asm/msr.h>
19919 +#include <asm/pgtable.h>
19920
19921 /* By default disabled */
19922 int mce_p5_enabled __read_mostly;
19923 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19924 if (!cpu_has(c, X86_FEATURE_MCE))
19925 return;
19926
19927 + pax_open_kernel();
19928 machine_check_vector = pentium_machine_check;
19929 + pax_close_kernel();
19930 /* Make sure the vector pointer is visible before we enable MCEs: */
19931 wmb();
19932
19933 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19934 index e9a701a..35317d6 100644
19935 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19936 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19937 @@ -10,6 +10,7 @@
19938 #include <asm/processor.h>
19939 #include <asm/mce.h>
19940 #include <asm/msr.h>
19941 +#include <asm/pgtable.h>
19942
19943 /* Machine check handler for WinChip C6: */
19944 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19945 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19946 {
19947 u32 lo, hi;
19948
19949 + pax_open_kernel();
19950 machine_check_vector = winchip_machine_check;
19951 + pax_close_kernel();
19952 /* Make sure the vector pointer is visible before we enable MCEs: */
19953 wmb();
19954
19955 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19956 index f961de9..8a9d332 100644
19957 --- a/arch/x86/kernel/cpu/mtrr/main.c
19958 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19959 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19960 u64 size_or_mask, size_and_mask;
19961 static bool mtrr_aps_delayed_init;
19962
19963 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19964 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19965
19966 const struct mtrr_ops *mtrr_if;
19967
19968 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19969 index df5e41f..816c719 100644
19970 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19971 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19972 @@ -25,7 +25,7 @@ struct mtrr_ops {
19973 int (*validate_add_page)(unsigned long base, unsigned long size,
19974 unsigned int type);
19975 int (*have_wrcomb)(void);
19976 -};
19977 +} __do_const;
19978
19979 extern int generic_get_free_region(unsigned long base, unsigned long size,
19980 int replace_reg);
19981 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19982 index 8a87a32..682a22a 100644
19983 --- a/arch/x86/kernel/cpu/perf_event.c
19984 +++ b/arch/x86/kernel/cpu/perf_event.c
19985 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19986 pr_info("no hardware sampling interrupt available.\n");
19987 }
19988
19989 -static struct attribute_group x86_pmu_format_group = {
19990 +static attribute_group_no_const x86_pmu_format_group = {
19991 .name = "format",
19992 .attrs = NULL,
19993 };
19994 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19995 NULL,
19996 };
19997
19998 -static struct attribute_group x86_pmu_events_group = {
19999 +static attribute_group_no_const x86_pmu_events_group = {
20000 .name = "events",
20001 .attrs = events_attr,
20002 };
20003 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20004 if (idx > GDT_ENTRIES)
20005 return 0;
20006
20007 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20008 + desc = get_cpu_gdt_table(smp_processor_id());
20009 }
20010
20011 return get_desc_base(desc + idx);
20012 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20013 break;
20014
20015 perf_callchain_store(entry, frame.return_address);
20016 - fp = frame.next_frame;
20017 + fp = (const void __force_user *)frame.next_frame;
20018 }
20019 }
20020
20021 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20022 index 639d128..e92d7e5 100644
20023 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20024 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20025 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20026 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20027 {
20028 struct attribute **attrs;
20029 - struct attribute_group *attr_group;
20030 + attribute_group_no_const *attr_group;
20031 int i = 0, j;
20032
20033 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20034 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20035 index f31a165..7b46cd8 100644
20036 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20037 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20038 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20039 * v2 and above have a perf capabilities MSR
20040 */
20041 if (version > 1) {
20042 - u64 capabilities;
20043 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20044
20045 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20046 - x86_pmu.intel_cap.capabilities = capabilities;
20047 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20048 + x86_pmu.intel_cap.capabilities = capabilities;
20049 }
20050
20051 intel_ds_init();
20052 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20053 index 4118f9f..f91d0ab 100644
20054 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20055 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20056 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20057 static int __init uncore_type_init(struct intel_uncore_type *type)
20058 {
20059 struct intel_uncore_pmu *pmus;
20060 - struct attribute_group *attr_group;
20061 + attribute_group_no_const *attr_group;
20062 struct attribute **attrs;
20063 int i, j;
20064
20065 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20066 index a80ab71..4089da5 100644
20067 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20068 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20069 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20070 struct uncore_event_desc {
20071 struct kobj_attribute attr;
20072 const char *config;
20073 -};
20074 +} __do_const;
20075
20076 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20077 { \
20078 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20079 index 7d9481c..99c7e4b 100644
20080 --- a/arch/x86/kernel/cpuid.c
20081 +++ b/arch/x86/kernel/cpuid.c
20082 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20083 return notifier_from_errno(err);
20084 }
20085
20086 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20087 +static struct notifier_block cpuid_class_cpu_notifier =
20088 {
20089 .notifier_call = cpuid_class_cpu_callback,
20090 };
20091 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20092 index e0e0841..da37e6f 100644
20093 --- a/arch/x86/kernel/crash.c
20094 +++ b/arch/x86/kernel/crash.c
20095 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20096 {
20097 #ifdef CONFIG_X86_32
20098 struct pt_regs fixed_regs;
20099 -#endif
20100
20101 -#ifdef CONFIG_X86_32
20102 - if (!user_mode_vm(regs)) {
20103 + if (!user_mode(regs)) {
20104 crash_fixup_ss_esp(&fixed_regs, regs);
20105 regs = &fixed_regs;
20106 }
20107 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20108 index afa64ad..dce67dd 100644
20109 --- a/arch/x86/kernel/crash_dump_64.c
20110 +++ b/arch/x86/kernel/crash_dump_64.c
20111 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20112 return -ENOMEM;
20113
20114 if (userbuf) {
20115 - if (copy_to_user(buf, vaddr + offset, csize)) {
20116 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20117 iounmap(vaddr);
20118 return -EFAULT;
20119 }
20120 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20121 index 5d3fe8d..02e1429 100644
20122 --- a/arch/x86/kernel/doublefault.c
20123 +++ b/arch/x86/kernel/doublefault.c
20124 @@ -13,7 +13,7 @@
20125
20126 #define DOUBLEFAULT_STACKSIZE (1024)
20127 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20128 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20129 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20130
20131 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20132
20133 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20134 unsigned long gdt, tss;
20135
20136 native_store_gdt(&gdt_desc);
20137 - gdt = gdt_desc.address;
20138 + gdt = (unsigned long)gdt_desc.address;
20139
20140 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20141
20142 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20143 /* 0x2 bit is always set */
20144 .flags = X86_EFLAGS_SF | 0x2,
20145 .sp = STACK_START,
20146 - .es = __USER_DS,
20147 + .es = __KERNEL_DS,
20148 .cs = __KERNEL_CS,
20149 .ss = __KERNEL_DS,
20150 - .ds = __USER_DS,
20151 + .ds = __KERNEL_DS,
20152 .fs = __KERNEL_PERCPU,
20153
20154 .__cr3 = __pa_nodebug(swapper_pg_dir),
20155 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20156 index deb6421..76bbc12 100644
20157 --- a/arch/x86/kernel/dumpstack.c
20158 +++ b/arch/x86/kernel/dumpstack.c
20159 @@ -2,6 +2,9 @@
20160 * Copyright (C) 1991, 1992 Linus Torvalds
20161 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20162 */
20163 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20164 +#define __INCLUDED_BY_HIDESYM 1
20165 +#endif
20166 #include <linux/kallsyms.h>
20167 #include <linux/kprobes.h>
20168 #include <linux/uaccess.h>
20169 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20170 static void
20171 print_ftrace_graph_addr(unsigned long addr, void *data,
20172 const struct stacktrace_ops *ops,
20173 - struct thread_info *tinfo, int *graph)
20174 + struct task_struct *task, int *graph)
20175 {
20176 - struct task_struct *task;
20177 unsigned long ret_addr;
20178 int index;
20179
20180 if (addr != (unsigned long)return_to_handler)
20181 return;
20182
20183 - task = tinfo->task;
20184 index = task->curr_ret_stack;
20185
20186 if (!task->ret_stack || index < *graph)
20187 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20188 static inline void
20189 print_ftrace_graph_addr(unsigned long addr, void *data,
20190 const struct stacktrace_ops *ops,
20191 - struct thread_info *tinfo, int *graph)
20192 + struct task_struct *task, int *graph)
20193 { }
20194 #endif
20195
20196 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20197 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20198 */
20199
20200 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20201 - void *p, unsigned int size, void *end)
20202 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20203 {
20204 - void *t = tinfo;
20205 if (end) {
20206 if (p < end && p >= (end-THREAD_SIZE))
20207 return 1;
20208 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20209 }
20210
20211 unsigned long
20212 -print_context_stack(struct thread_info *tinfo,
20213 +print_context_stack(struct task_struct *task, void *stack_start,
20214 unsigned long *stack, unsigned long bp,
20215 const struct stacktrace_ops *ops, void *data,
20216 unsigned long *end, int *graph)
20217 {
20218 struct stack_frame *frame = (struct stack_frame *)bp;
20219
20220 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20221 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20222 unsigned long addr;
20223
20224 addr = *stack;
20225 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20226 } else {
20227 ops->address(data, addr, 0);
20228 }
20229 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20230 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20231 }
20232 stack++;
20233 }
20234 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20235 EXPORT_SYMBOL_GPL(print_context_stack);
20236
20237 unsigned long
20238 -print_context_stack_bp(struct thread_info *tinfo,
20239 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20240 unsigned long *stack, unsigned long bp,
20241 const struct stacktrace_ops *ops, void *data,
20242 unsigned long *end, int *graph)
20243 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20244 struct stack_frame *frame = (struct stack_frame *)bp;
20245 unsigned long *ret_addr = &frame->return_address;
20246
20247 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20248 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20249 unsigned long addr = *ret_addr;
20250
20251 if (!__kernel_text_address(addr))
20252 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20253 ops->address(data, addr, 1);
20254 frame = frame->next_frame;
20255 ret_addr = &frame->return_address;
20256 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20257 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20258 }
20259
20260 return (unsigned long)frame;
20261 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20262 static void print_trace_address(void *data, unsigned long addr, int reliable)
20263 {
20264 touch_nmi_watchdog();
20265 - printk(data);
20266 + printk("%s", (char *)data);
20267 printk_address(addr, reliable);
20268 }
20269
20270 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20271 }
20272 EXPORT_SYMBOL_GPL(oops_begin);
20273
20274 +extern void gr_handle_kernel_exploit(void);
20275 +
20276 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20277 {
20278 if (regs && kexec_should_crash(current))
20279 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20280 panic("Fatal exception in interrupt");
20281 if (panic_on_oops)
20282 panic("Fatal exception");
20283 - do_exit(signr);
20284 +
20285 + gr_handle_kernel_exploit();
20286 +
20287 + do_group_exit(signr);
20288 }
20289
20290 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20291 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20292 print_modules();
20293 show_regs(regs);
20294 #ifdef CONFIG_X86_32
20295 - if (user_mode_vm(regs)) {
20296 + if (user_mode(regs)) {
20297 sp = regs->sp;
20298 ss = regs->ss & 0xffff;
20299 } else {
20300 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20301 unsigned long flags = oops_begin();
20302 int sig = SIGSEGV;
20303
20304 - if (!user_mode_vm(regs))
20305 + if (!user_mode(regs))
20306 report_bug(regs->ip, regs);
20307
20308 if (__die(str, regs, err))
20309 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20310 index f2a1770..540657f 100644
20311 --- a/arch/x86/kernel/dumpstack_32.c
20312 +++ b/arch/x86/kernel/dumpstack_32.c
20313 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20314 bp = stack_frame(task, regs);
20315
20316 for (;;) {
20317 - struct thread_info *context;
20318 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20319
20320 - context = (struct thread_info *)
20321 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20322 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20323 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20324
20325 - stack = (unsigned long *)context->previous_esp;
20326 - if (!stack)
20327 + if (stack_start == task_stack_page(task))
20328 break;
20329 + stack = *(unsigned long **)stack_start;
20330 if (ops->stack(data, "IRQ") < 0)
20331 break;
20332 touch_nmi_watchdog();
20333 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20334 int i;
20335
20336 show_regs_print_info(KERN_EMERG);
20337 - __show_regs(regs, !user_mode_vm(regs));
20338 + __show_regs(regs, !user_mode(regs));
20339
20340 /*
20341 * When in-kernel, we also print out the stack and code at the
20342 * time of the fault..
20343 */
20344 - if (!user_mode_vm(regs)) {
20345 + if (!user_mode(regs)) {
20346 unsigned int code_prologue = code_bytes * 43 / 64;
20347 unsigned int code_len = code_bytes;
20348 unsigned char c;
20349 u8 *ip;
20350 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20351
20352 pr_emerg("Stack:\n");
20353 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20354
20355 pr_emerg("Code:");
20356
20357 - ip = (u8 *)regs->ip - code_prologue;
20358 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20359 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20360 /* try starting at IP */
20361 - ip = (u8 *)regs->ip;
20362 + ip = (u8 *)regs->ip + cs_base;
20363 code_len = code_len - code_prologue + 1;
20364 }
20365 for (i = 0; i < code_len; i++, ip++) {
20366 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20367 pr_cont(" Bad EIP value.");
20368 break;
20369 }
20370 - if (ip == (u8 *)regs->ip)
20371 + if (ip == (u8 *)regs->ip + cs_base)
20372 pr_cont(" <%02x>", c);
20373 else
20374 pr_cont(" %02x", c);
20375 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20376 {
20377 unsigned short ud2;
20378
20379 + ip = ktla_ktva(ip);
20380 if (ip < PAGE_OFFSET)
20381 return 0;
20382 if (probe_kernel_address((unsigned short *)ip, ud2))
20383 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20384
20385 return ud2 == 0x0b0f;
20386 }
20387 +
20388 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20389 +void pax_check_alloca(unsigned long size)
20390 +{
20391 + unsigned long sp = (unsigned long)&sp, stack_left;
20392 +
20393 + /* all kernel stacks are of the same size */
20394 + stack_left = sp & (THREAD_SIZE - 1);
20395 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20396 +}
20397 +EXPORT_SYMBOL(pax_check_alloca);
20398 +#endif
20399 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20400 index addb207..99635fa 100644
20401 --- a/arch/x86/kernel/dumpstack_64.c
20402 +++ b/arch/x86/kernel/dumpstack_64.c
20403 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20404 unsigned long *irq_stack_end =
20405 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20406 unsigned used = 0;
20407 - struct thread_info *tinfo;
20408 int graph = 0;
20409 unsigned long dummy;
20410 + void *stack_start;
20411
20412 if (!task)
20413 task = current;
20414 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20415 * current stack address. If the stacks consist of nested
20416 * exceptions
20417 */
20418 - tinfo = task_thread_info(task);
20419 for (;;) {
20420 char *id;
20421 unsigned long *estack_end;
20422 +
20423 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20424 &used, &id);
20425
20426 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20427 if (ops->stack(data, id) < 0)
20428 break;
20429
20430 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20431 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20432 data, estack_end, &graph);
20433 ops->stack(data, "<EOE>");
20434 /*
20435 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20436 * second-to-last pointer (index -2 to end) in the
20437 * exception stack:
20438 */
20439 + if ((u16)estack_end[-1] != __KERNEL_DS)
20440 + goto out;
20441 stack = (unsigned long *) estack_end[-2];
20442 continue;
20443 }
20444 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20445 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20446 if (ops->stack(data, "IRQ") < 0)
20447 break;
20448 - bp = ops->walk_stack(tinfo, stack, bp,
20449 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20450 ops, data, irq_stack_end, &graph);
20451 /*
20452 * We link to the next stack (which would be
20453 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20454 /*
20455 * This handles the process stack:
20456 */
20457 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20458 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20459 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20460 +out:
20461 put_cpu();
20462 }
20463 EXPORT_SYMBOL(dump_trace);
20464 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20465
20466 return ud2 == 0x0b0f;
20467 }
20468 +
20469 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20470 +void pax_check_alloca(unsigned long size)
20471 +{
20472 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20473 + unsigned cpu, used;
20474 + char *id;
20475 +
20476 + /* check the process stack first */
20477 + stack_start = (unsigned long)task_stack_page(current);
20478 + stack_end = stack_start + THREAD_SIZE;
20479 + if (likely(stack_start <= sp && sp < stack_end)) {
20480 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20481 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20482 + return;
20483 + }
20484 +
20485 + cpu = get_cpu();
20486 +
20487 + /* check the irq stacks */
20488 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20489 + stack_start = stack_end - IRQ_STACK_SIZE;
20490 + if (stack_start <= sp && sp < stack_end) {
20491 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20492 + put_cpu();
20493 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20494 + return;
20495 + }
20496 +
20497 + /* check the exception stacks */
20498 + used = 0;
20499 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20500 + stack_start = stack_end - EXCEPTION_STKSZ;
20501 + if (stack_end && stack_start <= sp && sp < stack_end) {
20502 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20503 + put_cpu();
20504 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20505 + return;
20506 + }
20507 +
20508 + put_cpu();
20509 +
20510 + /* unknown stack */
20511 + BUG();
20512 +}
20513 +EXPORT_SYMBOL(pax_check_alloca);
20514 +#endif
20515 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20516 index 174da5f..5e55606 100644
20517 --- a/arch/x86/kernel/e820.c
20518 +++ b/arch/x86/kernel/e820.c
20519 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20520
20521 static void early_panic(char *msg)
20522 {
20523 - early_printk(msg);
20524 - panic(msg);
20525 + early_printk("%s", msg);
20526 + panic("%s", msg);
20527 }
20528
20529 static int userdef __initdata;
20530 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20531 index d15f575..d692043 100644
20532 --- a/arch/x86/kernel/early_printk.c
20533 +++ b/arch/x86/kernel/early_printk.c
20534 @@ -7,6 +7,7 @@
20535 #include <linux/pci_regs.h>
20536 #include <linux/pci_ids.h>
20537 #include <linux/errno.h>
20538 +#include <linux/sched.h>
20539 #include <asm/io.h>
20540 #include <asm/processor.h>
20541 #include <asm/fcntl.h>
20542 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20543 index f0dcb0c..9f39b80 100644
20544 --- a/arch/x86/kernel/entry_32.S
20545 +++ b/arch/x86/kernel/entry_32.S
20546 @@ -177,13 +177,153 @@
20547 /*CFI_REL_OFFSET gs, PT_GS*/
20548 .endm
20549 .macro SET_KERNEL_GS reg
20550 +
20551 +#ifdef CONFIG_CC_STACKPROTECTOR
20552 movl $(__KERNEL_STACK_CANARY), \reg
20553 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20554 + movl $(__USER_DS), \reg
20555 +#else
20556 + xorl \reg, \reg
20557 +#endif
20558 +
20559 movl \reg, %gs
20560 .endm
20561
20562 #endif /* CONFIG_X86_32_LAZY_GS */
20563
20564 -.macro SAVE_ALL
20565 +.macro pax_enter_kernel
20566 +#ifdef CONFIG_PAX_KERNEXEC
20567 + call pax_enter_kernel
20568 +#endif
20569 +.endm
20570 +
20571 +.macro pax_exit_kernel
20572 +#ifdef CONFIG_PAX_KERNEXEC
20573 + call pax_exit_kernel
20574 +#endif
20575 +.endm
20576 +
20577 +#ifdef CONFIG_PAX_KERNEXEC
20578 +ENTRY(pax_enter_kernel)
20579 +#ifdef CONFIG_PARAVIRT
20580 + pushl %eax
20581 + pushl %ecx
20582 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20583 + mov %eax, %esi
20584 +#else
20585 + mov %cr0, %esi
20586 +#endif
20587 + bts $16, %esi
20588 + jnc 1f
20589 + mov %cs, %esi
20590 + cmp $__KERNEL_CS, %esi
20591 + jz 3f
20592 + ljmp $__KERNEL_CS, $3f
20593 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20594 +2:
20595 +#ifdef CONFIG_PARAVIRT
20596 + mov %esi, %eax
20597 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20598 +#else
20599 + mov %esi, %cr0
20600 +#endif
20601 +3:
20602 +#ifdef CONFIG_PARAVIRT
20603 + popl %ecx
20604 + popl %eax
20605 +#endif
20606 + ret
20607 +ENDPROC(pax_enter_kernel)
20608 +
20609 +ENTRY(pax_exit_kernel)
20610 +#ifdef CONFIG_PARAVIRT
20611 + pushl %eax
20612 + pushl %ecx
20613 +#endif
20614 + mov %cs, %esi
20615 + cmp $__KERNEXEC_KERNEL_CS, %esi
20616 + jnz 2f
20617 +#ifdef CONFIG_PARAVIRT
20618 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20619 + mov %eax, %esi
20620 +#else
20621 + mov %cr0, %esi
20622 +#endif
20623 + btr $16, %esi
20624 + ljmp $__KERNEL_CS, $1f
20625 +1:
20626 +#ifdef CONFIG_PARAVIRT
20627 + mov %esi, %eax
20628 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20629 +#else
20630 + mov %esi, %cr0
20631 +#endif
20632 +2:
20633 +#ifdef CONFIG_PARAVIRT
20634 + popl %ecx
20635 + popl %eax
20636 +#endif
20637 + ret
20638 +ENDPROC(pax_exit_kernel)
20639 +#endif
20640 +
20641 + .macro pax_erase_kstack
20642 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20643 + call pax_erase_kstack
20644 +#endif
20645 + .endm
20646 +
20647 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20648 +/*
20649 + * ebp: thread_info
20650 + */
20651 +ENTRY(pax_erase_kstack)
20652 + pushl %edi
20653 + pushl %ecx
20654 + pushl %eax
20655 +
20656 + mov TI_lowest_stack(%ebp), %edi
20657 + mov $-0xBEEF, %eax
20658 + std
20659 +
20660 +1: mov %edi, %ecx
20661 + and $THREAD_SIZE_asm - 1, %ecx
20662 + shr $2, %ecx
20663 + repne scasl
20664 + jecxz 2f
20665 +
20666 + cmp $2*16, %ecx
20667 + jc 2f
20668 +
20669 + mov $2*16, %ecx
20670 + repe scasl
20671 + jecxz 2f
20672 + jne 1b
20673 +
20674 +2: cld
20675 + mov %esp, %ecx
20676 + sub %edi, %ecx
20677 +
20678 + cmp $THREAD_SIZE_asm, %ecx
20679 + jb 3f
20680 + ud2
20681 +3:
20682 +
20683 + shr $2, %ecx
20684 + rep stosl
20685 +
20686 + mov TI_task_thread_sp0(%ebp), %edi
20687 + sub $128, %edi
20688 + mov %edi, TI_lowest_stack(%ebp)
20689 +
20690 + popl %eax
20691 + popl %ecx
20692 + popl %edi
20693 + ret
20694 +ENDPROC(pax_erase_kstack)
20695 +#endif
20696 +
20697 +.macro __SAVE_ALL _DS
20698 cld
20699 PUSH_GS
20700 pushl_cfi %fs
20701 @@ -206,7 +346,7 @@
20702 CFI_REL_OFFSET ecx, 0
20703 pushl_cfi %ebx
20704 CFI_REL_OFFSET ebx, 0
20705 - movl $(__USER_DS), %edx
20706 + movl $\_DS, %edx
20707 movl %edx, %ds
20708 movl %edx, %es
20709 movl $(__KERNEL_PERCPU), %edx
20710 @@ -214,6 +354,15 @@
20711 SET_KERNEL_GS %edx
20712 .endm
20713
20714 +.macro SAVE_ALL
20715 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20716 + __SAVE_ALL __KERNEL_DS
20717 + pax_enter_kernel
20718 +#else
20719 + __SAVE_ALL __USER_DS
20720 +#endif
20721 +.endm
20722 +
20723 .macro RESTORE_INT_REGS
20724 popl_cfi %ebx
20725 CFI_RESTORE ebx
20726 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20727 popfl_cfi
20728 jmp syscall_exit
20729 CFI_ENDPROC
20730 -END(ret_from_fork)
20731 +ENDPROC(ret_from_fork)
20732
20733 ENTRY(ret_from_kernel_thread)
20734 CFI_STARTPROC
20735 @@ -344,7 +493,15 @@ ret_from_intr:
20736 andl $SEGMENT_RPL_MASK, %eax
20737 #endif
20738 cmpl $USER_RPL, %eax
20739 +
20740 +#ifdef CONFIG_PAX_KERNEXEC
20741 + jae resume_userspace
20742 +
20743 + pax_exit_kernel
20744 + jmp resume_kernel
20745 +#else
20746 jb resume_kernel # not returning to v8086 or userspace
20747 +#endif
20748
20749 ENTRY(resume_userspace)
20750 LOCKDEP_SYS_EXIT
20751 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20752 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20753 # int/exception return?
20754 jne work_pending
20755 - jmp restore_all
20756 -END(ret_from_exception)
20757 + jmp restore_all_pax
20758 +ENDPROC(ret_from_exception)
20759
20760 #ifdef CONFIG_PREEMPT
20761 ENTRY(resume_kernel)
20762 @@ -372,7 +529,7 @@ need_resched:
20763 jz restore_all
20764 call preempt_schedule_irq
20765 jmp need_resched
20766 -END(resume_kernel)
20767 +ENDPROC(resume_kernel)
20768 #endif
20769 CFI_ENDPROC
20770 /*
20771 @@ -406,30 +563,45 @@ sysenter_past_esp:
20772 /*CFI_REL_OFFSET cs, 0*/
20773 /*
20774 * Push current_thread_info()->sysenter_return to the stack.
20775 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20776 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20777 */
20778 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20779 + pushl_cfi $0
20780 CFI_REL_OFFSET eip, 0
20781
20782 pushl_cfi %eax
20783 SAVE_ALL
20784 + GET_THREAD_INFO(%ebp)
20785 + movl TI_sysenter_return(%ebp),%ebp
20786 + movl %ebp,PT_EIP(%esp)
20787 ENABLE_INTERRUPTS(CLBR_NONE)
20788
20789 /*
20790 * Load the potential sixth argument from user stack.
20791 * Careful about security.
20792 */
20793 + movl PT_OLDESP(%esp),%ebp
20794 +
20795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20796 + mov PT_OLDSS(%esp),%ds
20797 +1: movl %ds:(%ebp),%ebp
20798 + push %ss
20799 + pop %ds
20800 +#else
20801 cmpl $__PAGE_OFFSET-3,%ebp
20802 jae syscall_fault
20803 ASM_STAC
20804 1: movl (%ebp),%ebp
20805 ASM_CLAC
20806 +#endif
20807 +
20808 movl %ebp,PT_EBP(%esp)
20809 _ASM_EXTABLE(1b,syscall_fault)
20810
20811 GET_THREAD_INFO(%ebp)
20812
20813 +#ifdef CONFIG_PAX_RANDKSTACK
20814 + pax_erase_kstack
20815 +#endif
20816 +
20817 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20818 jnz sysenter_audit
20819 sysenter_do_call:
20820 @@ -444,12 +616,24 @@ sysenter_do_call:
20821 testl $_TIF_ALLWORK_MASK, %ecx
20822 jne sysexit_audit
20823 sysenter_exit:
20824 +
20825 +#ifdef CONFIG_PAX_RANDKSTACK
20826 + pushl_cfi %eax
20827 + movl %esp, %eax
20828 + call pax_randomize_kstack
20829 + popl_cfi %eax
20830 +#endif
20831 +
20832 + pax_erase_kstack
20833 +
20834 /* if something modifies registers it must also disable sysexit */
20835 movl PT_EIP(%esp), %edx
20836 movl PT_OLDESP(%esp), %ecx
20837 xorl %ebp,%ebp
20838 TRACE_IRQS_ON
20839 1: mov PT_FS(%esp), %fs
20840 +2: mov PT_DS(%esp), %ds
20841 +3: mov PT_ES(%esp), %es
20842 PTGS_TO_GS
20843 ENABLE_INTERRUPTS_SYSEXIT
20844
20845 @@ -466,6 +650,9 @@ sysenter_audit:
20846 movl %eax,%edx /* 2nd arg: syscall number */
20847 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20848 call __audit_syscall_entry
20849 +
20850 + pax_erase_kstack
20851 +
20852 pushl_cfi %ebx
20853 movl PT_EAX(%esp),%eax /* reload syscall number */
20854 jmp sysenter_do_call
20855 @@ -491,10 +678,16 @@ sysexit_audit:
20856
20857 CFI_ENDPROC
20858 .pushsection .fixup,"ax"
20859 -2: movl $0,PT_FS(%esp)
20860 +4: movl $0,PT_FS(%esp)
20861 + jmp 1b
20862 +5: movl $0,PT_DS(%esp)
20863 + jmp 1b
20864 +6: movl $0,PT_ES(%esp)
20865 jmp 1b
20866 .popsection
20867 - _ASM_EXTABLE(1b,2b)
20868 + _ASM_EXTABLE(1b,4b)
20869 + _ASM_EXTABLE(2b,5b)
20870 + _ASM_EXTABLE(3b,6b)
20871 PTGS_TO_GS_EX
20872 ENDPROC(ia32_sysenter_target)
20873
20874 @@ -509,6 +702,11 @@ ENTRY(system_call)
20875 pushl_cfi %eax # save orig_eax
20876 SAVE_ALL
20877 GET_THREAD_INFO(%ebp)
20878 +
20879 +#ifdef CONFIG_PAX_RANDKSTACK
20880 + pax_erase_kstack
20881 +#endif
20882 +
20883 # system call tracing in operation / emulation
20884 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20885 jnz syscall_trace_entry
20886 @@ -527,6 +725,15 @@ syscall_exit:
20887 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20888 jne syscall_exit_work
20889
20890 +restore_all_pax:
20891 +
20892 +#ifdef CONFIG_PAX_RANDKSTACK
20893 + movl %esp, %eax
20894 + call pax_randomize_kstack
20895 +#endif
20896 +
20897 + pax_erase_kstack
20898 +
20899 restore_all:
20900 TRACE_IRQS_IRET
20901 restore_all_notrace:
20902 @@ -583,14 +790,34 @@ ldt_ss:
20903 * compensating for the offset by changing to the ESPFIX segment with
20904 * a base address that matches for the difference.
20905 */
20906 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20907 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20908 mov %esp, %edx /* load kernel esp */
20909 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20910 mov %dx, %ax /* eax: new kernel esp */
20911 sub %eax, %edx /* offset (low word is 0) */
20912 +#ifdef CONFIG_SMP
20913 + movl PER_CPU_VAR(cpu_number), %ebx
20914 + shll $PAGE_SHIFT_asm, %ebx
20915 + addl $cpu_gdt_table, %ebx
20916 +#else
20917 + movl $cpu_gdt_table, %ebx
20918 +#endif
20919 shr $16, %edx
20920 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20921 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20922 +
20923 +#ifdef CONFIG_PAX_KERNEXEC
20924 + mov %cr0, %esi
20925 + btr $16, %esi
20926 + mov %esi, %cr0
20927 +#endif
20928 +
20929 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20930 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20931 +
20932 +#ifdef CONFIG_PAX_KERNEXEC
20933 + bts $16, %esi
20934 + mov %esi, %cr0
20935 +#endif
20936 +
20937 pushl_cfi $__ESPFIX_SS
20938 pushl_cfi %eax /* new kernel esp */
20939 /* Disable interrupts, but do not irqtrace this section: we
20940 @@ -619,20 +846,18 @@ work_resched:
20941 movl TI_flags(%ebp), %ecx
20942 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20943 # than syscall tracing?
20944 - jz restore_all
20945 + jz restore_all_pax
20946 testb $_TIF_NEED_RESCHED, %cl
20947 jnz work_resched
20948
20949 work_notifysig: # deal with pending signals and
20950 # notify-resume requests
20951 + movl %esp, %eax
20952 #ifdef CONFIG_VM86
20953 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20954 - movl %esp, %eax
20955 jne work_notifysig_v86 # returning to kernel-space or
20956 # vm86-space
20957 1:
20958 -#else
20959 - movl %esp, %eax
20960 #endif
20961 TRACE_IRQS_ON
20962 ENABLE_INTERRUPTS(CLBR_NONE)
20963 @@ -653,7 +878,7 @@ work_notifysig_v86:
20964 movl %eax, %esp
20965 jmp 1b
20966 #endif
20967 -END(work_pending)
20968 +ENDPROC(work_pending)
20969
20970 # perform syscall exit tracing
20971 ALIGN
20972 @@ -661,11 +886,14 @@ syscall_trace_entry:
20973 movl $-ENOSYS,PT_EAX(%esp)
20974 movl %esp, %eax
20975 call syscall_trace_enter
20976 +
20977 + pax_erase_kstack
20978 +
20979 /* What it returned is what we'll actually use. */
20980 cmpl $(NR_syscalls), %eax
20981 jnae syscall_call
20982 jmp syscall_exit
20983 -END(syscall_trace_entry)
20984 +ENDPROC(syscall_trace_entry)
20985
20986 # perform syscall exit tracing
20987 ALIGN
20988 @@ -678,21 +906,25 @@ syscall_exit_work:
20989 movl %esp, %eax
20990 call syscall_trace_leave
20991 jmp resume_userspace
20992 -END(syscall_exit_work)
20993 +ENDPROC(syscall_exit_work)
20994 CFI_ENDPROC
20995
20996 RING0_INT_FRAME # can't unwind into user space anyway
20997 syscall_fault:
20998 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20999 + push %ss
21000 + pop %ds
21001 +#endif
21002 ASM_CLAC
21003 GET_THREAD_INFO(%ebp)
21004 movl $-EFAULT,PT_EAX(%esp)
21005 jmp resume_userspace
21006 -END(syscall_fault)
21007 +ENDPROC(syscall_fault)
21008
21009 syscall_badsys:
21010 movl $-ENOSYS,PT_EAX(%esp)
21011 jmp resume_userspace
21012 -END(syscall_badsys)
21013 +ENDPROC(syscall_badsys)
21014 CFI_ENDPROC
21015 /*
21016 * End of kprobes section
21017 @@ -708,8 +940,15 @@ END(syscall_badsys)
21018 * normal stack and adjusts ESP with the matching offset.
21019 */
21020 /* fixup the stack */
21021 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21022 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21023 +#ifdef CONFIG_SMP
21024 + movl PER_CPU_VAR(cpu_number), %ebx
21025 + shll $PAGE_SHIFT_asm, %ebx
21026 + addl $cpu_gdt_table, %ebx
21027 +#else
21028 + movl $cpu_gdt_table, %ebx
21029 +#endif
21030 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21031 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21032 shl $16, %eax
21033 addl %esp, %eax /* the adjusted stack pointer */
21034 pushl_cfi $__KERNEL_DS
21035 @@ -762,7 +1001,7 @@ vector=vector+1
21036 .endr
21037 2: jmp common_interrupt
21038 .endr
21039 -END(irq_entries_start)
21040 +ENDPROC(irq_entries_start)
21041
21042 .previous
21043 END(interrupt)
21044 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21045 pushl_cfi $do_coprocessor_error
21046 jmp error_code
21047 CFI_ENDPROC
21048 -END(coprocessor_error)
21049 +ENDPROC(coprocessor_error)
21050
21051 ENTRY(simd_coprocessor_error)
21052 RING0_INT_FRAME
21053 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21054 .section .altinstructions,"a"
21055 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21056 .previous
21057 -.section .altinstr_replacement,"ax"
21058 +.section .altinstr_replacement,"a"
21059 663: pushl $do_simd_coprocessor_error
21060 664:
21061 .previous
21062 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21063 #endif
21064 jmp error_code
21065 CFI_ENDPROC
21066 -END(simd_coprocessor_error)
21067 +ENDPROC(simd_coprocessor_error)
21068
21069 ENTRY(device_not_available)
21070 RING0_INT_FRAME
21071 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21072 pushl_cfi $do_device_not_available
21073 jmp error_code
21074 CFI_ENDPROC
21075 -END(device_not_available)
21076 +ENDPROC(device_not_available)
21077
21078 #ifdef CONFIG_PARAVIRT
21079 ENTRY(native_iret)
21080 iret
21081 _ASM_EXTABLE(native_iret, iret_exc)
21082 -END(native_iret)
21083 +ENDPROC(native_iret)
21084
21085 ENTRY(native_irq_enable_sysexit)
21086 sti
21087 sysexit
21088 -END(native_irq_enable_sysexit)
21089 +ENDPROC(native_irq_enable_sysexit)
21090 #endif
21091
21092 ENTRY(overflow)
21093 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21094 pushl_cfi $do_overflow
21095 jmp error_code
21096 CFI_ENDPROC
21097 -END(overflow)
21098 +ENDPROC(overflow)
21099
21100 ENTRY(bounds)
21101 RING0_INT_FRAME
21102 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21103 pushl_cfi $do_bounds
21104 jmp error_code
21105 CFI_ENDPROC
21106 -END(bounds)
21107 +ENDPROC(bounds)
21108
21109 ENTRY(invalid_op)
21110 RING0_INT_FRAME
21111 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21112 pushl_cfi $do_invalid_op
21113 jmp error_code
21114 CFI_ENDPROC
21115 -END(invalid_op)
21116 +ENDPROC(invalid_op)
21117
21118 ENTRY(coprocessor_segment_overrun)
21119 RING0_INT_FRAME
21120 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21121 pushl_cfi $do_coprocessor_segment_overrun
21122 jmp error_code
21123 CFI_ENDPROC
21124 -END(coprocessor_segment_overrun)
21125 +ENDPROC(coprocessor_segment_overrun)
21126
21127 ENTRY(invalid_TSS)
21128 RING0_EC_FRAME
21129 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21130 pushl_cfi $do_invalid_TSS
21131 jmp error_code
21132 CFI_ENDPROC
21133 -END(invalid_TSS)
21134 +ENDPROC(invalid_TSS)
21135
21136 ENTRY(segment_not_present)
21137 RING0_EC_FRAME
21138 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21139 pushl_cfi $do_segment_not_present
21140 jmp error_code
21141 CFI_ENDPROC
21142 -END(segment_not_present)
21143 +ENDPROC(segment_not_present)
21144
21145 ENTRY(stack_segment)
21146 RING0_EC_FRAME
21147 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21148 pushl_cfi $do_stack_segment
21149 jmp error_code
21150 CFI_ENDPROC
21151 -END(stack_segment)
21152 +ENDPROC(stack_segment)
21153
21154 ENTRY(alignment_check)
21155 RING0_EC_FRAME
21156 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21157 pushl_cfi $do_alignment_check
21158 jmp error_code
21159 CFI_ENDPROC
21160 -END(alignment_check)
21161 +ENDPROC(alignment_check)
21162
21163 ENTRY(divide_error)
21164 RING0_INT_FRAME
21165 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21166 pushl_cfi $do_divide_error
21167 jmp error_code
21168 CFI_ENDPROC
21169 -END(divide_error)
21170 +ENDPROC(divide_error)
21171
21172 #ifdef CONFIG_X86_MCE
21173 ENTRY(machine_check)
21174 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21175 pushl_cfi machine_check_vector
21176 jmp error_code
21177 CFI_ENDPROC
21178 -END(machine_check)
21179 +ENDPROC(machine_check)
21180 #endif
21181
21182 ENTRY(spurious_interrupt_bug)
21183 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21184 pushl_cfi $do_spurious_interrupt_bug
21185 jmp error_code
21186 CFI_ENDPROC
21187 -END(spurious_interrupt_bug)
21188 +ENDPROC(spurious_interrupt_bug)
21189 /*
21190 * End of kprobes section
21191 */
21192 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21193
21194 ENTRY(mcount)
21195 ret
21196 -END(mcount)
21197 +ENDPROC(mcount)
21198
21199 ENTRY(ftrace_caller)
21200 cmpl $0, function_trace_stop
21201 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21202 .globl ftrace_stub
21203 ftrace_stub:
21204 ret
21205 -END(ftrace_caller)
21206 +ENDPROC(ftrace_caller)
21207
21208 ENTRY(ftrace_regs_caller)
21209 pushf /* push flags before compare (in cs location) */
21210 @@ -1210,7 +1449,7 @@ trace:
21211 popl %ecx
21212 popl %eax
21213 jmp ftrace_stub
21214 -END(mcount)
21215 +ENDPROC(mcount)
21216 #endif /* CONFIG_DYNAMIC_FTRACE */
21217 #endif /* CONFIG_FUNCTION_TRACER */
21218
21219 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
21220 popl %ecx
21221 popl %eax
21222 ret
21223 -END(ftrace_graph_caller)
21224 +ENDPROC(ftrace_graph_caller)
21225
21226 .globl return_to_handler
21227 return_to_handler:
21228 @@ -1284,15 +1523,18 @@ error_code:
21229 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21230 REG_TO_PTGS %ecx
21231 SET_KERNEL_GS %ecx
21232 - movl $(__USER_DS), %ecx
21233 + movl $(__KERNEL_DS), %ecx
21234 movl %ecx, %ds
21235 movl %ecx, %es
21236 +
21237 + pax_enter_kernel
21238 +
21239 TRACE_IRQS_OFF
21240 movl %esp,%eax # pt_regs pointer
21241 call *%edi
21242 jmp ret_from_exception
21243 CFI_ENDPROC
21244 -END(page_fault)
21245 +ENDPROC(page_fault)
21246
21247 /*
21248 * Debug traps and NMI can happen at the one SYSENTER instruction
21249 @@ -1335,7 +1577,7 @@ debug_stack_correct:
21250 call do_debug
21251 jmp ret_from_exception
21252 CFI_ENDPROC
21253 -END(debug)
21254 +ENDPROC(debug)
21255
21256 /*
21257 * NMI is doubly nasty. It can happen _while_ we're handling
21258 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
21259 xorl %edx,%edx # zero error code
21260 movl %esp,%eax # pt_regs pointer
21261 call do_nmi
21262 +
21263 + pax_exit_kernel
21264 +
21265 jmp restore_all_notrace
21266 CFI_ENDPROC
21267
21268 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
21269 FIXUP_ESPFIX_STACK # %eax == %esp
21270 xorl %edx,%edx # zero error code
21271 call do_nmi
21272 +
21273 + pax_exit_kernel
21274 +
21275 RESTORE_REGS
21276 lss 12+4(%esp), %esp # back to espfix stack
21277 CFI_ADJUST_CFA_OFFSET -24
21278 jmp irq_return
21279 CFI_ENDPROC
21280 -END(nmi)
21281 +ENDPROC(nmi)
21282
21283 ENTRY(int3)
21284 RING0_INT_FRAME
21285 @@ -1427,14 +1675,14 @@ ENTRY(int3)
21286 call do_int3
21287 jmp ret_from_exception
21288 CFI_ENDPROC
21289 -END(int3)
21290 +ENDPROC(int3)
21291
21292 ENTRY(general_protection)
21293 RING0_EC_FRAME
21294 pushl_cfi $do_general_protection
21295 jmp error_code
21296 CFI_ENDPROC
21297 -END(general_protection)
21298 +ENDPROC(general_protection)
21299
21300 #ifdef CONFIG_KVM_GUEST
21301 ENTRY(async_page_fault)
21302 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
21303 pushl_cfi $do_async_page_fault
21304 jmp error_code
21305 CFI_ENDPROC
21306 -END(async_page_fault)
21307 +ENDPROC(async_page_fault)
21308 #endif
21309
21310 /*
21311 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21312 index b077f4c..feb26c1 100644
21313 --- a/arch/x86/kernel/entry_64.S
21314 +++ b/arch/x86/kernel/entry_64.S
21315 @@ -59,6 +59,8 @@
21316 #include <asm/context_tracking.h>
21317 #include <asm/smap.h>
21318 #include <linux/err.h>
21319 +#include <asm/pgtable.h>
21320 +#include <asm/alternative-asm.h>
21321
21322 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21323 #include <linux/elf-em.h>
21324 @@ -80,8 +82,9 @@
21325 #ifdef CONFIG_DYNAMIC_FTRACE
21326
21327 ENTRY(function_hook)
21328 + pax_force_retaddr
21329 retq
21330 -END(function_hook)
21331 +ENDPROC(function_hook)
21332
21333 /* skip is set if stack has been adjusted */
21334 .macro ftrace_caller_setup skip=0
21335 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21336 #endif
21337
21338 GLOBAL(ftrace_stub)
21339 + pax_force_retaddr
21340 retq
21341 -END(ftrace_caller)
21342 +ENDPROC(ftrace_caller)
21343
21344 ENTRY(ftrace_regs_caller)
21345 /* Save the current flags before compare (in SS location)*/
21346 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21347 popfq
21348 jmp ftrace_stub
21349
21350 -END(ftrace_regs_caller)
21351 +ENDPROC(ftrace_regs_caller)
21352
21353
21354 #else /* ! CONFIG_DYNAMIC_FTRACE */
21355 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21356 #endif
21357
21358 GLOBAL(ftrace_stub)
21359 + pax_force_retaddr
21360 retq
21361
21362 trace:
21363 @@ -225,12 +230,13 @@ trace:
21364 #endif
21365 subq $MCOUNT_INSN_SIZE, %rdi
21366
21367 + pax_force_fptr ftrace_trace_function
21368 call *ftrace_trace_function
21369
21370 MCOUNT_RESTORE_FRAME
21371
21372 jmp ftrace_stub
21373 -END(function_hook)
21374 +ENDPROC(function_hook)
21375 #endif /* CONFIG_DYNAMIC_FTRACE */
21376 #endif /* CONFIG_FUNCTION_TRACER */
21377
21378 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21379
21380 MCOUNT_RESTORE_FRAME
21381
21382 + pax_force_retaddr
21383 retq
21384 -END(ftrace_graph_caller)
21385 +ENDPROC(ftrace_graph_caller)
21386
21387 GLOBAL(return_to_handler)
21388 subq $24, %rsp
21389 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21390 movq 8(%rsp), %rdx
21391 movq (%rsp), %rax
21392 addq $24, %rsp
21393 + pax_force_fptr %rdi
21394 jmp *%rdi
21395 +ENDPROC(return_to_handler)
21396 #endif
21397
21398
21399 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21400 ENDPROC(native_usergs_sysret64)
21401 #endif /* CONFIG_PARAVIRT */
21402
21403 + .macro ljmpq sel, off
21404 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21405 + .byte 0x48; ljmp *1234f(%rip)
21406 + .pushsection .rodata
21407 + .align 16
21408 + 1234: .quad \off; .word \sel
21409 + .popsection
21410 +#else
21411 + pushq $\sel
21412 + pushq $\off
21413 + lretq
21414 +#endif
21415 + .endm
21416 +
21417 + .macro pax_enter_kernel
21418 + pax_set_fptr_mask
21419 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21420 + call pax_enter_kernel
21421 +#endif
21422 + .endm
21423 +
21424 + .macro pax_exit_kernel
21425 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21426 + call pax_exit_kernel
21427 +#endif
21428 +
21429 + .endm
21430 +
21431 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21432 +ENTRY(pax_enter_kernel)
21433 + pushq %rdi
21434 +
21435 +#ifdef CONFIG_PARAVIRT
21436 + PV_SAVE_REGS(CLBR_RDI)
21437 +#endif
21438 +
21439 +#ifdef CONFIG_PAX_KERNEXEC
21440 + GET_CR0_INTO_RDI
21441 + bts $16,%rdi
21442 + jnc 3f
21443 + mov %cs,%edi
21444 + cmp $__KERNEL_CS,%edi
21445 + jnz 2f
21446 +1:
21447 +#endif
21448 +
21449 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21450 + 661: jmp 111f
21451 + .pushsection .altinstr_replacement, "a"
21452 + 662: ASM_NOP2
21453 + .popsection
21454 + .pushsection .altinstructions, "a"
21455 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21456 + .popsection
21457 + GET_CR3_INTO_RDI
21458 + cmp $0,%dil
21459 + jnz 112f
21460 + mov $__KERNEL_DS,%edi
21461 + mov %edi,%ss
21462 + jmp 111f
21463 +112: cmp $1,%dil
21464 + jz 113f
21465 + ud2
21466 +113: sub $4097,%rdi
21467 + bts $63,%rdi
21468 + SET_RDI_INTO_CR3
21469 + mov $__UDEREF_KERNEL_DS,%edi
21470 + mov %edi,%ss
21471 +111:
21472 +#endif
21473 +
21474 +#ifdef CONFIG_PARAVIRT
21475 + PV_RESTORE_REGS(CLBR_RDI)
21476 +#endif
21477 +
21478 + popq %rdi
21479 + pax_force_retaddr
21480 + retq
21481 +
21482 +#ifdef CONFIG_PAX_KERNEXEC
21483 +2: ljmpq __KERNEL_CS,1b
21484 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21485 +4: SET_RDI_INTO_CR0
21486 + jmp 1b
21487 +#endif
21488 +ENDPROC(pax_enter_kernel)
21489 +
21490 +ENTRY(pax_exit_kernel)
21491 + pushq %rdi
21492 +
21493 +#ifdef CONFIG_PARAVIRT
21494 + PV_SAVE_REGS(CLBR_RDI)
21495 +#endif
21496 +
21497 +#ifdef CONFIG_PAX_KERNEXEC
21498 + mov %cs,%rdi
21499 + cmp $__KERNEXEC_KERNEL_CS,%edi
21500 + jz 2f
21501 + GET_CR0_INTO_RDI
21502 + bts $16,%rdi
21503 + jnc 4f
21504 +1:
21505 +#endif
21506 +
21507 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21508 + 661: jmp 111f
21509 + .pushsection .altinstr_replacement, "a"
21510 + 662: ASM_NOP2
21511 + .popsection
21512 + .pushsection .altinstructions, "a"
21513 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21514 + .popsection
21515 + mov %ss,%edi
21516 + cmp $__UDEREF_KERNEL_DS,%edi
21517 + jnz 111f
21518 + GET_CR3_INTO_RDI
21519 + cmp $0,%dil
21520 + jz 112f
21521 + ud2
21522 +112: add $4097,%rdi
21523 + bts $63,%rdi
21524 + SET_RDI_INTO_CR3
21525 + mov $__KERNEL_DS,%edi
21526 + mov %edi,%ss
21527 +111:
21528 +#endif
21529 +
21530 +#ifdef CONFIG_PARAVIRT
21531 + PV_RESTORE_REGS(CLBR_RDI);
21532 +#endif
21533 +
21534 + popq %rdi
21535 + pax_force_retaddr
21536 + retq
21537 +
21538 +#ifdef CONFIG_PAX_KERNEXEC
21539 +2: GET_CR0_INTO_RDI
21540 + btr $16,%rdi
21541 + jnc 4f
21542 + ljmpq __KERNEL_CS,3f
21543 +3: SET_RDI_INTO_CR0
21544 + jmp 1b
21545 +4: ud2
21546 + jmp 4b
21547 +#endif
21548 +ENDPROC(pax_exit_kernel)
21549 +#endif
21550 +
21551 + .macro pax_enter_kernel_user
21552 + pax_set_fptr_mask
21553 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21554 + call pax_enter_kernel_user
21555 +#endif
21556 + .endm
21557 +
21558 + .macro pax_exit_kernel_user
21559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21560 + call pax_exit_kernel_user
21561 +#endif
21562 +#ifdef CONFIG_PAX_RANDKSTACK
21563 + pushq %rax
21564 + pushq %r11
21565 + call pax_randomize_kstack
21566 + popq %r11
21567 + popq %rax
21568 +#endif
21569 + .endm
21570 +
21571 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21572 +ENTRY(pax_enter_kernel_user)
21573 + pushq %rdi
21574 + pushq %rbx
21575 +
21576 +#ifdef CONFIG_PARAVIRT
21577 + PV_SAVE_REGS(CLBR_RDI)
21578 +#endif
21579 +
21580 + 661: jmp 111f
21581 + .pushsection .altinstr_replacement, "a"
21582 + 662: ASM_NOP2
21583 + .popsection
21584 + .pushsection .altinstructions, "a"
21585 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21586 + .popsection
21587 + GET_CR3_INTO_RDI
21588 + cmp $1,%dil
21589 + jnz 4f
21590 + sub $4097,%rdi
21591 + bts $63,%rdi
21592 + SET_RDI_INTO_CR3
21593 + jmp 3f
21594 +111:
21595 +
21596 + GET_CR3_INTO_RDI
21597 + mov %rdi,%rbx
21598 + add $__START_KERNEL_map,%rbx
21599 + sub phys_base(%rip),%rbx
21600 +
21601 +#ifdef CONFIG_PARAVIRT
21602 + cmpl $0, pv_info+PARAVIRT_enabled
21603 + jz 1f
21604 + pushq %rdi
21605 + i = 0
21606 + .rept USER_PGD_PTRS
21607 + mov i*8(%rbx),%rsi
21608 + mov $0,%sil
21609 + lea i*8(%rbx),%rdi
21610 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21611 + i = i + 1
21612 + .endr
21613 + popq %rdi
21614 + jmp 2f
21615 +1:
21616 +#endif
21617 +
21618 + i = 0
21619 + .rept USER_PGD_PTRS
21620 + movb $0,i*8(%rbx)
21621 + i = i + 1
21622 + .endr
21623 +
21624 +2: SET_RDI_INTO_CR3
21625 +
21626 +#ifdef CONFIG_PAX_KERNEXEC
21627 + GET_CR0_INTO_RDI
21628 + bts $16,%rdi
21629 + SET_RDI_INTO_CR0
21630 +#endif
21631 +
21632 +3:
21633 +
21634 +#ifdef CONFIG_PARAVIRT
21635 + PV_RESTORE_REGS(CLBR_RDI)
21636 +#endif
21637 +
21638 + popq %rbx
21639 + popq %rdi
21640 + pax_force_retaddr
21641 + retq
21642 +4: ud2
21643 +ENDPROC(pax_enter_kernel_user)
21644 +
21645 +ENTRY(pax_exit_kernel_user)
21646 + pushq %rdi
21647 + pushq %rbx
21648 +
21649 +#ifdef CONFIG_PARAVIRT
21650 + PV_SAVE_REGS(CLBR_RDI)
21651 +#endif
21652 +
21653 + GET_CR3_INTO_RDI
21654 + 661: jmp 1f
21655 + .pushsection .altinstr_replacement, "a"
21656 + 662: ASM_NOP2
21657 + .popsection
21658 + .pushsection .altinstructions, "a"
21659 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21660 + .popsection
21661 + cmp $0,%dil
21662 + jnz 3f
21663 + add $4097,%rdi
21664 + bts $63,%rdi
21665 + SET_RDI_INTO_CR3
21666 + jmp 2f
21667 +1:
21668 +
21669 + mov %rdi,%rbx
21670 +
21671 +#ifdef CONFIG_PAX_KERNEXEC
21672 + GET_CR0_INTO_RDI
21673 + btr $16,%rdi
21674 + jnc 3f
21675 + SET_RDI_INTO_CR0
21676 +#endif
21677 +
21678 + add $__START_KERNEL_map,%rbx
21679 + sub phys_base(%rip),%rbx
21680 +
21681 +#ifdef CONFIG_PARAVIRT
21682 + cmpl $0, pv_info+PARAVIRT_enabled
21683 + jz 1f
21684 + i = 0
21685 + .rept USER_PGD_PTRS
21686 + mov i*8(%rbx),%rsi
21687 + mov $0x67,%sil
21688 + lea i*8(%rbx),%rdi
21689 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21690 + i = i + 1
21691 + .endr
21692 + jmp 2f
21693 +1:
21694 +#endif
21695 +
21696 + i = 0
21697 + .rept USER_PGD_PTRS
21698 + movb $0x67,i*8(%rbx)
21699 + i = i + 1
21700 + .endr
21701 +2:
21702 +
21703 +#ifdef CONFIG_PARAVIRT
21704 + PV_RESTORE_REGS(CLBR_RDI)
21705 +#endif
21706 +
21707 + popq %rbx
21708 + popq %rdi
21709 + pax_force_retaddr
21710 + retq
21711 +3: ud2
21712 +ENDPROC(pax_exit_kernel_user)
21713 +#endif
21714 +
21715 + .macro pax_enter_kernel_nmi
21716 + pax_set_fptr_mask
21717 +
21718 +#ifdef CONFIG_PAX_KERNEXEC
21719 + GET_CR0_INTO_RDI
21720 + bts $16,%rdi
21721 + jc 110f
21722 + SET_RDI_INTO_CR0
21723 + or $2,%ebx
21724 +110:
21725 +#endif
21726 +
21727 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21728 + 661: jmp 111f
21729 + .pushsection .altinstr_replacement, "a"
21730 + 662: ASM_NOP2
21731 + .popsection
21732 + .pushsection .altinstructions, "a"
21733 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21734 + .popsection
21735 + GET_CR3_INTO_RDI
21736 + cmp $0,%dil
21737 + jz 111f
21738 + sub $4097,%rdi
21739 + or $4,%ebx
21740 + bts $63,%rdi
21741 + SET_RDI_INTO_CR3
21742 + mov $__UDEREF_KERNEL_DS,%edi
21743 + mov %edi,%ss
21744 +111:
21745 +#endif
21746 + .endm
21747 +
21748 + .macro pax_exit_kernel_nmi
21749 +#ifdef CONFIG_PAX_KERNEXEC
21750 + btr $1,%ebx
21751 + jnc 110f
21752 + GET_CR0_INTO_RDI
21753 + btr $16,%rdi
21754 + SET_RDI_INTO_CR0
21755 +110:
21756 +#endif
21757 +
21758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21759 + btr $2,%ebx
21760 + jnc 111f
21761 + GET_CR3_INTO_RDI
21762 + add $4097,%rdi
21763 + bts $63,%rdi
21764 + SET_RDI_INTO_CR3
21765 + mov $__KERNEL_DS,%edi
21766 + mov %edi,%ss
21767 +111:
21768 +#endif
21769 + .endm
21770 +
21771 + .macro pax_erase_kstack
21772 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21773 + call pax_erase_kstack
21774 +#endif
21775 + .endm
21776 +
21777 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21778 +ENTRY(pax_erase_kstack)
21779 + pushq %rdi
21780 + pushq %rcx
21781 + pushq %rax
21782 + pushq %r11
21783 +
21784 + GET_THREAD_INFO(%r11)
21785 + mov TI_lowest_stack(%r11), %rdi
21786 + mov $-0xBEEF, %rax
21787 + std
21788 +
21789 +1: mov %edi, %ecx
21790 + and $THREAD_SIZE_asm - 1, %ecx
21791 + shr $3, %ecx
21792 + repne scasq
21793 + jecxz 2f
21794 +
21795 + cmp $2*8, %ecx
21796 + jc 2f
21797 +
21798 + mov $2*8, %ecx
21799 + repe scasq
21800 + jecxz 2f
21801 + jne 1b
21802 +
21803 +2: cld
21804 + mov %esp, %ecx
21805 + sub %edi, %ecx
21806 +
21807 + cmp $THREAD_SIZE_asm, %rcx
21808 + jb 3f
21809 + ud2
21810 +3:
21811 +
21812 + shr $3, %ecx
21813 + rep stosq
21814 +
21815 + mov TI_task_thread_sp0(%r11), %rdi
21816 + sub $256, %rdi
21817 + mov %rdi, TI_lowest_stack(%r11)
21818 +
21819 + popq %r11
21820 + popq %rax
21821 + popq %rcx
21822 + popq %rdi
21823 + pax_force_retaddr
21824 + ret
21825 +ENDPROC(pax_erase_kstack)
21826 +#endif
21827
21828 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21829 #ifdef CONFIG_TRACE_IRQFLAGS
21830 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21831 .endm
21832
21833 .macro UNFAKE_STACK_FRAME
21834 - addq $8*6, %rsp
21835 - CFI_ADJUST_CFA_OFFSET -(6*8)
21836 + addq $8*6 + ARG_SKIP, %rsp
21837 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21838 .endm
21839
21840 /*
21841 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21842 movq %rsp, %rsi
21843
21844 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21845 - testl $3, CS-RBP(%rsi)
21846 + testb $3, CS-RBP(%rsi)
21847 je 1f
21848 SWAPGS
21849 /*
21850 @@ -514,9 +947,10 @@ ENTRY(save_paranoid)
21851 js 1f /* negative -> in kernel */
21852 SWAPGS
21853 xorl %ebx,%ebx
21854 -1: ret
21855 +1: pax_force_retaddr_bts
21856 + ret
21857 CFI_ENDPROC
21858 -END(save_paranoid)
21859 +ENDPROC(save_paranoid)
21860 .popsection
21861
21862 /*
21863 @@ -538,7 +972,7 @@ ENTRY(ret_from_fork)
21864
21865 RESTORE_REST
21866
21867 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21868 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21869 jz 1f
21870
21871 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21872 @@ -556,7 +990,7 @@ ENTRY(ret_from_fork)
21873 RESTORE_REST
21874 jmp int_ret_from_sys_call
21875 CFI_ENDPROC
21876 -END(ret_from_fork)
21877 +ENDPROC(ret_from_fork)
21878
21879 /*
21880 * System call entry. Up to 6 arguments in registers are supported.
21881 @@ -593,7 +1027,7 @@ END(ret_from_fork)
21882 ENTRY(system_call)
21883 CFI_STARTPROC simple
21884 CFI_SIGNAL_FRAME
21885 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21886 + CFI_DEF_CFA rsp,0
21887 CFI_REGISTER rip,rcx
21888 /*CFI_REGISTER rflags,r11*/
21889 SWAPGS_UNSAFE_STACK
21890 @@ -606,16 +1040,23 @@ GLOBAL(system_call_after_swapgs)
21891
21892 movq %rsp,PER_CPU_VAR(old_rsp)
21893 movq PER_CPU_VAR(kernel_stack),%rsp
21894 + SAVE_ARGS 8*6,0
21895 + pax_enter_kernel_user
21896 +
21897 +#ifdef CONFIG_PAX_RANDKSTACK
21898 + pax_erase_kstack
21899 +#endif
21900 +
21901 /*
21902 * No need to follow this irqs off/on section - it's straight
21903 * and short:
21904 */
21905 ENABLE_INTERRUPTS(CLBR_NONE)
21906 - SAVE_ARGS 8,0
21907 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21908 movq %rcx,RIP-ARGOFFSET(%rsp)
21909 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21910 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21911 + GET_THREAD_INFO(%rcx)
21912 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21913 jnz tracesys
21914 system_call_fastpath:
21915 #if __SYSCALL_MASK == ~0
21916 @@ -625,7 +1066,7 @@ system_call_fastpath:
21917 cmpl $__NR_syscall_max,%eax
21918 #endif
21919 ja badsys
21920 - movq %r10,%rcx
21921 + movq R10-ARGOFFSET(%rsp),%rcx
21922 call *sys_call_table(,%rax,8) # XXX: rip relative
21923 movq %rax,RAX-ARGOFFSET(%rsp)
21924 /*
21925 @@ -639,10 +1080,13 @@ sysret_check:
21926 LOCKDEP_SYS_EXIT
21927 DISABLE_INTERRUPTS(CLBR_NONE)
21928 TRACE_IRQS_OFF
21929 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21930 + GET_THREAD_INFO(%rcx)
21931 + movl TI_flags(%rcx),%edx
21932 andl %edi,%edx
21933 jnz sysret_careful
21934 CFI_REMEMBER_STATE
21935 + pax_exit_kernel_user
21936 + pax_erase_kstack
21937 /*
21938 * sysretq will re-enable interrupts:
21939 */
21940 @@ -694,14 +1138,18 @@ badsys:
21941 * jump back to the normal fast path.
21942 */
21943 auditsys:
21944 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21945 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21946 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21947 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21948 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21949 movq %rax,%rsi /* 2nd arg: syscall number */
21950 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21951 call __audit_syscall_entry
21952 +
21953 + pax_erase_kstack
21954 +
21955 LOAD_ARGS 0 /* reload call-clobbered registers */
21956 + pax_set_fptr_mask
21957 jmp system_call_fastpath
21958
21959 /*
21960 @@ -722,7 +1170,7 @@ sysret_audit:
21961 /* Do syscall tracing */
21962 tracesys:
21963 #ifdef CONFIG_AUDITSYSCALL
21964 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21965 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21966 jz auditsys
21967 #endif
21968 SAVE_REST
21969 @@ -730,12 +1178,16 @@ tracesys:
21970 FIXUP_TOP_OF_STACK %rdi
21971 movq %rsp,%rdi
21972 call syscall_trace_enter
21973 +
21974 + pax_erase_kstack
21975 +
21976 /*
21977 * Reload arg registers from stack in case ptrace changed them.
21978 * We don't reload %rax because syscall_trace_enter() returned
21979 * the value it wants us to use in the table lookup.
21980 */
21981 LOAD_ARGS ARGOFFSET, 1
21982 + pax_set_fptr_mask
21983 RESTORE_REST
21984 #if __SYSCALL_MASK == ~0
21985 cmpq $__NR_syscall_max,%rax
21986 @@ -744,7 +1196,7 @@ tracesys:
21987 cmpl $__NR_syscall_max,%eax
21988 #endif
21989 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21990 - movq %r10,%rcx /* fixup for C */
21991 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21992 call *sys_call_table(,%rax,8)
21993 movq %rax,RAX-ARGOFFSET(%rsp)
21994 /* Use IRET because user could have changed frame */
21995 @@ -765,7 +1217,9 @@ GLOBAL(int_with_check)
21996 andl %edi,%edx
21997 jnz int_careful
21998 andl $~TS_COMPAT,TI_status(%rcx)
21999 - jmp retint_swapgs
22000 + pax_exit_kernel_user
22001 + pax_erase_kstack
22002 + jmp retint_swapgs_pax
22003
22004 /* Either reschedule or signal or syscall exit tracking needed. */
22005 /* First do a reschedule test. */
22006 @@ -811,7 +1265,7 @@ int_restore_rest:
22007 TRACE_IRQS_OFF
22008 jmp int_with_check
22009 CFI_ENDPROC
22010 -END(system_call)
22011 +ENDPROC(system_call)
22012
22013 .macro FORK_LIKE func
22014 ENTRY(stub_\func)
22015 @@ -824,9 +1278,10 @@ ENTRY(stub_\func)
22016 DEFAULT_FRAME 0 8 /* offset 8: return address */
22017 call sys_\func
22018 RESTORE_TOP_OF_STACK %r11, 8
22019 + pax_force_retaddr
22020 ret $REST_SKIP /* pop extended registers */
22021 CFI_ENDPROC
22022 -END(stub_\func)
22023 +ENDPROC(stub_\func)
22024 .endm
22025
22026 .macro FIXED_FRAME label,func
22027 @@ -836,9 +1291,10 @@ ENTRY(\label)
22028 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22029 call \func
22030 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22031 + pax_force_retaddr
22032 ret
22033 CFI_ENDPROC
22034 -END(\label)
22035 +ENDPROC(\label)
22036 .endm
22037
22038 FORK_LIKE clone
22039 @@ -855,9 +1311,10 @@ ENTRY(ptregscall_common)
22040 movq_cfi_restore R12+8, r12
22041 movq_cfi_restore RBP+8, rbp
22042 movq_cfi_restore RBX+8, rbx
22043 + pax_force_retaddr
22044 ret $REST_SKIP /* pop extended registers */
22045 CFI_ENDPROC
22046 -END(ptregscall_common)
22047 +ENDPROC(ptregscall_common)
22048
22049 ENTRY(stub_execve)
22050 CFI_STARTPROC
22051 @@ -870,7 +1327,7 @@ ENTRY(stub_execve)
22052 RESTORE_REST
22053 jmp int_ret_from_sys_call
22054 CFI_ENDPROC
22055 -END(stub_execve)
22056 +ENDPROC(stub_execve)
22057
22058 /*
22059 * sigreturn is special because it needs to restore all registers on return.
22060 @@ -887,7 +1344,7 @@ ENTRY(stub_rt_sigreturn)
22061 RESTORE_REST
22062 jmp int_ret_from_sys_call
22063 CFI_ENDPROC
22064 -END(stub_rt_sigreturn)
22065 +ENDPROC(stub_rt_sigreturn)
22066
22067 #ifdef CONFIG_X86_X32_ABI
22068 ENTRY(stub_x32_rt_sigreturn)
22069 @@ -901,7 +1358,7 @@ ENTRY(stub_x32_rt_sigreturn)
22070 RESTORE_REST
22071 jmp int_ret_from_sys_call
22072 CFI_ENDPROC
22073 -END(stub_x32_rt_sigreturn)
22074 +ENDPROC(stub_x32_rt_sigreturn)
22075
22076 ENTRY(stub_x32_execve)
22077 CFI_STARTPROC
22078 @@ -915,7 +1372,7 @@ ENTRY(stub_x32_execve)
22079 RESTORE_REST
22080 jmp int_ret_from_sys_call
22081 CFI_ENDPROC
22082 -END(stub_x32_execve)
22083 +ENDPROC(stub_x32_execve)
22084
22085 #endif
22086
22087 @@ -952,7 +1409,7 @@ vector=vector+1
22088 2: jmp common_interrupt
22089 .endr
22090 CFI_ENDPROC
22091 -END(irq_entries_start)
22092 +ENDPROC(irq_entries_start)
22093
22094 .previous
22095 END(interrupt)
22096 @@ -972,6 +1429,16 @@ END(interrupt)
22097 subq $ORIG_RAX-RBP, %rsp
22098 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22099 SAVE_ARGS_IRQ
22100 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22101 + testb $3, CS(%rdi)
22102 + jnz 1f
22103 + pax_enter_kernel
22104 + jmp 2f
22105 +1: pax_enter_kernel_user
22106 +2:
22107 +#else
22108 + pax_enter_kernel
22109 +#endif
22110 call \func
22111 .endm
22112
22113 @@ -1004,7 +1471,7 @@ ret_from_intr:
22114
22115 exit_intr:
22116 GET_THREAD_INFO(%rcx)
22117 - testl $3,CS-ARGOFFSET(%rsp)
22118 + testb $3,CS-ARGOFFSET(%rsp)
22119 je retint_kernel
22120
22121 /* Interrupt came from user space */
22122 @@ -1026,12 +1493,16 @@ retint_swapgs: /* return to user-space */
22123 * The iretq could re-enable interrupts:
22124 */
22125 DISABLE_INTERRUPTS(CLBR_ANY)
22126 + pax_exit_kernel_user
22127 +retint_swapgs_pax:
22128 TRACE_IRQS_IRETQ
22129 SWAPGS
22130 jmp restore_args
22131
22132 retint_restore_args: /* return to kernel space */
22133 DISABLE_INTERRUPTS(CLBR_ANY)
22134 + pax_exit_kernel
22135 + pax_force_retaddr (RIP-ARGOFFSET)
22136 /*
22137 * The iretq could re-enable interrupts:
22138 */
22139 @@ -1114,7 +1585,7 @@ ENTRY(retint_kernel)
22140 #endif
22141
22142 CFI_ENDPROC
22143 -END(common_interrupt)
22144 +ENDPROC(common_interrupt)
22145 /*
22146 * End of kprobes section
22147 */
22148 @@ -1132,7 +1603,7 @@ ENTRY(\sym)
22149 interrupt \do_sym
22150 jmp ret_from_intr
22151 CFI_ENDPROC
22152 -END(\sym)
22153 +ENDPROC(\sym)
22154 .endm
22155
22156 #ifdef CONFIG_TRACING
22157 @@ -1215,12 +1686,22 @@ ENTRY(\sym)
22158 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22159 call error_entry
22160 DEFAULT_FRAME 0
22161 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22162 + testb $3, CS(%rsp)
22163 + jnz 1f
22164 + pax_enter_kernel
22165 + jmp 2f
22166 +1: pax_enter_kernel_user
22167 +2:
22168 +#else
22169 + pax_enter_kernel
22170 +#endif
22171 movq %rsp,%rdi /* pt_regs pointer */
22172 xorl %esi,%esi /* no error code */
22173 call \do_sym
22174 jmp error_exit /* %ebx: no swapgs flag */
22175 CFI_ENDPROC
22176 -END(\sym)
22177 +ENDPROC(\sym)
22178 .endm
22179
22180 .macro paranoidzeroentry sym do_sym
22181 @@ -1233,15 +1714,25 @@ ENTRY(\sym)
22182 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22183 call save_paranoid
22184 TRACE_IRQS_OFF
22185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22186 + testb $3, CS(%rsp)
22187 + jnz 1f
22188 + pax_enter_kernel
22189 + jmp 2f
22190 +1: pax_enter_kernel_user
22191 +2:
22192 +#else
22193 + pax_enter_kernel
22194 +#endif
22195 movq %rsp,%rdi /* pt_regs pointer */
22196 xorl %esi,%esi /* no error code */
22197 call \do_sym
22198 jmp paranoid_exit /* %ebx: no swapgs flag */
22199 CFI_ENDPROC
22200 -END(\sym)
22201 +ENDPROC(\sym)
22202 .endm
22203
22204 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22205 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22206 .macro paranoidzeroentry_ist sym do_sym ist
22207 ENTRY(\sym)
22208 INTR_FRAME
22209 @@ -1252,14 +1743,30 @@ ENTRY(\sym)
22210 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22211 call save_paranoid
22212 TRACE_IRQS_OFF_DEBUG
22213 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22214 + testb $3, CS(%rsp)
22215 + jnz 1f
22216 + pax_enter_kernel
22217 + jmp 2f
22218 +1: pax_enter_kernel_user
22219 +2:
22220 +#else
22221 + pax_enter_kernel
22222 +#endif
22223 movq %rsp,%rdi /* pt_regs pointer */
22224 xorl %esi,%esi /* no error code */
22225 +#ifdef CONFIG_SMP
22226 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22227 + lea init_tss(%r12), %r12
22228 +#else
22229 + lea init_tss(%rip), %r12
22230 +#endif
22231 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22232 call \do_sym
22233 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22234 jmp paranoid_exit /* %ebx: no swapgs flag */
22235 CFI_ENDPROC
22236 -END(\sym)
22237 +ENDPROC(\sym)
22238 .endm
22239
22240 .macro errorentry sym do_sym
22241 @@ -1271,13 +1778,23 @@ ENTRY(\sym)
22242 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22243 call error_entry
22244 DEFAULT_FRAME 0
22245 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22246 + testb $3, CS(%rsp)
22247 + jnz 1f
22248 + pax_enter_kernel
22249 + jmp 2f
22250 +1: pax_enter_kernel_user
22251 +2:
22252 +#else
22253 + pax_enter_kernel
22254 +#endif
22255 movq %rsp,%rdi /* pt_regs pointer */
22256 movq ORIG_RAX(%rsp),%rsi /* get error code */
22257 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22258 call \do_sym
22259 jmp error_exit /* %ebx: no swapgs flag */
22260 CFI_ENDPROC
22261 -END(\sym)
22262 +ENDPROC(\sym)
22263 .endm
22264
22265 /* error code is on the stack already */
22266 @@ -1291,13 +1808,23 @@ ENTRY(\sym)
22267 call save_paranoid
22268 DEFAULT_FRAME 0
22269 TRACE_IRQS_OFF
22270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22271 + testb $3, CS(%rsp)
22272 + jnz 1f
22273 + pax_enter_kernel
22274 + jmp 2f
22275 +1: pax_enter_kernel_user
22276 +2:
22277 +#else
22278 + pax_enter_kernel
22279 +#endif
22280 movq %rsp,%rdi /* pt_regs pointer */
22281 movq ORIG_RAX(%rsp),%rsi /* get error code */
22282 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22283 call \do_sym
22284 jmp paranoid_exit /* %ebx: no swapgs flag */
22285 CFI_ENDPROC
22286 -END(\sym)
22287 +ENDPROC(\sym)
22288 .endm
22289
22290 zeroentry divide_error do_divide_error
22291 @@ -1327,9 +1854,10 @@ gs_change:
22292 2: mfence /* workaround */
22293 SWAPGS
22294 popfq_cfi
22295 + pax_force_retaddr
22296 ret
22297 CFI_ENDPROC
22298 -END(native_load_gs_index)
22299 +ENDPROC(native_load_gs_index)
22300
22301 _ASM_EXTABLE(gs_change,bad_gs)
22302 .section .fixup,"ax"
22303 @@ -1357,9 +1885,10 @@ ENTRY(call_softirq)
22304 CFI_DEF_CFA_REGISTER rsp
22305 CFI_ADJUST_CFA_OFFSET -8
22306 decl PER_CPU_VAR(irq_count)
22307 + pax_force_retaddr
22308 ret
22309 CFI_ENDPROC
22310 -END(call_softirq)
22311 +ENDPROC(call_softirq)
22312
22313 #ifdef CONFIG_XEN
22314 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22315 @@ -1397,7 +1926,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22316 decl PER_CPU_VAR(irq_count)
22317 jmp error_exit
22318 CFI_ENDPROC
22319 -END(xen_do_hypervisor_callback)
22320 +ENDPROC(xen_do_hypervisor_callback)
22321
22322 /*
22323 * Hypervisor uses this for application faults while it executes.
22324 @@ -1456,7 +1985,7 @@ ENTRY(xen_failsafe_callback)
22325 SAVE_ALL
22326 jmp error_exit
22327 CFI_ENDPROC
22328 -END(xen_failsafe_callback)
22329 +ENDPROC(xen_failsafe_callback)
22330
22331 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22332 xen_hvm_callback_vector xen_evtchn_do_upcall
22333 @@ -1508,18 +2037,33 @@ ENTRY(paranoid_exit)
22334 DEFAULT_FRAME
22335 DISABLE_INTERRUPTS(CLBR_NONE)
22336 TRACE_IRQS_OFF_DEBUG
22337 - testl %ebx,%ebx /* swapgs needed? */
22338 + testl $1,%ebx /* swapgs needed? */
22339 jnz paranoid_restore
22340 - testl $3,CS(%rsp)
22341 + testb $3,CS(%rsp)
22342 jnz paranoid_userspace
22343 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22344 + pax_exit_kernel
22345 + TRACE_IRQS_IRETQ 0
22346 + SWAPGS_UNSAFE_STACK
22347 + RESTORE_ALL 8
22348 + pax_force_retaddr_bts
22349 + jmp irq_return
22350 +#endif
22351 paranoid_swapgs:
22352 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22353 + pax_exit_kernel_user
22354 +#else
22355 + pax_exit_kernel
22356 +#endif
22357 TRACE_IRQS_IRETQ 0
22358 SWAPGS_UNSAFE_STACK
22359 RESTORE_ALL 8
22360 jmp irq_return
22361 paranoid_restore:
22362 + pax_exit_kernel
22363 TRACE_IRQS_IRETQ_DEBUG 0
22364 RESTORE_ALL 8
22365 + pax_force_retaddr_bts
22366 jmp irq_return
22367 paranoid_userspace:
22368 GET_THREAD_INFO(%rcx)
22369 @@ -1548,7 +2092,7 @@ paranoid_schedule:
22370 TRACE_IRQS_OFF
22371 jmp paranoid_userspace
22372 CFI_ENDPROC
22373 -END(paranoid_exit)
22374 +ENDPROC(paranoid_exit)
22375
22376 /*
22377 * Exception entry point. This expects an error code/orig_rax on the stack.
22378 @@ -1575,12 +2119,13 @@ ENTRY(error_entry)
22379 movq_cfi r14, R14+8
22380 movq_cfi r15, R15+8
22381 xorl %ebx,%ebx
22382 - testl $3,CS+8(%rsp)
22383 + testb $3,CS+8(%rsp)
22384 je error_kernelspace
22385 error_swapgs:
22386 SWAPGS
22387 error_sti:
22388 TRACE_IRQS_OFF
22389 + pax_force_retaddr_bts
22390 ret
22391
22392 /*
22393 @@ -1607,7 +2152,7 @@ bstep_iret:
22394 movq %rcx,RIP+8(%rsp)
22395 jmp error_swapgs
22396 CFI_ENDPROC
22397 -END(error_entry)
22398 +ENDPROC(error_entry)
22399
22400
22401 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22402 @@ -1618,7 +2163,7 @@ ENTRY(error_exit)
22403 DISABLE_INTERRUPTS(CLBR_NONE)
22404 TRACE_IRQS_OFF
22405 GET_THREAD_INFO(%rcx)
22406 - testl %eax,%eax
22407 + testl $1,%eax
22408 jne retint_kernel
22409 LOCKDEP_SYS_EXIT_IRQ
22410 movl TI_flags(%rcx),%edx
22411 @@ -1627,7 +2172,7 @@ ENTRY(error_exit)
22412 jnz retint_careful
22413 jmp retint_swapgs
22414 CFI_ENDPROC
22415 -END(error_exit)
22416 +ENDPROC(error_exit)
22417
22418 /*
22419 * Test if a given stack is an NMI stack or not.
22420 @@ -1685,9 +2230,11 @@ ENTRY(nmi)
22421 * If %cs was not the kernel segment, then the NMI triggered in user
22422 * space, which means it is definitely not nested.
22423 */
22424 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22425 + je 1f
22426 cmpl $__KERNEL_CS, 16(%rsp)
22427 jne first_nmi
22428 -
22429 +1:
22430 /*
22431 * Check the special variable on the stack to see if NMIs are
22432 * executing.
22433 @@ -1721,8 +2268,7 @@ nested_nmi:
22434
22435 1:
22436 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22437 - leaq -1*8(%rsp), %rdx
22438 - movq %rdx, %rsp
22439 + subq $8, %rsp
22440 CFI_ADJUST_CFA_OFFSET 1*8
22441 leaq -10*8(%rsp), %rdx
22442 pushq_cfi $__KERNEL_DS
22443 @@ -1740,6 +2286,7 @@ nested_nmi_out:
22444 CFI_RESTORE rdx
22445
22446 /* No need to check faults here */
22447 +# pax_force_retaddr_bts
22448 INTERRUPT_RETURN
22449
22450 CFI_RESTORE_STATE
22451 @@ -1856,6 +2403,8 @@ end_repeat_nmi:
22452 */
22453 movq %cr2, %r12
22454
22455 + pax_enter_kernel_nmi
22456 +
22457 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22458 movq %rsp,%rdi
22459 movq $-1,%rsi
22460 @@ -1868,26 +2417,31 @@ end_repeat_nmi:
22461 movq %r12, %cr2
22462 1:
22463
22464 - testl %ebx,%ebx /* swapgs needed? */
22465 + testl $1,%ebx /* swapgs needed? */
22466 jnz nmi_restore
22467 nmi_swapgs:
22468 SWAPGS_UNSAFE_STACK
22469 nmi_restore:
22470 + pax_exit_kernel_nmi
22471 /* Pop the extra iret frame at once */
22472 RESTORE_ALL 6*8
22473 + testb $3, 8(%rsp)
22474 + jnz 1f
22475 + pax_force_retaddr_bts
22476 +1:
22477
22478 /* Clear the NMI executing stack variable */
22479 movq $0, 5*8(%rsp)
22480 jmp irq_return
22481 CFI_ENDPROC
22482 -END(nmi)
22483 +ENDPROC(nmi)
22484
22485 ENTRY(ignore_sysret)
22486 CFI_STARTPROC
22487 mov $-ENOSYS,%eax
22488 sysret
22489 CFI_ENDPROC
22490 -END(ignore_sysret)
22491 +ENDPROC(ignore_sysret)
22492
22493 /*
22494 * End of kprobes section
22495 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22496 index 42a392a..fbbd930 100644
22497 --- a/arch/x86/kernel/ftrace.c
22498 +++ b/arch/x86/kernel/ftrace.c
22499 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22500 {
22501 unsigned char replaced[MCOUNT_INSN_SIZE];
22502
22503 + ip = ktla_ktva(ip);
22504 +
22505 /*
22506 * Note: Due to modules and __init, code can
22507 * disappear and change, we need to protect against faulting
22508 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22509 unsigned char old[MCOUNT_INSN_SIZE], *new;
22510 int ret;
22511
22512 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22513 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22514 new = ftrace_call_replace(ip, (unsigned long)func);
22515
22516 /* See comment above by declaration of modifying_ftrace_code */
22517 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22518 /* Also update the regs callback function */
22519 if (!ret) {
22520 ip = (unsigned long)(&ftrace_regs_call);
22521 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22522 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22523 new = ftrace_call_replace(ip, (unsigned long)func);
22524 ret = ftrace_modify_code(ip, old, new);
22525 }
22526 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22527 * kernel identity mapping to modify code.
22528 */
22529 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22530 - ip = (unsigned long)__va(__pa_symbol(ip));
22531 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22532
22533 return probe_kernel_write((void *)ip, val, size);
22534 }
22535 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22536 unsigned char replaced[MCOUNT_INSN_SIZE];
22537 unsigned char brk = BREAKPOINT_INSTRUCTION;
22538
22539 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22540 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22541 return -EFAULT;
22542
22543 /* Make sure it is what we expect it to be */
22544 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22545 return ret;
22546
22547 fail_update:
22548 - probe_kernel_write((void *)ip, &old_code[0], 1);
22549 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22550 goto out;
22551 }
22552
22553 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22554 {
22555 unsigned char code[MCOUNT_INSN_SIZE];
22556
22557 + ip = ktla_ktva(ip);
22558 +
22559 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22560 return -EFAULT;
22561
22562 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22563 index 1be8e43..d9b9ef6 100644
22564 --- a/arch/x86/kernel/head64.c
22565 +++ b/arch/x86/kernel/head64.c
22566 @@ -67,12 +67,12 @@ again:
22567 pgd = *pgd_p;
22568
22569 /*
22570 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22571 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22572 + * The use of __early_va rather than __va here is critical:
22573 + * __va would point us back into the dynamic
22574 * range and we might end up looping forever...
22575 */
22576 if (pgd)
22577 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22578 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22579 else {
22580 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22581 reset_early_page_tables();
22582 @@ -82,13 +82,13 @@ again:
22583 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22584 for (i = 0; i < PTRS_PER_PUD; i++)
22585 pud_p[i] = 0;
22586 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22587 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22588 }
22589 pud_p += pud_index(address);
22590 pud = *pud_p;
22591
22592 if (pud)
22593 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22594 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22595 else {
22596 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22597 reset_early_page_tables();
22598 @@ -98,7 +98,7 @@ again:
22599 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22600 for (i = 0; i < PTRS_PER_PMD; i++)
22601 pmd_p[i] = 0;
22602 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22603 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22604 }
22605 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22606 pmd_p[pmd_index(address)] = pmd;
22607 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
22608 if (console_loglevel == 10)
22609 early_printk("Kernel alive\n");
22610
22611 - clear_page(init_level4_pgt);
22612 /* set init_level4_pgt kernel high mapping*/
22613 init_level4_pgt[511] = early_level4_pgt[511];
22614
22615 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22616 index 81ba276..30c5411 100644
22617 --- a/arch/x86/kernel/head_32.S
22618 +++ b/arch/x86/kernel/head_32.S
22619 @@ -26,6 +26,12 @@
22620 /* Physical address */
22621 #define pa(X) ((X) - __PAGE_OFFSET)
22622
22623 +#ifdef CONFIG_PAX_KERNEXEC
22624 +#define ta(X) (X)
22625 +#else
22626 +#define ta(X) ((X) - __PAGE_OFFSET)
22627 +#endif
22628 +
22629 /*
22630 * References to members of the new_cpu_data structure.
22631 */
22632 @@ -55,11 +61,7 @@
22633 * and small than max_low_pfn, otherwise will waste some page table entries
22634 */
22635
22636 -#if PTRS_PER_PMD > 1
22637 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22638 -#else
22639 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22640 -#endif
22641 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22642
22643 /* Number of possible pages in the lowmem region */
22644 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22645 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22646 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22647
22648 /*
22649 + * Real beginning of normal "text" segment
22650 + */
22651 +ENTRY(stext)
22652 +ENTRY(_stext)
22653 +
22654 +/*
22655 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22656 * %esi points to the real-mode code as a 32-bit pointer.
22657 * CS and DS must be 4 GB flat segments, but we don't depend on
22658 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22659 * can.
22660 */
22661 __HEAD
22662 +
22663 +#ifdef CONFIG_PAX_KERNEXEC
22664 + jmp startup_32
22665 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22666 +.fill PAGE_SIZE-5,1,0xcc
22667 +#endif
22668 +
22669 ENTRY(startup_32)
22670 movl pa(stack_start),%ecx
22671
22672 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22673 2:
22674 leal -__PAGE_OFFSET(%ecx),%esp
22675
22676 +#ifdef CONFIG_SMP
22677 + movl $pa(cpu_gdt_table),%edi
22678 + movl $__per_cpu_load,%eax
22679 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22680 + rorl $16,%eax
22681 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22682 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22683 + movl $__per_cpu_end - 1,%eax
22684 + subl $__per_cpu_start,%eax
22685 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22686 +#endif
22687 +
22688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22689 + movl $NR_CPUS,%ecx
22690 + movl $pa(cpu_gdt_table),%edi
22691 +1:
22692 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22693 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22694 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22695 + addl $PAGE_SIZE_asm,%edi
22696 + loop 1b
22697 +#endif
22698 +
22699 +#ifdef CONFIG_PAX_KERNEXEC
22700 + movl $pa(boot_gdt),%edi
22701 + movl $__LOAD_PHYSICAL_ADDR,%eax
22702 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22703 + rorl $16,%eax
22704 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22705 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22706 + rorl $16,%eax
22707 +
22708 + ljmp $(__BOOT_CS),$1f
22709 +1:
22710 +
22711 + movl $NR_CPUS,%ecx
22712 + movl $pa(cpu_gdt_table),%edi
22713 + addl $__PAGE_OFFSET,%eax
22714 +1:
22715 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22716 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22717 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22718 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22719 + rorl $16,%eax
22720 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22721 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22722 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22723 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22724 + rorl $16,%eax
22725 + addl $PAGE_SIZE_asm,%edi
22726 + loop 1b
22727 +#endif
22728 +
22729 /*
22730 * Clear BSS first so that there are no surprises...
22731 */
22732 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22733 movl %eax, pa(max_pfn_mapped)
22734
22735 /* Do early initialization of the fixmap area */
22736 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22737 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22738 +#ifdef CONFIG_COMPAT_VDSO
22739 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22740 +#else
22741 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22742 +#endif
22743 #else /* Not PAE */
22744
22745 page_pde_offset = (__PAGE_OFFSET >> 20);
22746 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22747 movl %eax, pa(max_pfn_mapped)
22748
22749 /* Do early initialization of the fixmap area */
22750 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22751 - movl %eax,pa(initial_page_table+0xffc)
22752 +#ifdef CONFIG_COMPAT_VDSO
22753 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22754 +#else
22755 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22756 +#endif
22757 #endif
22758
22759 #ifdef CONFIG_PARAVIRT
22760 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22761 cmpl $num_subarch_entries, %eax
22762 jae bad_subarch
22763
22764 - movl pa(subarch_entries)(,%eax,4), %eax
22765 - subl $__PAGE_OFFSET, %eax
22766 - jmp *%eax
22767 + jmp *pa(subarch_entries)(,%eax,4)
22768
22769 bad_subarch:
22770 WEAK(lguest_entry)
22771 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22772 __INITDATA
22773
22774 subarch_entries:
22775 - .long default_entry /* normal x86/PC */
22776 - .long lguest_entry /* lguest hypervisor */
22777 - .long xen_entry /* Xen hypervisor */
22778 - .long default_entry /* Moorestown MID */
22779 + .long ta(default_entry) /* normal x86/PC */
22780 + .long ta(lguest_entry) /* lguest hypervisor */
22781 + .long ta(xen_entry) /* Xen hypervisor */
22782 + .long ta(default_entry) /* Moorestown MID */
22783 num_subarch_entries = (. - subarch_entries) / 4
22784 .previous
22785 #else
22786 @@ -354,6 +426,7 @@ default_entry:
22787 movl pa(mmu_cr4_features),%eax
22788 movl %eax,%cr4
22789
22790 +#ifdef CONFIG_X86_PAE
22791 testb $X86_CR4_PAE, %al # check if PAE is enabled
22792 jz enable_paging
22793
22794 @@ -382,6 +455,9 @@ default_entry:
22795 /* Make changes effective */
22796 wrmsr
22797
22798 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22799 +#endif
22800 +
22801 enable_paging:
22802
22803 /*
22804 @@ -449,14 +525,20 @@ is486:
22805 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22806 movl %eax,%ss # after changing gdt.
22807
22808 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22809 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22810 movl %eax,%ds
22811 movl %eax,%es
22812
22813 movl $(__KERNEL_PERCPU), %eax
22814 movl %eax,%fs # set this cpu's percpu
22815
22816 +#ifdef CONFIG_CC_STACKPROTECTOR
22817 movl $(__KERNEL_STACK_CANARY),%eax
22818 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22819 + movl $(__USER_DS),%eax
22820 +#else
22821 + xorl %eax,%eax
22822 +#endif
22823 movl %eax,%gs
22824
22825 xorl %eax,%eax # Clear LDT
22826 @@ -512,8 +594,11 @@ setup_once:
22827 * relocation. Manually set base address in stack canary
22828 * segment descriptor.
22829 */
22830 - movl $gdt_page,%eax
22831 + movl $cpu_gdt_table,%eax
22832 movl $stack_canary,%ecx
22833 +#ifdef CONFIG_SMP
22834 + addl $__per_cpu_load,%ecx
22835 +#endif
22836 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22837 shrl $16, %ecx
22838 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22839 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22840 /* This is global to keep gas from relaxing the jumps */
22841 ENTRY(early_idt_handler)
22842 cld
22843 - cmpl $2,%ss:early_recursion_flag
22844 + cmpl $1,%ss:early_recursion_flag
22845 je hlt_loop
22846 incl %ss:early_recursion_flag
22847
22848 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22849 pushl (20+6*4)(%esp) /* trapno */
22850 pushl $fault_msg
22851 call printk
22852 -#endif
22853 call dump_stack
22854 +#endif
22855 hlt_loop:
22856 hlt
22857 jmp hlt_loop
22858 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22859 /* This is the default interrupt "handler" :-) */
22860 ALIGN
22861 ignore_int:
22862 - cld
22863 #ifdef CONFIG_PRINTK
22864 + cmpl $2,%ss:early_recursion_flag
22865 + je hlt_loop
22866 + incl %ss:early_recursion_flag
22867 + cld
22868 pushl %eax
22869 pushl %ecx
22870 pushl %edx
22871 @@ -612,9 +700,6 @@ ignore_int:
22872 movl $(__KERNEL_DS),%eax
22873 movl %eax,%ds
22874 movl %eax,%es
22875 - cmpl $2,early_recursion_flag
22876 - je hlt_loop
22877 - incl early_recursion_flag
22878 pushl 16(%esp)
22879 pushl 24(%esp)
22880 pushl 32(%esp)
22881 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22882 /*
22883 * BSS section
22884 */
22885 -__PAGE_ALIGNED_BSS
22886 - .align PAGE_SIZE
22887 #ifdef CONFIG_X86_PAE
22888 +.section .initial_pg_pmd,"a",@progbits
22889 initial_pg_pmd:
22890 .fill 1024*KPMDS,4,0
22891 #else
22892 +.section .initial_page_table,"a",@progbits
22893 ENTRY(initial_page_table)
22894 .fill 1024,4,0
22895 #endif
22896 +.section .initial_pg_fixmap,"a",@progbits
22897 initial_pg_fixmap:
22898 .fill 1024,4,0
22899 +.section .empty_zero_page,"a",@progbits
22900 ENTRY(empty_zero_page)
22901 .fill 4096,1,0
22902 +.section .swapper_pg_dir,"a",@progbits
22903 ENTRY(swapper_pg_dir)
22904 +#ifdef CONFIG_X86_PAE
22905 + .fill 4,8,0
22906 +#else
22907 .fill 1024,4,0
22908 +#endif
22909
22910 /*
22911 * This starts the data section.
22912 */
22913 #ifdef CONFIG_X86_PAE
22914 -__PAGE_ALIGNED_DATA
22915 - /* Page-aligned for the benefit of paravirt? */
22916 - .align PAGE_SIZE
22917 +.section .initial_page_table,"a",@progbits
22918 ENTRY(initial_page_table)
22919 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22920 # if KPMDS == 3
22921 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22922 # error "Kernel PMDs should be 1, 2 or 3"
22923 # endif
22924 .align PAGE_SIZE /* needs to be page-sized too */
22925 +
22926 +#ifdef CONFIG_PAX_PER_CPU_PGD
22927 +ENTRY(cpu_pgd)
22928 + .rept 2*NR_CPUS
22929 + .fill 4,8,0
22930 + .endr
22931 +#endif
22932 +
22933 #endif
22934
22935 .data
22936 .balign 4
22937 ENTRY(stack_start)
22938 - .long init_thread_union+THREAD_SIZE
22939 + .long init_thread_union+THREAD_SIZE-8
22940
22941 __INITRODATA
22942 int_msg:
22943 @@ -722,7 +820,7 @@ fault_msg:
22944 * segment size, and 32-bit linear address value:
22945 */
22946
22947 - .data
22948 +.section .rodata,"a",@progbits
22949 .globl boot_gdt_descr
22950 .globl idt_descr
22951
22952 @@ -731,7 +829,7 @@ fault_msg:
22953 .word 0 # 32 bit align gdt_desc.address
22954 boot_gdt_descr:
22955 .word __BOOT_DS+7
22956 - .long boot_gdt - __PAGE_OFFSET
22957 + .long pa(boot_gdt)
22958
22959 .word 0 # 32-bit align idt_desc.address
22960 idt_descr:
22961 @@ -742,7 +840,7 @@ idt_descr:
22962 .word 0 # 32 bit align gdt_desc.address
22963 ENTRY(early_gdt_descr)
22964 .word GDT_ENTRIES*8-1
22965 - .long gdt_page /* Overwritten for secondary CPUs */
22966 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22967
22968 /*
22969 * The boot_gdt must mirror the equivalent in setup.S and is
22970 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22971 .align L1_CACHE_BYTES
22972 ENTRY(boot_gdt)
22973 .fill GDT_ENTRY_BOOT_CS,8,0
22974 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22975 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22976 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22977 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22978 +
22979 + .align PAGE_SIZE_asm
22980 +ENTRY(cpu_gdt_table)
22981 + .rept NR_CPUS
22982 + .quad 0x0000000000000000 /* NULL descriptor */
22983 + .quad 0x0000000000000000 /* 0x0b reserved */
22984 + .quad 0x0000000000000000 /* 0x13 reserved */
22985 + .quad 0x0000000000000000 /* 0x1b reserved */
22986 +
22987 +#ifdef CONFIG_PAX_KERNEXEC
22988 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22989 +#else
22990 + .quad 0x0000000000000000 /* 0x20 unused */
22991 +#endif
22992 +
22993 + .quad 0x0000000000000000 /* 0x28 unused */
22994 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22995 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22996 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22997 + .quad 0x0000000000000000 /* 0x4b reserved */
22998 + .quad 0x0000000000000000 /* 0x53 reserved */
22999 + .quad 0x0000000000000000 /* 0x5b reserved */
23000 +
23001 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23002 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23003 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23004 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23005 +
23006 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23007 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23008 +
23009 + /*
23010 + * Segments used for calling PnP BIOS have byte granularity.
23011 + * The code segments and data segments have fixed 64k limits,
23012 + * the transfer segment sizes are set at run time.
23013 + */
23014 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23015 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23016 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23017 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23018 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23019 +
23020 + /*
23021 + * The APM segments have byte granularity and their bases
23022 + * are set at run time. All have 64k limits.
23023 + */
23024 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23025 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23026 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23027 +
23028 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23029 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23030 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23031 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23032 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23033 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23034 +
23035 + /* Be sure this is zeroed to avoid false validations in Xen */
23036 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23037 + .endr
23038 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23039 index e1aabdb..fee4fee 100644
23040 --- a/arch/x86/kernel/head_64.S
23041 +++ b/arch/x86/kernel/head_64.S
23042 @@ -20,6 +20,8 @@
23043 #include <asm/processor-flags.h>
23044 #include <asm/percpu.h>
23045 #include <asm/nops.h>
23046 +#include <asm/cpufeature.h>
23047 +#include <asm/alternative-asm.h>
23048
23049 #ifdef CONFIG_PARAVIRT
23050 #include <asm/asm-offsets.h>
23051 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23052 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23053 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23054 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23055 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23056 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23057 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23058 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23059 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23060 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23061
23062 .text
23063 __HEAD
23064 @@ -89,11 +97,24 @@ startup_64:
23065 * Fixup the physical addresses in the page table
23066 */
23067 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23068 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23069 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23070 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23071 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23072 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23073
23074 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23075 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23076 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23077 +#ifndef CONFIG_XEN
23078 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23079 +#endif
23080 +
23081 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23082 +
23083 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23084 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23085
23086 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23087 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23088
23089 /*
23090 * Set up the identity mapping for the switchover. These
23091 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23092 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23093 1:
23094
23095 - /* Enable PAE mode and PGE */
23096 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23097 + /* Enable PAE mode and PSE/PGE */
23098 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23099 movq %rcx, %cr4
23100
23101 /* Setup early boot stage 4 level pagetables. */
23102 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23103 movl $MSR_EFER, %ecx
23104 rdmsr
23105 btsl $_EFER_SCE, %eax /* Enable System Call */
23106 - btl $20,%edi /* No Execute supported? */
23107 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23108 jnc 1f
23109 btsl $_EFER_NX, %eax
23110 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23111 +#ifndef CONFIG_EFI
23112 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23113 +#endif
23114 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23115 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
23116 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
23117 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
23118 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
23119 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23120 1: wrmsr /* Make changes effective */
23121
23122 /* Setup cr0 */
23123 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
23124 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23125 * address given in m16:64.
23126 */
23127 + pax_set_fptr_mask
23128 movq initial_code(%rip),%rax
23129 pushq $0 # fake return address to stop unwinder
23130 pushq $__KERNEL_CS # set correct cs
23131 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
23132 call dump_stack
23133 #ifdef CONFIG_KALLSYMS
23134 leaq early_idt_ripmsg(%rip),%rdi
23135 - movq 40(%rsp),%rsi # %rip again
23136 + movq 88(%rsp),%rsi # %rip again
23137 call __print_symbol
23138 #endif
23139 #endif /* EARLY_PRINTK */
23140 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
23141 early_recursion_flag:
23142 .long 0
23143
23144 + .section .rodata,"a",@progbits
23145 #ifdef CONFIG_EARLY_PRINTK
23146 early_idt_msg:
23147 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23148 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
23149 NEXT_PAGE(early_dynamic_pgts)
23150 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23151
23152 - .data
23153 + .section .rodata,"a",@progbits
23154
23155 -#ifndef CONFIG_XEN
23156 NEXT_PAGE(init_level4_pgt)
23157 - .fill 512,8,0
23158 -#else
23159 -NEXT_PAGE(init_level4_pgt)
23160 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23161 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23162 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23163 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23164 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23165 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23166 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23167 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23168 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23169 .org init_level4_pgt + L4_START_KERNEL*8, 0
23170 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23171 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23172
23173 +#ifdef CONFIG_PAX_PER_CPU_PGD
23174 +NEXT_PAGE(cpu_pgd)
23175 + .rept 2*NR_CPUS
23176 + .fill 512,8,0
23177 + .endr
23178 +#endif
23179 +
23180 NEXT_PAGE(level3_ident_pgt)
23181 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23182 +#ifdef CONFIG_XEN
23183 .fill 511, 8, 0
23184 +#else
23185 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23186 + .fill 510,8,0
23187 +#endif
23188 +
23189 +NEXT_PAGE(level3_vmalloc_start_pgt)
23190 + .fill 512,8,0
23191 +
23192 +NEXT_PAGE(level3_vmalloc_end_pgt)
23193 + .fill 512,8,0
23194 +
23195 +NEXT_PAGE(level3_vmemmap_pgt)
23196 + .fill L3_VMEMMAP_START,8,0
23197 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23198 +
23199 NEXT_PAGE(level2_ident_pgt)
23200 - /* Since I easily can, map the first 1G.
23201 + /* Since I easily can, map the first 2G.
23202 * Don't set NX because code runs from these pages.
23203 */
23204 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23205 -#endif
23206 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23207
23208 NEXT_PAGE(level3_kernel_pgt)
23209 .fill L3_START_KERNEL,8,0
23210 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
23211 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23212 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23213
23214 +NEXT_PAGE(level2_vmemmap_pgt)
23215 + .fill 512,8,0
23216 +
23217 NEXT_PAGE(level2_kernel_pgt)
23218 /*
23219 * 512 MB kernel mapping. We spend a full page on this pagetable
23220 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
23221 NEXT_PAGE(level2_fixmap_pgt)
23222 .fill 506,8,0
23223 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23224 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23225 - .fill 5,8,0
23226 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23227 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23228 + .fill 4,8,0
23229
23230 NEXT_PAGE(level1_fixmap_pgt)
23231 .fill 512,8,0
23232
23233 +NEXT_PAGE(level1_vsyscall_pgt)
23234 + .fill 512,8,0
23235 +
23236 #undef PMDS
23237
23238 - .data
23239 + .align PAGE_SIZE
23240 +ENTRY(cpu_gdt_table)
23241 + .rept NR_CPUS
23242 + .quad 0x0000000000000000 /* NULL descriptor */
23243 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23244 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23245 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23246 + .quad 0x00cffb000000ffff /* __USER32_CS */
23247 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23248 + .quad 0x00affb000000ffff /* __USER_CS */
23249 +
23250 +#ifdef CONFIG_PAX_KERNEXEC
23251 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23252 +#else
23253 + .quad 0x0 /* unused */
23254 +#endif
23255 +
23256 + .quad 0,0 /* TSS */
23257 + .quad 0,0 /* LDT */
23258 + .quad 0,0,0 /* three TLS descriptors */
23259 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23260 + /* asm/segment.h:GDT_ENTRIES must match this */
23261 +
23262 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23263 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23264 +#else
23265 + .quad 0x0 /* unused */
23266 +#endif
23267 +
23268 + /* zero the remaining page */
23269 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23270 + .endr
23271 +
23272 .align 16
23273 .globl early_gdt_descr
23274 early_gdt_descr:
23275 .word GDT_ENTRIES*8-1
23276 early_gdt_descr_base:
23277 - .quad INIT_PER_CPU_VAR(gdt_page)
23278 + .quad cpu_gdt_table
23279
23280 ENTRY(phys_base)
23281 /* This must match the first entry in level2_kernel_pgt */
23282 .quad 0x0000000000000000
23283
23284 #include "../../x86/xen/xen-head.S"
23285 -
23286 - __PAGE_ALIGNED_BSS
23287 +
23288 + .section .rodata,"a",@progbits
23289 NEXT_PAGE(empty_zero_page)
23290 .skip PAGE_SIZE
23291 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23292 index 0fa6912..b37438b 100644
23293 --- a/arch/x86/kernel/i386_ksyms_32.c
23294 +++ b/arch/x86/kernel/i386_ksyms_32.c
23295 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23296 EXPORT_SYMBOL(cmpxchg8b_emu);
23297 #endif
23298
23299 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23300 +
23301 /* Networking helper routines. */
23302 EXPORT_SYMBOL(csum_partial_copy_generic);
23303 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23304 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23305
23306 EXPORT_SYMBOL(__get_user_1);
23307 EXPORT_SYMBOL(__get_user_2);
23308 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23309
23310 EXPORT_SYMBOL(csum_partial);
23311 EXPORT_SYMBOL(empty_zero_page);
23312 +
23313 +#ifdef CONFIG_PAX_KERNEXEC
23314 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23315 +#endif
23316 +
23317 +#ifdef CONFIG_PAX_PER_CPU_PGD
23318 +EXPORT_SYMBOL(cpu_pgd);
23319 +#endif
23320 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23321 index 5d576ab..1403a03 100644
23322 --- a/arch/x86/kernel/i387.c
23323 +++ b/arch/x86/kernel/i387.c
23324 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23325 static inline bool interrupted_user_mode(void)
23326 {
23327 struct pt_regs *regs = get_irq_regs();
23328 - return regs && user_mode_vm(regs);
23329 + return regs && user_mode(regs);
23330 }
23331
23332 /*
23333 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23334 index 9a5c460..84868423 100644
23335 --- a/arch/x86/kernel/i8259.c
23336 +++ b/arch/x86/kernel/i8259.c
23337 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23338 static void make_8259A_irq(unsigned int irq)
23339 {
23340 disable_irq_nosync(irq);
23341 - io_apic_irqs &= ~(1<<irq);
23342 + io_apic_irqs &= ~(1UL<<irq);
23343 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23344 i8259A_chip.name);
23345 enable_irq(irq);
23346 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23347 "spurious 8259A interrupt: IRQ%d.\n", irq);
23348 spurious_irq_mask |= irqmask;
23349 }
23350 - atomic_inc(&irq_err_count);
23351 + atomic_inc_unchecked(&irq_err_count);
23352 /*
23353 * Theoretically we do not have to handle this IRQ,
23354 * but in Linux this does not cause problems and is
23355 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23356 /* (slave's support for AEOI in flat mode is to be investigated) */
23357 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23358
23359 + pax_open_kernel();
23360 if (auto_eoi)
23361 /*
23362 * In AEOI mode we just have to mask the interrupt
23363 * when acking.
23364 */
23365 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23366 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23367 else
23368 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23369 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23370 + pax_close_kernel();
23371
23372 udelay(100); /* wait for 8259A to initialize */
23373
23374 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23375 index a979b5b..1d6db75 100644
23376 --- a/arch/x86/kernel/io_delay.c
23377 +++ b/arch/x86/kernel/io_delay.c
23378 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23379 * Quirk table for systems that misbehave (lock up, etc.) if port
23380 * 0x80 is used:
23381 */
23382 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23383 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23384 {
23385 .callback = dmi_io_delay_0xed_port,
23386 .ident = "Compaq Presario V6000",
23387 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23388 index 4ddaf66..6292f4e 100644
23389 --- a/arch/x86/kernel/ioport.c
23390 +++ b/arch/x86/kernel/ioport.c
23391 @@ -6,6 +6,7 @@
23392 #include <linux/sched.h>
23393 #include <linux/kernel.h>
23394 #include <linux/capability.h>
23395 +#include <linux/security.h>
23396 #include <linux/errno.h>
23397 #include <linux/types.h>
23398 #include <linux/ioport.h>
23399 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23400
23401 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23402 return -EINVAL;
23403 +#ifdef CONFIG_GRKERNSEC_IO
23404 + if (turn_on && grsec_disable_privio) {
23405 + gr_handle_ioperm();
23406 + return -EPERM;
23407 + }
23408 +#endif
23409 if (turn_on && !capable(CAP_SYS_RAWIO))
23410 return -EPERM;
23411
23412 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23413 * because the ->io_bitmap_max value must match the bitmap
23414 * contents:
23415 */
23416 - tss = &per_cpu(init_tss, get_cpu());
23417 + tss = init_tss + get_cpu();
23418
23419 if (turn_on)
23420 bitmap_clear(t->io_bitmap_ptr, from, num);
23421 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23422 return -EINVAL;
23423 /* Trying to gain more privileges? */
23424 if (level > old) {
23425 +#ifdef CONFIG_GRKERNSEC_IO
23426 + if (grsec_disable_privio) {
23427 + gr_handle_iopl();
23428 + return -EPERM;
23429 + }
23430 +#endif
23431 if (!capable(CAP_SYS_RAWIO))
23432 return -EPERM;
23433 }
23434 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23435 index 22d0687..e07b2a5 100644
23436 --- a/arch/x86/kernel/irq.c
23437 +++ b/arch/x86/kernel/irq.c
23438 @@ -21,7 +21,7 @@
23439 #define CREATE_TRACE_POINTS
23440 #include <asm/trace/irq_vectors.h>
23441
23442 -atomic_t irq_err_count;
23443 +atomic_unchecked_t irq_err_count;
23444
23445 /* Function pointer for generic interrupt vector handling */
23446 void (*x86_platform_ipi_callback)(void) = NULL;
23447 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23448 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23449 seq_printf(p, " Machine check polls\n");
23450 #endif
23451 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23452 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23453 #if defined(CONFIG_X86_IO_APIC)
23454 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23455 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23456 #endif
23457 return 0;
23458 }
23459 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23460
23461 u64 arch_irq_stat(void)
23462 {
23463 - u64 sum = atomic_read(&irq_err_count);
23464 + u64 sum = atomic_read_unchecked(&irq_err_count);
23465 return sum;
23466 }
23467
23468 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23469 index 4186755..784efa0 100644
23470 --- a/arch/x86/kernel/irq_32.c
23471 +++ b/arch/x86/kernel/irq_32.c
23472 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23473 __asm__ __volatile__("andl %%esp,%0" :
23474 "=r" (sp) : "0" (THREAD_SIZE - 1));
23475
23476 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23477 + return sp < STACK_WARN;
23478 }
23479
23480 static void print_stack_overflow(void)
23481 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23482 * per-CPU IRQ handling contexts (thread information and stack)
23483 */
23484 union irq_ctx {
23485 - struct thread_info tinfo;
23486 - u32 stack[THREAD_SIZE/sizeof(u32)];
23487 + unsigned long previous_esp;
23488 + u32 stack[THREAD_SIZE/sizeof(u32)];
23489 } __attribute__((aligned(THREAD_SIZE)));
23490
23491 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23492 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23493 static inline int
23494 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23495 {
23496 - union irq_ctx *curctx, *irqctx;
23497 + union irq_ctx *irqctx;
23498 u32 *isp, arg1, arg2;
23499
23500 - curctx = (union irq_ctx *) current_thread_info();
23501 irqctx = __this_cpu_read(hardirq_ctx);
23502
23503 /*
23504 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23505 * handler) we can't do that and just have to keep using the
23506 * current stack (which is the irq stack already after all)
23507 */
23508 - if (unlikely(curctx == irqctx))
23509 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23510 return 0;
23511
23512 /* build the stack frame on the IRQ stack */
23513 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23514 - irqctx->tinfo.task = curctx->tinfo.task;
23515 - irqctx->tinfo.previous_esp = current_stack_pointer;
23516 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23517 + irqctx->previous_esp = current_stack_pointer;
23518
23519 - /* Copy the preempt_count so that the [soft]irq checks work. */
23520 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23522 + __set_fs(MAKE_MM_SEG(0));
23523 +#endif
23524
23525 if (unlikely(overflow))
23526 call_on_stack(print_stack_overflow, isp);
23527 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23528 : "0" (irq), "1" (desc), "2" (isp),
23529 "D" (desc->handle_irq)
23530 : "memory", "cc", "ecx");
23531 +
23532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23533 + __set_fs(current_thread_info()->addr_limit);
23534 +#endif
23535 +
23536 return 1;
23537 }
23538
23539 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23540 */
23541 void irq_ctx_init(int cpu)
23542 {
23543 - union irq_ctx *irqctx;
23544 -
23545 if (per_cpu(hardirq_ctx, cpu))
23546 return;
23547
23548 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23549 - THREADINFO_GFP,
23550 - THREAD_SIZE_ORDER));
23551 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23552 - irqctx->tinfo.cpu = cpu;
23553 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23554 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23555 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23556 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23557
23558 - per_cpu(hardirq_ctx, cpu) = irqctx;
23559 -
23560 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23561 - THREADINFO_GFP,
23562 - THREAD_SIZE_ORDER));
23563 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23564 - irqctx->tinfo.cpu = cpu;
23565 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23566 -
23567 - per_cpu(softirq_ctx, cpu) = irqctx;
23568 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23569 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23570
23571 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23572 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23573 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23574 asmlinkage void do_softirq(void)
23575 {
23576 unsigned long flags;
23577 - struct thread_info *curctx;
23578 union irq_ctx *irqctx;
23579 u32 *isp;
23580
23581 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23582 local_irq_save(flags);
23583
23584 if (local_softirq_pending()) {
23585 - curctx = current_thread_info();
23586 irqctx = __this_cpu_read(softirq_ctx);
23587 - irqctx->tinfo.task = curctx->task;
23588 - irqctx->tinfo.previous_esp = current_stack_pointer;
23589 + irqctx->previous_esp = current_stack_pointer;
23590
23591 /* build the stack frame on the softirq stack */
23592 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23593 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23594 +
23595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23596 + __set_fs(MAKE_MM_SEG(0));
23597 +#endif
23598
23599 call_on_stack(__do_softirq, isp);
23600 +
23601 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23602 + __set_fs(current_thread_info()->addr_limit);
23603 +#endif
23604 +
23605 /*
23606 * Shouldn't happen, we returned above if in_interrupt():
23607 */
23608 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23609 if (unlikely(!desc))
23610 return false;
23611
23612 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23613 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23614 if (unlikely(overflow))
23615 print_stack_overflow();
23616 desc->handle_irq(irq, desc);
23617 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23618 index d04d3ec..ea4b374 100644
23619 --- a/arch/x86/kernel/irq_64.c
23620 +++ b/arch/x86/kernel/irq_64.c
23621 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23622 u64 estack_top, estack_bottom;
23623 u64 curbase = (u64)task_stack_page(current);
23624
23625 - if (user_mode_vm(regs))
23626 + if (user_mode(regs))
23627 return;
23628
23629 if (regs->sp >= curbase + sizeof(struct thread_info) +
23630 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
23631 index ee11b7d..4df4d0c 100644
23632 --- a/arch/x86/kernel/jump_label.c
23633 +++ b/arch/x86/kernel/jump_label.c
23634 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
23635 * We are enabling this jump label. If it is not a nop
23636 * then something must have gone wrong.
23637 */
23638 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
23639 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
23640 bug_at((void *)entry->code, __LINE__);
23641
23642 code.jump = 0xe9;
23643 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
23644 */
23645 if (init) {
23646 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
23647 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
23648 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
23649 bug_at((void *)entry->code, __LINE__);
23650 } else {
23651 code.jump = 0xe9;
23652 code.offset = entry->target -
23653 (entry->code + JUMP_LABEL_NOP_SIZE);
23654 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
23655 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
23656 bug_at((void *)entry->code, __LINE__);
23657 }
23658 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
23659 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23660 index 836f832..a8bda67 100644
23661 --- a/arch/x86/kernel/kgdb.c
23662 +++ b/arch/x86/kernel/kgdb.c
23663 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23664 #ifdef CONFIG_X86_32
23665 switch (regno) {
23666 case GDB_SS:
23667 - if (!user_mode_vm(regs))
23668 + if (!user_mode(regs))
23669 *(unsigned long *)mem = __KERNEL_DS;
23670 break;
23671 case GDB_SP:
23672 - if (!user_mode_vm(regs))
23673 + if (!user_mode(regs))
23674 *(unsigned long *)mem = kernel_stack_pointer(regs);
23675 break;
23676 case GDB_GS:
23677 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23678 bp->attr.bp_addr = breakinfo[breakno].addr;
23679 bp->attr.bp_len = breakinfo[breakno].len;
23680 bp->attr.bp_type = breakinfo[breakno].type;
23681 - info->address = breakinfo[breakno].addr;
23682 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23683 + info->address = ktla_ktva(breakinfo[breakno].addr);
23684 + else
23685 + info->address = breakinfo[breakno].addr;
23686 info->len = breakinfo[breakno].len;
23687 info->type = breakinfo[breakno].type;
23688 val = arch_install_hw_breakpoint(bp);
23689 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23690 case 'k':
23691 /* clear the trace bit */
23692 linux_regs->flags &= ~X86_EFLAGS_TF;
23693 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23694 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23695
23696 /* set the trace bit if we're stepping */
23697 if (remcomInBuffer[0] == 's') {
23698 linux_regs->flags |= X86_EFLAGS_TF;
23699 - atomic_set(&kgdb_cpu_doing_single_step,
23700 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23701 raw_smp_processor_id());
23702 }
23703
23704 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23705
23706 switch (cmd) {
23707 case DIE_DEBUG:
23708 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23709 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23710 if (user_mode(regs))
23711 return single_step_cont(regs, args);
23712 break;
23713 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23714 #endif /* CONFIG_DEBUG_RODATA */
23715
23716 bpt->type = BP_BREAKPOINT;
23717 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23718 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23719 BREAK_INSTR_SIZE);
23720 if (err)
23721 return err;
23722 - err = probe_kernel_write((char *)bpt->bpt_addr,
23723 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23724 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23725 #ifdef CONFIG_DEBUG_RODATA
23726 if (!err)
23727 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23728 return -EBUSY;
23729 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23730 BREAK_INSTR_SIZE);
23731 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23732 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23733 if (err)
23734 return err;
23735 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23736 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23737 if (mutex_is_locked(&text_mutex))
23738 goto knl_write;
23739 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23740 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23741 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23742 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23743 goto knl_write;
23744 return err;
23745 knl_write:
23746 #endif /* CONFIG_DEBUG_RODATA */
23747 - return probe_kernel_write((char *)bpt->bpt_addr,
23748 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23749 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23750 }
23751
23752 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23753 index 79a3f96..6ba030a 100644
23754 --- a/arch/x86/kernel/kprobes/core.c
23755 +++ b/arch/x86/kernel/kprobes/core.c
23756 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23757 s32 raddr;
23758 } __packed *insn;
23759
23760 - insn = (struct __arch_relative_insn *)from;
23761 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23762 +
23763 + pax_open_kernel();
23764 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23765 insn->op = op;
23766 + pax_close_kernel();
23767 }
23768
23769 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23770 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23771 kprobe_opcode_t opcode;
23772 kprobe_opcode_t *orig_opcodes = opcodes;
23773
23774 - if (search_exception_tables((unsigned long)opcodes))
23775 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23776 return 0; /* Page fault may occur on this address. */
23777
23778 retry:
23779 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23780 * for the first byte, we can recover the original instruction
23781 * from it and kp->opcode.
23782 */
23783 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23784 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23785 buf[0] = kp->opcode;
23786 - return (unsigned long)buf;
23787 + return ktva_ktla((unsigned long)buf);
23788 }
23789
23790 /*
23791 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23792 /* Another subsystem puts a breakpoint, failed to recover */
23793 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23794 return 0;
23795 + pax_open_kernel();
23796 memcpy(dest, insn.kaddr, insn.length);
23797 + pax_close_kernel();
23798
23799 #ifdef CONFIG_X86_64
23800 if (insn_rip_relative(&insn)) {
23801 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23802 return 0;
23803 }
23804 disp = (u8 *) dest + insn_offset_displacement(&insn);
23805 + pax_open_kernel();
23806 *(s32 *) disp = (s32) newdisp;
23807 + pax_close_kernel();
23808 }
23809 #endif
23810 return insn.length;
23811 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23812 * nor set current_kprobe, because it doesn't use single
23813 * stepping.
23814 */
23815 - regs->ip = (unsigned long)p->ainsn.insn;
23816 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23817 preempt_enable_no_resched();
23818 return;
23819 }
23820 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23821 regs->flags &= ~X86_EFLAGS_IF;
23822 /* single step inline if the instruction is an int3 */
23823 if (p->opcode == BREAKPOINT_INSTRUCTION)
23824 - regs->ip = (unsigned long)p->addr;
23825 + regs->ip = ktla_ktva((unsigned long)p->addr);
23826 else
23827 - regs->ip = (unsigned long)p->ainsn.insn;
23828 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23829 }
23830
23831 /*
23832 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23833 setup_singlestep(p, regs, kcb, 0);
23834 return 1;
23835 }
23836 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23837 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23838 /*
23839 * The breakpoint instruction was removed right
23840 * after we hit it. Another cpu has removed
23841 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23842 " movq %rax, 152(%rsp)\n"
23843 RESTORE_REGS_STRING
23844 " popfq\n"
23845 +#ifdef KERNEXEC_PLUGIN
23846 + " btsq $63,(%rsp)\n"
23847 +#endif
23848 #else
23849 " pushf\n"
23850 SAVE_REGS_STRING
23851 @@ -779,7 +789,7 @@ static void __kprobes
23852 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23853 {
23854 unsigned long *tos = stack_addr(regs);
23855 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23856 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23857 unsigned long orig_ip = (unsigned long)p->addr;
23858 kprobe_opcode_t *insn = p->ainsn.insn;
23859
23860 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23861 struct die_args *args = data;
23862 int ret = NOTIFY_DONE;
23863
23864 - if (args->regs && user_mode_vm(args->regs))
23865 + if (args->regs && user_mode(args->regs))
23866 return ret;
23867
23868 switch (val) {
23869 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23870 index 898160b..758cde8 100644
23871 --- a/arch/x86/kernel/kprobes/opt.c
23872 +++ b/arch/x86/kernel/kprobes/opt.c
23873 @@ -79,6 +79,7 @@ found:
23874 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23875 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23876 {
23877 + pax_open_kernel();
23878 #ifdef CONFIG_X86_64
23879 *addr++ = 0x48;
23880 *addr++ = 0xbf;
23881 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23882 *addr++ = 0xb8;
23883 #endif
23884 *(unsigned long *)addr = val;
23885 + pax_close_kernel();
23886 }
23887
23888 asm (
23889 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23890 * Verify if the address gap is in 2GB range, because this uses
23891 * a relative jump.
23892 */
23893 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23894 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23895 if (abs(rel) > 0x7fffffff)
23896 return -ERANGE;
23897
23898 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23899 op->optinsn.size = ret;
23900
23901 /* Copy arch-dep-instance from template */
23902 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23903 + pax_open_kernel();
23904 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23905 + pax_close_kernel();
23906
23907 /* Set probe information */
23908 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23909
23910 /* Set probe function call */
23911 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23912 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23913
23914 /* Set returning jmp instruction at the tail of out-of-line buffer */
23915 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23916 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23917 (u8 *)op->kp.addr + op->optinsn.size);
23918
23919 flush_icache_range((unsigned long) buf,
23920 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
23921 WARN_ON(kprobe_disabled(&op->kp));
23922
23923 /* Backup instructions which will be replaced by jump address */
23924 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23925 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23926 RELATIVE_ADDR_SIZE);
23927
23928 insn_buf[0] = RELATIVEJUMP_OPCODE;
23929 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23930 /* This kprobe is really able to run optimized path. */
23931 op = container_of(p, struct optimized_kprobe, kp);
23932 /* Detour through copied instructions */
23933 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23934 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23935 if (!reenter)
23936 reset_current_kprobe();
23937 preempt_enable_no_resched();
23938 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23939 index ebc9873..1b9724b 100644
23940 --- a/arch/x86/kernel/ldt.c
23941 +++ b/arch/x86/kernel/ldt.c
23942 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23943 if (reload) {
23944 #ifdef CONFIG_SMP
23945 preempt_disable();
23946 - load_LDT(pc);
23947 + load_LDT_nolock(pc);
23948 if (!cpumask_equal(mm_cpumask(current->mm),
23949 cpumask_of(smp_processor_id())))
23950 smp_call_function(flush_ldt, current->mm, 1);
23951 preempt_enable();
23952 #else
23953 - load_LDT(pc);
23954 + load_LDT_nolock(pc);
23955 #endif
23956 }
23957 if (oldsize) {
23958 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23959 return err;
23960
23961 for (i = 0; i < old->size; i++)
23962 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23963 + write_ldt_entry(new->ldt, i, old->ldt + i);
23964 return 0;
23965 }
23966
23967 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23968 retval = copy_ldt(&mm->context, &old_mm->context);
23969 mutex_unlock(&old_mm->context.lock);
23970 }
23971 +
23972 + if (tsk == current) {
23973 + mm->context.vdso = 0;
23974 +
23975 +#ifdef CONFIG_X86_32
23976 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23977 + mm->context.user_cs_base = 0UL;
23978 + mm->context.user_cs_limit = ~0UL;
23979 +
23980 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23981 + cpus_clear(mm->context.cpu_user_cs_mask);
23982 +#endif
23983 +
23984 +#endif
23985 +#endif
23986 +
23987 + }
23988 +
23989 return retval;
23990 }
23991
23992 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23993 }
23994 }
23995
23996 +#ifdef CONFIG_PAX_SEGMEXEC
23997 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23998 + error = -EINVAL;
23999 + goto out_unlock;
24000 + }
24001 +#endif
24002 +
24003 fill_ldt(&ldt, &ldt_info);
24004 if (oldmode)
24005 ldt.avl = 0;
24006 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24007 index 5b19e4d..6476a76 100644
24008 --- a/arch/x86/kernel/machine_kexec_32.c
24009 +++ b/arch/x86/kernel/machine_kexec_32.c
24010 @@ -26,7 +26,7 @@
24011 #include <asm/cacheflush.h>
24012 #include <asm/debugreg.h>
24013
24014 -static void set_idt(void *newidt, __u16 limit)
24015 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24016 {
24017 struct desc_ptr curidt;
24018
24019 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24020 }
24021
24022
24023 -static void set_gdt(void *newgdt, __u16 limit)
24024 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24025 {
24026 struct desc_ptr curgdt;
24027
24028 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24029 }
24030
24031 control_page = page_address(image->control_code_page);
24032 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24033 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24034
24035 relocate_kernel_ptr = control_page;
24036 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24037 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24038 index 15c9876..0a43909 100644
24039 --- a/arch/x86/kernel/microcode_core.c
24040 +++ b/arch/x86/kernel/microcode_core.c
24041 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24042 return NOTIFY_OK;
24043 }
24044
24045 -static struct notifier_block __refdata mc_cpu_notifier = {
24046 +static struct notifier_block mc_cpu_notifier = {
24047 .notifier_call = mc_cpu_callback,
24048 };
24049
24050 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24051 index 5fb2ceb..3ae90bb 100644
24052 --- a/arch/x86/kernel/microcode_intel.c
24053 +++ b/arch/x86/kernel/microcode_intel.c
24054 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24055
24056 static int get_ucode_user(void *to, const void *from, size_t n)
24057 {
24058 - return copy_from_user(to, from, n);
24059 + return copy_from_user(to, (const void __force_user *)from, n);
24060 }
24061
24062 static enum ucode_state
24063 request_microcode_user(int cpu, const void __user *buf, size_t size)
24064 {
24065 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24066 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24067 }
24068
24069 static void microcode_fini_cpu(int cpu)
24070 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24071 index 216a4d7..228255a 100644
24072 --- a/arch/x86/kernel/module.c
24073 +++ b/arch/x86/kernel/module.c
24074 @@ -43,15 +43,60 @@ do { \
24075 } while (0)
24076 #endif
24077
24078 -void *module_alloc(unsigned long size)
24079 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24080 {
24081 - if (PAGE_ALIGN(size) > MODULES_LEN)
24082 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24083 return NULL;
24084 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24085 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24086 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24087 -1, __builtin_return_address(0));
24088 }
24089
24090 +void *module_alloc(unsigned long size)
24091 +{
24092 +
24093 +#ifdef CONFIG_PAX_KERNEXEC
24094 + return __module_alloc(size, PAGE_KERNEL);
24095 +#else
24096 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24097 +#endif
24098 +
24099 +}
24100 +
24101 +#ifdef CONFIG_PAX_KERNEXEC
24102 +#ifdef CONFIG_X86_32
24103 +void *module_alloc_exec(unsigned long size)
24104 +{
24105 + struct vm_struct *area;
24106 +
24107 + if (size == 0)
24108 + return NULL;
24109 +
24110 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24111 + return area ? area->addr : NULL;
24112 +}
24113 +EXPORT_SYMBOL(module_alloc_exec);
24114 +
24115 +void module_free_exec(struct module *mod, void *module_region)
24116 +{
24117 + vunmap(module_region);
24118 +}
24119 +EXPORT_SYMBOL(module_free_exec);
24120 +#else
24121 +void module_free_exec(struct module *mod, void *module_region)
24122 +{
24123 + module_free(mod, module_region);
24124 +}
24125 +EXPORT_SYMBOL(module_free_exec);
24126 +
24127 +void *module_alloc_exec(unsigned long size)
24128 +{
24129 + return __module_alloc(size, PAGE_KERNEL_RX);
24130 +}
24131 +EXPORT_SYMBOL(module_alloc_exec);
24132 +#endif
24133 +#endif
24134 +
24135 #ifdef CONFIG_X86_32
24136 int apply_relocate(Elf32_Shdr *sechdrs,
24137 const char *strtab,
24138 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24139 unsigned int i;
24140 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24141 Elf32_Sym *sym;
24142 - uint32_t *location;
24143 + uint32_t *plocation, location;
24144
24145 DEBUGP("Applying relocate section %u to %u\n",
24146 relsec, sechdrs[relsec].sh_info);
24147 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24148 /* This is where to make the change */
24149 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24150 - + rel[i].r_offset;
24151 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24152 + location = (uint32_t)plocation;
24153 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24154 + plocation = ktla_ktva((void *)plocation);
24155 /* This is the symbol it is referring to. Note that all
24156 undefined symbols have been resolved. */
24157 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24158 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24159 switch (ELF32_R_TYPE(rel[i].r_info)) {
24160 case R_386_32:
24161 /* We add the value into the location given */
24162 - *location += sym->st_value;
24163 + pax_open_kernel();
24164 + *plocation += sym->st_value;
24165 + pax_close_kernel();
24166 break;
24167 case R_386_PC32:
24168 /* Add the value, subtract its position */
24169 - *location += sym->st_value - (uint32_t)location;
24170 + pax_open_kernel();
24171 + *plocation += sym->st_value - location;
24172 + pax_close_kernel();
24173 break;
24174 default:
24175 pr_err("%s: Unknown relocation: %u\n",
24176 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24177 case R_X86_64_NONE:
24178 break;
24179 case R_X86_64_64:
24180 + pax_open_kernel();
24181 *(u64 *)loc = val;
24182 + pax_close_kernel();
24183 break;
24184 case R_X86_64_32:
24185 + pax_open_kernel();
24186 *(u32 *)loc = val;
24187 + pax_close_kernel();
24188 if (val != *(u32 *)loc)
24189 goto overflow;
24190 break;
24191 case R_X86_64_32S:
24192 + pax_open_kernel();
24193 *(s32 *)loc = val;
24194 + pax_close_kernel();
24195 if ((s64)val != *(s32 *)loc)
24196 goto overflow;
24197 break;
24198 case R_X86_64_PC32:
24199 val -= (u64)loc;
24200 + pax_open_kernel();
24201 *(u32 *)loc = val;
24202 + pax_close_kernel();
24203 +
24204 #if 0
24205 if ((s64)val != *(s32 *)loc)
24206 goto overflow;
24207 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24208 index 88458fa..349f7a4 100644
24209 --- a/arch/x86/kernel/msr.c
24210 +++ b/arch/x86/kernel/msr.c
24211 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24212 return notifier_from_errno(err);
24213 }
24214
24215 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24216 +static struct notifier_block msr_class_cpu_notifier = {
24217 .notifier_call = msr_class_cpu_callback,
24218 };
24219
24220 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24221 index 6fcb49c..5b3f4ff 100644
24222 --- a/arch/x86/kernel/nmi.c
24223 +++ b/arch/x86/kernel/nmi.c
24224 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24225 return handled;
24226 }
24227
24228 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24229 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24230 {
24231 struct nmi_desc *desc = nmi_to_desc(type);
24232 unsigned long flags;
24233 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24234 * event confuses some handlers (kdump uses this flag)
24235 */
24236 if (action->flags & NMI_FLAG_FIRST)
24237 - list_add_rcu(&action->list, &desc->head);
24238 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24239 else
24240 - list_add_tail_rcu(&action->list, &desc->head);
24241 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24242
24243 spin_unlock_irqrestore(&desc->lock, flags);
24244 return 0;
24245 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24246 if (!strcmp(n->name, name)) {
24247 WARN(in_nmi(),
24248 "Trying to free NMI (%s) from NMI context!\n", n->name);
24249 - list_del_rcu(&n->list);
24250 + pax_list_del_rcu((struct list_head *)&n->list);
24251 break;
24252 }
24253 }
24254 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24255 dotraplinkage notrace __kprobes void
24256 do_nmi(struct pt_regs *regs, long error_code)
24257 {
24258 +
24259 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24260 + if (!user_mode(regs)) {
24261 + unsigned long cs = regs->cs & 0xFFFF;
24262 + unsigned long ip = ktva_ktla(regs->ip);
24263 +
24264 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24265 + regs->ip = ip;
24266 + }
24267 +#endif
24268 +
24269 nmi_nesting_preprocess(regs);
24270
24271 nmi_enter();
24272 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24273 index 6d9582e..f746287 100644
24274 --- a/arch/x86/kernel/nmi_selftest.c
24275 +++ b/arch/x86/kernel/nmi_selftest.c
24276 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24277 {
24278 /* trap all the unknown NMIs we may generate */
24279 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24280 - __initdata);
24281 + __initconst);
24282 }
24283
24284 static void __init cleanup_nmi_testsuite(void)
24285 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24286 unsigned long timeout;
24287
24288 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24289 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24290 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24291 nmi_fail = FAILURE;
24292 return;
24293 }
24294 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24295 index bbb6c73..24a58ef 100644
24296 --- a/arch/x86/kernel/paravirt-spinlocks.c
24297 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24298 @@ -8,7 +8,7 @@
24299
24300 #include <asm/paravirt.h>
24301
24302 -struct pv_lock_ops pv_lock_ops = {
24303 +struct pv_lock_ops pv_lock_ops __read_only = {
24304 #ifdef CONFIG_SMP
24305 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
24306 .unlock_kick = paravirt_nop,
24307 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24308 index 1b10af8..0b58cbc 100644
24309 --- a/arch/x86/kernel/paravirt.c
24310 +++ b/arch/x86/kernel/paravirt.c
24311 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24312 {
24313 return x;
24314 }
24315 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24316 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24317 +#endif
24318
24319 void __init default_banner(void)
24320 {
24321 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24322 if (opfunc == NULL)
24323 /* If there's no function, patch it with a ud2a (BUG) */
24324 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24325 - else if (opfunc == _paravirt_nop)
24326 + else if (opfunc == (void *)_paravirt_nop)
24327 /* If the operation is a nop, then nop the callsite */
24328 ret = paravirt_patch_nop();
24329
24330 /* identity functions just return their single argument */
24331 - else if (opfunc == _paravirt_ident_32)
24332 + else if (opfunc == (void *)_paravirt_ident_32)
24333 ret = paravirt_patch_ident_32(insnbuf, len);
24334 - else if (opfunc == _paravirt_ident_64)
24335 + else if (opfunc == (void *)_paravirt_ident_64)
24336 ret = paravirt_patch_ident_64(insnbuf, len);
24337 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24338 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24339 + ret = paravirt_patch_ident_64(insnbuf, len);
24340 +#endif
24341
24342 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24343 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24344 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24345 if (insn_len > len || start == NULL)
24346 insn_len = len;
24347 else
24348 - memcpy(insnbuf, start, insn_len);
24349 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24350
24351 return insn_len;
24352 }
24353 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24354 return this_cpu_read(paravirt_lazy_mode);
24355 }
24356
24357 -struct pv_info pv_info = {
24358 +struct pv_info pv_info __read_only = {
24359 .name = "bare hardware",
24360 .paravirt_enabled = 0,
24361 .kernel_rpl = 0,
24362 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
24363 #endif
24364 };
24365
24366 -struct pv_init_ops pv_init_ops = {
24367 +struct pv_init_ops pv_init_ops __read_only = {
24368 .patch = native_patch,
24369 };
24370
24371 -struct pv_time_ops pv_time_ops = {
24372 +struct pv_time_ops pv_time_ops __read_only = {
24373 .sched_clock = native_sched_clock,
24374 .steal_clock = native_steal_clock,
24375 };
24376
24377 -__visible struct pv_irq_ops pv_irq_ops = {
24378 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
24379 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24380 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24381 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24382 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
24383 #endif
24384 };
24385
24386 -__visible struct pv_cpu_ops pv_cpu_ops = {
24387 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
24388 .cpuid = native_cpuid,
24389 .get_debugreg = native_get_debugreg,
24390 .set_debugreg = native_set_debugreg,
24391 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
24392 .end_context_switch = paravirt_nop,
24393 };
24394
24395 -struct pv_apic_ops pv_apic_ops = {
24396 +struct pv_apic_ops pv_apic_ops __read_only= {
24397 #ifdef CONFIG_X86_LOCAL_APIC
24398 .startup_ipi_hook = paravirt_nop,
24399 #endif
24400 };
24401
24402 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24403 +#ifdef CONFIG_X86_32
24404 +#ifdef CONFIG_X86_PAE
24405 +/* 64-bit pagetable entries */
24406 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24407 +#else
24408 /* 32-bit pagetable entries */
24409 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24410 +#endif
24411 #else
24412 /* 64-bit pagetable entries */
24413 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24414 #endif
24415
24416 -struct pv_mmu_ops pv_mmu_ops = {
24417 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24418
24419 .read_cr2 = native_read_cr2,
24420 .write_cr2 = native_write_cr2,
24421 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24422 .make_pud = PTE_IDENT,
24423
24424 .set_pgd = native_set_pgd,
24425 + .set_pgd_batched = native_set_pgd_batched,
24426 #endif
24427 #endif /* PAGETABLE_LEVELS >= 3 */
24428
24429 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24430 },
24431
24432 .set_fixmap = native_set_fixmap,
24433 +
24434 +#ifdef CONFIG_PAX_KERNEXEC
24435 + .pax_open_kernel = native_pax_open_kernel,
24436 + .pax_close_kernel = native_pax_close_kernel,
24437 +#endif
24438 +
24439 };
24440
24441 EXPORT_SYMBOL_GPL(pv_time_ops);
24442 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24443 index 299d493..2ccb0ee 100644
24444 --- a/arch/x86/kernel/pci-calgary_64.c
24445 +++ b/arch/x86/kernel/pci-calgary_64.c
24446 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24447 tce_space = be64_to_cpu(readq(target));
24448 tce_space = tce_space & TAR_SW_BITS;
24449
24450 - tce_space = tce_space & (~specified_table_size);
24451 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24452 info->tce_space = (u64 *)__va(tce_space);
24453 }
24454 }
24455 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24456 index 35ccf75..7a15747 100644
24457 --- a/arch/x86/kernel/pci-iommu_table.c
24458 +++ b/arch/x86/kernel/pci-iommu_table.c
24459 @@ -2,7 +2,7 @@
24460 #include <asm/iommu_table.h>
24461 #include <linux/string.h>
24462 #include <linux/kallsyms.h>
24463 -
24464 +#include <linux/sched.h>
24465
24466 #define DEBUG 1
24467
24468 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24469 index 6c483ba..d10ce2f 100644
24470 --- a/arch/x86/kernel/pci-swiotlb.c
24471 +++ b/arch/x86/kernel/pci-swiotlb.c
24472 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24473 void *vaddr, dma_addr_t dma_addr,
24474 struct dma_attrs *attrs)
24475 {
24476 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24477 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24478 }
24479
24480 static struct dma_map_ops swiotlb_dma_ops = {
24481 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24482 index c83516b..432ad6d 100644
24483 --- a/arch/x86/kernel/process.c
24484 +++ b/arch/x86/kernel/process.c
24485 @@ -36,7 +36,8 @@
24486 * section. Since TSS's are completely CPU-local, we want them
24487 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24488 */
24489 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24490 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24491 +EXPORT_SYMBOL(init_tss);
24492
24493 #ifdef CONFIG_X86_64
24494 static DEFINE_PER_CPU(unsigned char, is_idle);
24495 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24496 task_xstate_cachep =
24497 kmem_cache_create("task_xstate", xstate_size,
24498 __alignof__(union thread_xstate),
24499 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24500 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24501 }
24502
24503 /*
24504 @@ -105,7 +106,7 @@ void exit_thread(void)
24505 unsigned long *bp = t->io_bitmap_ptr;
24506
24507 if (bp) {
24508 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24509 + struct tss_struct *tss = init_tss + get_cpu();
24510
24511 t->io_bitmap_ptr = NULL;
24512 clear_thread_flag(TIF_IO_BITMAP);
24513 @@ -125,6 +126,9 @@ void flush_thread(void)
24514 {
24515 struct task_struct *tsk = current;
24516
24517 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24518 + loadsegment(gs, 0);
24519 +#endif
24520 flush_ptrace_hw_breakpoint(tsk);
24521 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24522 drop_init_fpu(tsk);
24523 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24524 void exit_idle(void)
24525 {
24526 /* idle loop has pid 0 */
24527 - if (current->pid)
24528 + if (task_pid_nr(current))
24529 return;
24530 __exit_idle();
24531 }
24532 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24533 return ret;
24534 }
24535 #endif
24536 -void stop_this_cpu(void *dummy)
24537 +__noreturn void stop_this_cpu(void *dummy)
24538 {
24539 local_irq_disable();
24540 /*
24541 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24542 }
24543 early_param("idle", idle_setup);
24544
24545 -unsigned long arch_align_stack(unsigned long sp)
24546 +#ifdef CONFIG_PAX_RANDKSTACK
24547 +void pax_randomize_kstack(struct pt_regs *regs)
24548 {
24549 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24550 - sp -= get_random_int() % 8192;
24551 - return sp & ~0xf;
24552 -}
24553 + struct thread_struct *thread = &current->thread;
24554 + unsigned long time;
24555
24556 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24557 -{
24558 - unsigned long range_end = mm->brk + 0x02000000;
24559 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24560 -}
24561 + if (!randomize_va_space)
24562 + return;
24563 +
24564 + if (v8086_mode(regs))
24565 + return;
24566
24567 + rdtscl(time);
24568 +
24569 + /* P4 seems to return a 0 LSB, ignore it */
24570 +#ifdef CONFIG_MPENTIUM4
24571 + time &= 0x3EUL;
24572 + time <<= 2;
24573 +#elif defined(CONFIG_X86_64)
24574 + time &= 0xFUL;
24575 + time <<= 4;
24576 +#else
24577 + time &= 0x1FUL;
24578 + time <<= 3;
24579 +#endif
24580 +
24581 + thread->sp0 ^= time;
24582 + load_sp0(init_tss + smp_processor_id(), thread);
24583 +
24584 +#ifdef CONFIG_X86_64
24585 + this_cpu_write(kernel_stack, thread->sp0);
24586 +#endif
24587 +}
24588 +#endif
24589 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24590 index 884f98f..ec23e04 100644
24591 --- a/arch/x86/kernel/process_32.c
24592 +++ b/arch/x86/kernel/process_32.c
24593 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24594 unsigned long thread_saved_pc(struct task_struct *tsk)
24595 {
24596 return ((unsigned long *)tsk->thread.sp)[3];
24597 +//XXX return tsk->thread.eip;
24598 }
24599
24600 void __show_regs(struct pt_regs *regs, int all)
24601 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24602 unsigned long sp;
24603 unsigned short ss, gs;
24604
24605 - if (user_mode_vm(regs)) {
24606 + if (user_mode(regs)) {
24607 sp = regs->sp;
24608 ss = regs->ss & 0xffff;
24609 - gs = get_user_gs(regs);
24610 } else {
24611 sp = kernel_stack_pointer(regs);
24612 savesegment(ss, ss);
24613 - savesegment(gs, gs);
24614 }
24615 + gs = get_user_gs(regs);
24616
24617 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24618 (u16)regs->cs, regs->ip, regs->flags,
24619 - smp_processor_id());
24620 + raw_smp_processor_id());
24621 print_symbol("EIP is at %s\n", regs->ip);
24622
24623 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24624 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24625 int copy_thread(unsigned long clone_flags, unsigned long sp,
24626 unsigned long arg, struct task_struct *p)
24627 {
24628 - struct pt_regs *childregs = task_pt_regs(p);
24629 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24630 struct task_struct *tsk;
24631 int err;
24632
24633 p->thread.sp = (unsigned long) childregs;
24634 p->thread.sp0 = (unsigned long) (childregs+1);
24635 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24636
24637 if (unlikely(p->flags & PF_KTHREAD)) {
24638 /* kernel thread */
24639 memset(childregs, 0, sizeof(struct pt_regs));
24640 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24641 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24642 - childregs->ds = __USER_DS;
24643 - childregs->es = __USER_DS;
24644 + savesegment(gs, childregs->gs);
24645 + childregs->ds = __KERNEL_DS;
24646 + childregs->es = __KERNEL_DS;
24647 childregs->fs = __KERNEL_PERCPU;
24648 childregs->bx = sp; /* function */
24649 childregs->bp = arg;
24650 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24651 struct thread_struct *prev = &prev_p->thread,
24652 *next = &next_p->thread;
24653 int cpu = smp_processor_id();
24654 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24655 + struct tss_struct *tss = init_tss + cpu;
24656 fpu_switch_t fpu;
24657
24658 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24659 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24660 */
24661 lazy_save_gs(prev->gs);
24662
24663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24664 + __set_fs(task_thread_info(next_p)->addr_limit);
24665 +#endif
24666 +
24667 /*
24668 * Load the per-thread Thread-Local Storage descriptor.
24669 */
24670 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24671 */
24672 arch_end_context_switch(next_p);
24673
24674 + this_cpu_write(current_task, next_p);
24675 + this_cpu_write(current_tinfo, &next_p->tinfo);
24676 +
24677 /*
24678 * Restore %gs if needed (which is common)
24679 */
24680 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24681
24682 switch_fpu_finish(next_p, fpu);
24683
24684 - this_cpu_write(current_task, next_p);
24685 -
24686 return prev_p;
24687 }
24688
24689 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24690 } while (count++ < 16);
24691 return 0;
24692 }
24693 -
24694 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24695 index bb1dc51..08dda7f 100644
24696 --- a/arch/x86/kernel/process_64.c
24697 +++ b/arch/x86/kernel/process_64.c
24698 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24699 struct pt_regs *childregs;
24700 struct task_struct *me = current;
24701
24702 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24703 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24704 childregs = task_pt_regs(p);
24705 p->thread.sp = (unsigned long) childregs;
24706 p->thread.usersp = me->thread.usersp;
24707 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24708 set_tsk_thread_flag(p, TIF_FORK);
24709 p->fpu_counter = 0;
24710 p->thread.io_bitmap_ptr = NULL;
24711 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24712 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24713 savesegment(es, p->thread.es);
24714 savesegment(ds, p->thread.ds);
24715 + savesegment(ss, p->thread.ss);
24716 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24717 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24718
24719 if (unlikely(p->flags & PF_KTHREAD)) {
24720 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24721 struct thread_struct *prev = &prev_p->thread;
24722 struct thread_struct *next = &next_p->thread;
24723 int cpu = smp_processor_id();
24724 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24725 + struct tss_struct *tss = init_tss + cpu;
24726 unsigned fsindex, gsindex;
24727 fpu_switch_t fpu;
24728
24729 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24730 if (unlikely(next->ds | prev->ds))
24731 loadsegment(ds, next->ds);
24732
24733 + savesegment(ss, prev->ss);
24734 + if (unlikely(next->ss != prev->ss))
24735 + loadsegment(ss, next->ss);
24736
24737 /* We must save %fs and %gs before load_TLS() because
24738 * %fs and %gs may be cleared by load_TLS().
24739 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24740 prev->usersp = this_cpu_read(old_rsp);
24741 this_cpu_write(old_rsp, next->usersp);
24742 this_cpu_write(current_task, next_p);
24743 + this_cpu_write(current_tinfo, &next_p->tinfo);
24744
24745 - this_cpu_write(kernel_stack,
24746 - (unsigned long)task_stack_page(next_p) +
24747 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24748 + this_cpu_write(kernel_stack, next->sp0);
24749
24750 /*
24751 * Now maybe reload the debug registers and handle I/O bitmaps
24752 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24753 if (!p || p == current || p->state == TASK_RUNNING)
24754 return 0;
24755 stack = (unsigned long)task_stack_page(p);
24756 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24757 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24758 return 0;
24759 fp = *(u64 *)(p->thread.sp);
24760 do {
24761 - if (fp < (unsigned long)stack ||
24762 - fp >= (unsigned long)stack+THREAD_SIZE)
24763 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24764 return 0;
24765 ip = *(u64 *)(fp+8);
24766 if (!in_sched_functions(ip))
24767 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24768 index 7461f50..1334029 100644
24769 --- a/arch/x86/kernel/ptrace.c
24770 +++ b/arch/x86/kernel/ptrace.c
24771 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24772 {
24773 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24774 unsigned long sp = (unsigned long)&regs->sp;
24775 - struct thread_info *tinfo;
24776
24777 - if (context == (sp & ~(THREAD_SIZE - 1)))
24778 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24779 return sp;
24780
24781 - tinfo = (struct thread_info *)context;
24782 - if (tinfo->previous_esp)
24783 - return tinfo->previous_esp;
24784 + sp = *(unsigned long *)context;
24785 + if (sp)
24786 + return sp;
24787
24788 return (unsigned long)regs;
24789 }
24790 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24791 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24792 {
24793 int i;
24794 - int dr7 = 0;
24795 + unsigned long dr7 = 0;
24796 struct arch_hw_breakpoint *info;
24797
24798 for (i = 0; i < HBP_NUM; i++) {
24799 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24800 unsigned long addr, unsigned long data)
24801 {
24802 int ret;
24803 - unsigned long __user *datap = (unsigned long __user *)data;
24804 + unsigned long __user *datap = (__force unsigned long __user *)data;
24805
24806 switch (request) {
24807 /* read the word at location addr in the USER area. */
24808 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24809 if ((int) addr < 0)
24810 return -EIO;
24811 ret = do_get_thread_area(child, addr,
24812 - (struct user_desc __user *)data);
24813 + (__force struct user_desc __user *) data);
24814 break;
24815
24816 case PTRACE_SET_THREAD_AREA:
24817 if ((int) addr < 0)
24818 return -EIO;
24819 ret = do_set_thread_area(child, addr,
24820 - (struct user_desc __user *)data, 0);
24821 + (__force struct user_desc __user *) data, 0);
24822 break;
24823 #endif
24824
24825 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24826
24827 #ifdef CONFIG_X86_64
24828
24829 -static struct user_regset x86_64_regsets[] __read_mostly = {
24830 +static user_regset_no_const x86_64_regsets[] __read_only = {
24831 [REGSET_GENERAL] = {
24832 .core_note_type = NT_PRSTATUS,
24833 .n = sizeof(struct user_regs_struct) / sizeof(long),
24834 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24835 #endif /* CONFIG_X86_64 */
24836
24837 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24838 -static struct user_regset x86_32_regsets[] __read_mostly = {
24839 +static user_regset_no_const x86_32_regsets[] __read_only = {
24840 [REGSET_GENERAL] = {
24841 .core_note_type = NT_PRSTATUS,
24842 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24843 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24844 */
24845 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24846
24847 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24848 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24849 {
24850 #ifdef CONFIG_X86_64
24851 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24852 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24853 memset(info, 0, sizeof(*info));
24854 info->si_signo = SIGTRAP;
24855 info->si_code = si_code;
24856 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24857 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24858 }
24859
24860 void user_single_step_siginfo(struct task_struct *tsk,
24861 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24862 # define IS_IA32 0
24863 #endif
24864
24865 +#ifdef CONFIG_GRKERNSEC_SETXID
24866 +extern void gr_delayed_cred_worker(void);
24867 +#endif
24868 +
24869 /*
24870 * We must return the syscall number to actually look up in the table.
24871 * This can be -1L to skip running any syscall at all.
24872 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24873
24874 user_exit();
24875
24876 +#ifdef CONFIG_GRKERNSEC_SETXID
24877 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24878 + gr_delayed_cred_worker();
24879 +#endif
24880 +
24881 /*
24882 * If we stepped into a sysenter/syscall insn, it trapped in
24883 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24884 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24885 */
24886 user_exit();
24887
24888 +#ifdef CONFIG_GRKERNSEC_SETXID
24889 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24890 + gr_delayed_cred_worker();
24891 +#endif
24892 +
24893 audit_syscall_exit(regs);
24894
24895 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24896 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24897 index a16bae3..1f65f25 100644
24898 --- a/arch/x86/kernel/pvclock.c
24899 +++ b/arch/x86/kernel/pvclock.c
24900 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24901 return pv_tsc_khz;
24902 }
24903
24904 -static atomic64_t last_value = ATOMIC64_INIT(0);
24905 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24906
24907 void pvclock_resume(void)
24908 {
24909 - atomic64_set(&last_value, 0);
24910 + atomic64_set_unchecked(&last_value, 0);
24911 }
24912
24913 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24914 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24915 * updating at the same time, and one of them could be slightly behind,
24916 * making the assumption that last_value always go forward fail to hold.
24917 */
24918 - last = atomic64_read(&last_value);
24919 + last = atomic64_read_unchecked(&last_value);
24920 do {
24921 if (ret < last)
24922 return last;
24923 - last = atomic64_cmpxchg(&last_value, last, ret);
24924 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24925 } while (unlikely(last != ret));
24926
24927 return ret;
24928 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24929 index 7e920bf..cc24446 100644
24930 --- a/arch/x86/kernel/reboot.c
24931 +++ b/arch/x86/kernel/reboot.c
24932 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24933
24934 void __noreturn machine_real_restart(unsigned int type)
24935 {
24936 +
24937 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24938 + struct desc_struct *gdt;
24939 +#endif
24940 +
24941 local_irq_disable();
24942
24943 /*
24944 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24945
24946 /* Jump to the identity-mapped low memory code */
24947 #ifdef CONFIG_X86_32
24948 - asm volatile("jmpl *%0" : :
24949 +
24950 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24951 + gdt = get_cpu_gdt_table(smp_processor_id());
24952 + pax_open_kernel();
24953 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24954 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24955 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24956 + loadsegment(ds, __KERNEL_DS);
24957 + loadsegment(es, __KERNEL_DS);
24958 + loadsegment(ss, __KERNEL_DS);
24959 +#endif
24960 +#ifdef CONFIG_PAX_KERNEXEC
24961 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24962 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24963 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24964 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24965 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24966 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24967 +#endif
24968 + pax_close_kernel();
24969 +#endif
24970 +
24971 + asm volatile("ljmpl *%0" : :
24972 "rm" (real_mode_header->machine_real_restart_asm),
24973 "a" (type));
24974 #else
24975 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24976 * try to force a triple fault and then cycle between hitting the keyboard
24977 * controller and doing that
24978 */
24979 -static void native_machine_emergency_restart(void)
24980 +static void __noreturn native_machine_emergency_restart(void)
24981 {
24982 int i;
24983 int attempt = 0;
24984 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
24985 #endif
24986 }
24987
24988 -static void __machine_emergency_restart(int emergency)
24989 +static void __noreturn __machine_emergency_restart(int emergency)
24990 {
24991 reboot_emergency = emergency;
24992 machine_ops.emergency_restart();
24993 }
24994
24995 -static void native_machine_restart(char *__unused)
24996 +static void __noreturn native_machine_restart(char *__unused)
24997 {
24998 pr_notice("machine restart\n");
24999
25000 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25001 __machine_emergency_restart(0);
25002 }
25003
25004 -static void native_machine_halt(void)
25005 +static void __noreturn native_machine_halt(void)
25006 {
25007 /* Stop other cpus and apics */
25008 machine_shutdown();
25009 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25010 stop_this_cpu(NULL);
25011 }
25012
25013 -static void native_machine_power_off(void)
25014 +static void __noreturn native_machine_power_off(void)
25015 {
25016 if (pm_power_off) {
25017 if (!reboot_force)
25018 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25019 }
25020 /* A fallback in case there is no PM info available */
25021 tboot_shutdown(TB_SHUTDOWN_HALT);
25022 + unreachable();
25023 }
25024
25025 -struct machine_ops machine_ops = {
25026 +struct machine_ops machine_ops __read_only = {
25027 .power_off = native_machine_power_off,
25028 .shutdown = native_machine_shutdown,
25029 .emergency_restart = native_machine_emergency_restart,
25030 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25031 index c8e41e9..64049ef 100644
25032 --- a/arch/x86/kernel/reboot_fixups_32.c
25033 +++ b/arch/x86/kernel/reboot_fixups_32.c
25034 @@ -57,7 +57,7 @@ struct device_fixup {
25035 unsigned int vendor;
25036 unsigned int device;
25037 void (*reboot_fixup)(struct pci_dev *);
25038 -};
25039 +} __do_const;
25040
25041 /*
25042 * PCI ids solely used for fixups_table go here
25043 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25044 index 3fd2c69..16ef367 100644
25045 --- a/arch/x86/kernel/relocate_kernel_64.S
25046 +++ b/arch/x86/kernel/relocate_kernel_64.S
25047 @@ -11,6 +11,7 @@
25048 #include <asm/kexec.h>
25049 #include <asm/processor-flags.h>
25050 #include <asm/pgtable_types.h>
25051 +#include <asm/alternative-asm.h>
25052
25053 /*
25054 * Must be relocatable PIC code callable as a C function
25055 @@ -96,8 +97,7 @@ relocate_kernel:
25056
25057 /* jump to identity mapped page */
25058 addq $(identity_mapped - relocate_kernel), %r8
25059 - pushq %r8
25060 - ret
25061 + jmp *%r8
25062
25063 identity_mapped:
25064 /* set return address to 0 if not preserving context */
25065 @@ -167,6 +167,7 @@ identity_mapped:
25066 xorl %r14d, %r14d
25067 xorl %r15d, %r15d
25068
25069 + pax_force_retaddr 0, 1
25070 ret
25071
25072 1:
25073 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25074 index f0de629..a4978a8f 100644
25075 --- a/arch/x86/kernel/setup.c
25076 +++ b/arch/x86/kernel/setup.c
25077 @@ -110,6 +110,7 @@
25078 #include <asm/mce.h>
25079 #include <asm/alternative.h>
25080 #include <asm/prom.h>
25081 +#include <asm/boot.h>
25082
25083 /*
25084 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25085 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25086 #endif
25087
25088
25089 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25090 -__visible unsigned long mmu_cr4_features;
25091 +#ifdef CONFIG_X86_64
25092 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25093 +#elif defined(CONFIG_X86_PAE)
25094 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25095 #else
25096 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25097 +__visible unsigned long mmu_cr4_features __read_only;
25098 #endif
25099
25100 +void set_in_cr4(unsigned long mask)
25101 +{
25102 + unsigned long cr4 = read_cr4();
25103 +
25104 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25105 + return;
25106 +
25107 + pax_open_kernel();
25108 + mmu_cr4_features |= mask;
25109 + pax_close_kernel();
25110 +
25111 + if (trampoline_cr4_features)
25112 + *trampoline_cr4_features = mmu_cr4_features;
25113 + cr4 |= mask;
25114 + write_cr4(cr4);
25115 +}
25116 +EXPORT_SYMBOL(set_in_cr4);
25117 +
25118 +void clear_in_cr4(unsigned long mask)
25119 +{
25120 + unsigned long cr4 = read_cr4();
25121 +
25122 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25123 + return;
25124 +
25125 + pax_open_kernel();
25126 + mmu_cr4_features &= ~mask;
25127 + pax_close_kernel();
25128 +
25129 + if (trampoline_cr4_features)
25130 + *trampoline_cr4_features = mmu_cr4_features;
25131 + cr4 &= ~mask;
25132 + write_cr4(cr4);
25133 +}
25134 +EXPORT_SYMBOL(clear_in_cr4);
25135 +
25136 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25137 int bootloader_type, bootloader_version;
25138
25139 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25140 * area (640->1Mb) as ram even though it is not.
25141 * take them out.
25142 */
25143 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25144 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25145
25146 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25147 }
25148 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25149 /* called before trim_bios_range() to spare extra sanitize */
25150 static void __init e820_add_kernel_range(void)
25151 {
25152 - u64 start = __pa_symbol(_text);
25153 + u64 start = __pa_symbol(ktla_ktva(_text));
25154 u64 size = __pa_symbol(_end) - start;
25155
25156 /*
25157 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25158
25159 void __init setup_arch(char **cmdline_p)
25160 {
25161 +#ifdef CONFIG_X86_32
25162 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25163 +#else
25164 memblock_reserve(__pa_symbol(_text),
25165 (unsigned long)__bss_stop - (unsigned long)_text);
25166 +#endif
25167
25168 early_reserve_initrd();
25169
25170 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25171
25172 if (!boot_params.hdr.root_flags)
25173 root_mountflags &= ~MS_RDONLY;
25174 - init_mm.start_code = (unsigned long) _text;
25175 - init_mm.end_code = (unsigned long) _etext;
25176 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25177 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25178 init_mm.end_data = (unsigned long) _edata;
25179 init_mm.brk = _brk_end;
25180
25181 - code_resource.start = __pa_symbol(_text);
25182 - code_resource.end = __pa_symbol(_etext)-1;
25183 - data_resource.start = __pa_symbol(_etext);
25184 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25185 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25186 + data_resource.start = __pa_symbol(_sdata);
25187 data_resource.end = __pa_symbol(_edata)-1;
25188 bss_resource.start = __pa_symbol(__bss_start);
25189 bss_resource.end = __pa_symbol(__bss_stop)-1;
25190 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25191 index 5cdff03..80fa283 100644
25192 --- a/arch/x86/kernel/setup_percpu.c
25193 +++ b/arch/x86/kernel/setup_percpu.c
25194 @@ -21,19 +21,17 @@
25195 #include <asm/cpu.h>
25196 #include <asm/stackprotector.h>
25197
25198 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25199 +#ifdef CONFIG_SMP
25200 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25201 EXPORT_PER_CPU_SYMBOL(cpu_number);
25202 +#endif
25203
25204 -#ifdef CONFIG_X86_64
25205 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25206 -#else
25207 -#define BOOT_PERCPU_OFFSET 0
25208 -#endif
25209
25210 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25211 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25212
25213 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25214 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25215 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25216 };
25217 EXPORT_SYMBOL(__per_cpu_offset);
25218 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25219 {
25220 #ifdef CONFIG_NEED_MULTIPLE_NODES
25221 pg_data_t *last = NULL;
25222 - unsigned int cpu;
25223 + int cpu;
25224
25225 for_each_possible_cpu(cpu) {
25226 int node = early_cpu_to_node(cpu);
25227 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25228 {
25229 #ifdef CONFIG_X86_32
25230 struct desc_struct gdt;
25231 + unsigned long base = per_cpu_offset(cpu);
25232
25233 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25234 - 0x2 | DESCTYPE_S, 0x8);
25235 - gdt.s = 1;
25236 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25237 + 0x83 | DESCTYPE_S, 0xC);
25238 write_gdt_entry(get_cpu_gdt_table(cpu),
25239 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25240 #endif
25241 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25242 /* alrighty, percpu areas up and running */
25243 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25244 for_each_possible_cpu(cpu) {
25245 +#ifdef CONFIG_CC_STACKPROTECTOR
25246 +#ifdef CONFIG_X86_32
25247 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25248 +#endif
25249 +#endif
25250 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25251 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25252 per_cpu(cpu_number, cpu) = cpu;
25253 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25254 */
25255 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25256 #endif
25257 +#ifdef CONFIG_CC_STACKPROTECTOR
25258 +#ifdef CONFIG_X86_32
25259 + if (!cpu)
25260 + per_cpu(stack_canary.canary, cpu) = canary;
25261 +#endif
25262 +#endif
25263 /*
25264 * Up to this point, the boot CPU has been using .init.data
25265 * area. Reload any changed state for the boot CPU.
25266 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25267 index 9e5de68..16c53cb 100644
25268 --- a/arch/x86/kernel/signal.c
25269 +++ b/arch/x86/kernel/signal.c
25270 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25271 * Align the stack pointer according to the i386 ABI,
25272 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25273 */
25274 - sp = ((sp + 4) & -16ul) - 4;
25275 + sp = ((sp - 12) & -16ul) - 4;
25276 #else /* !CONFIG_X86_32 */
25277 sp = round_down(sp, 16) - 8;
25278 #endif
25279 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25280 }
25281
25282 if (current->mm->context.vdso)
25283 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25284 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25285 else
25286 - restorer = &frame->retcode;
25287 + restorer = (void __user *)&frame->retcode;
25288 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25289 restorer = ksig->ka.sa.sa_restorer;
25290
25291 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25292 * reasons and because gdb uses it as a signature to notice
25293 * signal handler stack frames.
25294 */
25295 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25296 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25297
25298 if (err)
25299 return -EFAULT;
25300 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25301 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25302
25303 /* Set up to return from userspace. */
25304 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25305 + if (current->mm->context.vdso)
25306 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25307 + else
25308 + restorer = (void __user *)&frame->retcode;
25309 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25310 restorer = ksig->ka.sa.sa_restorer;
25311 put_user_ex(restorer, &frame->pretcode);
25312 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25313 * reasons and because gdb uses it as a signature to notice
25314 * signal handler stack frames.
25315 */
25316 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25317 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25318 } put_user_catch(err);
25319
25320 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25321 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25322 {
25323 int usig = signr_convert(ksig->sig);
25324 sigset_t *set = sigmask_to_save();
25325 - compat_sigset_t *cset = (compat_sigset_t *) set;
25326 + sigset_t sigcopy;
25327 + compat_sigset_t *cset;
25328 +
25329 + sigcopy = *set;
25330 +
25331 + cset = (compat_sigset_t *) &sigcopy;
25332
25333 /* Set up the stack frame */
25334 if (is_ia32_frame()) {
25335 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25336 } else if (is_x32_frame()) {
25337 return x32_setup_rt_frame(ksig, cset, regs);
25338 } else {
25339 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25340 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25341 }
25342 }
25343
25344 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25345 index 7c3a5a6..f0a8961 100644
25346 --- a/arch/x86/kernel/smp.c
25347 +++ b/arch/x86/kernel/smp.c
25348 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25349
25350 __setup("nonmi_ipi", nonmi_ipi_setup);
25351
25352 -struct smp_ops smp_ops = {
25353 +struct smp_ops smp_ops __read_only = {
25354 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25355 .smp_prepare_cpus = native_smp_prepare_cpus,
25356 .smp_cpus_done = native_smp_cpus_done,
25357 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25358 index 6cacab6..750636a 100644
25359 --- a/arch/x86/kernel/smpboot.c
25360 +++ b/arch/x86/kernel/smpboot.c
25361 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25362
25363 enable_start_cpu0 = 0;
25364
25365 -#ifdef CONFIG_X86_32
25366 - /* switch away from the initial page table */
25367 - load_cr3(swapper_pg_dir);
25368 - __flush_tlb_all();
25369 -#endif
25370 -
25371 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25372 barrier();
25373 +
25374 + /* switch away from the initial page table */
25375 +#ifdef CONFIG_PAX_PER_CPU_PGD
25376 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25377 + __flush_tlb_all();
25378 +#elif defined(CONFIG_X86_32)
25379 + load_cr3(swapper_pg_dir);
25380 + __flush_tlb_all();
25381 +#endif
25382 +
25383 /*
25384 * Check TSC synchronization with the BP:
25385 */
25386 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25387 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25388 (THREAD_SIZE + task_stack_page(idle))) - 1);
25389 per_cpu(current_task, cpu) = idle;
25390 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25391
25392 #ifdef CONFIG_X86_32
25393 /* Stack for startup_32 can be just as for start_secondary onwards */
25394 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25395 #else
25396 clear_tsk_thread_flag(idle, TIF_FORK);
25397 initial_gs = per_cpu_offset(cpu);
25398 - per_cpu(kernel_stack, cpu) =
25399 - (unsigned long)task_stack_page(idle) -
25400 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25401 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25402 #endif
25403 +
25404 + pax_open_kernel();
25405 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25406 + pax_close_kernel();
25407 +
25408 initial_code = (unsigned long)start_secondary;
25409 stack_start = idle->thread.sp;
25410
25411 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25412 /* the FPU context is blank, nobody can own it */
25413 __cpu_disable_lazy_restore(cpu);
25414
25415 +#ifdef CONFIG_PAX_PER_CPU_PGD
25416 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25417 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25418 + KERNEL_PGD_PTRS);
25419 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25420 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25421 + KERNEL_PGD_PTRS);
25422 +#endif
25423 +
25424 err = do_boot_cpu(apicid, cpu, tidle);
25425 if (err) {
25426 pr_debug("do_boot_cpu failed %d\n", err);
25427 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25428 index 9b4d51d..5d28b58 100644
25429 --- a/arch/x86/kernel/step.c
25430 +++ b/arch/x86/kernel/step.c
25431 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25432 struct desc_struct *desc;
25433 unsigned long base;
25434
25435 - seg &= ~7UL;
25436 + seg >>= 3;
25437
25438 mutex_lock(&child->mm->context.lock);
25439 - if (unlikely((seg >> 3) >= child->mm->context.size))
25440 + if (unlikely(seg >= child->mm->context.size))
25441 addr = -1L; /* bogus selector, access would fault */
25442 else {
25443 desc = child->mm->context.ldt + seg;
25444 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25445 addr += base;
25446 }
25447 mutex_unlock(&child->mm->context.lock);
25448 - }
25449 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25450 + addr = ktla_ktva(addr);
25451
25452 return addr;
25453 }
25454 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25455 unsigned char opcode[15];
25456 unsigned long addr = convert_ip_to_linear(child, regs);
25457
25458 + if (addr == -EINVAL)
25459 + return 0;
25460 +
25461 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25462 for (i = 0; i < copied; i++) {
25463 switch (opcode[i]) {
25464 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25465 new file mode 100644
25466 index 0000000..5877189
25467 --- /dev/null
25468 +++ b/arch/x86/kernel/sys_i386_32.c
25469 @@ -0,0 +1,189 @@
25470 +/*
25471 + * This file contains various random system calls that
25472 + * have a non-standard calling sequence on the Linux/i386
25473 + * platform.
25474 + */
25475 +
25476 +#include <linux/errno.h>
25477 +#include <linux/sched.h>
25478 +#include <linux/mm.h>
25479 +#include <linux/fs.h>
25480 +#include <linux/smp.h>
25481 +#include <linux/sem.h>
25482 +#include <linux/msg.h>
25483 +#include <linux/shm.h>
25484 +#include <linux/stat.h>
25485 +#include <linux/syscalls.h>
25486 +#include <linux/mman.h>
25487 +#include <linux/file.h>
25488 +#include <linux/utsname.h>
25489 +#include <linux/ipc.h>
25490 +#include <linux/elf.h>
25491 +
25492 +#include <linux/uaccess.h>
25493 +#include <linux/unistd.h>
25494 +
25495 +#include <asm/syscalls.h>
25496 +
25497 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25498 +{
25499 + unsigned long pax_task_size = TASK_SIZE;
25500 +
25501 +#ifdef CONFIG_PAX_SEGMEXEC
25502 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25503 + pax_task_size = SEGMEXEC_TASK_SIZE;
25504 +#endif
25505 +
25506 + if (flags & MAP_FIXED)
25507 + if (len > pax_task_size || addr > pax_task_size - len)
25508 + return -EINVAL;
25509 +
25510 + return 0;
25511 +}
25512 +
25513 +/*
25514 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25515 + */
25516 +static unsigned long get_align_mask(void)
25517 +{
25518 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25519 + return 0;
25520 +
25521 + if (!(current->flags & PF_RANDOMIZE))
25522 + return 0;
25523 +
25524 + return va_align.mask;
25525 +}
25526 +
25527 +unsigned long
25528 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25529 + unsigned long len, unsigned long pgoff, unsigned long flags)
25530 +{
25531 + struct mm_struct *mm = current->mm;
25532 + struct vm_area_struct *vma;
25533 + unsigned long pax_task_size = TASK_SIZE;
25534 + struct vm_unmapped_area_info info;
25535 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25536 +
25537 +#ifdef CONFIG_PAX_SEGMEXEC
25538 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25539 + pax_task_size = SEGMEXEC_TASK_SIZE;
25540 +#endif
25541 +
25542 + pax_task_size -= PAGE_SIZE;
25543 +
25544 + if (len > pax_task_size)
25545 + return -ENOMEM;
25546 +
25547 + if (flags & MAP_FIXED)
25548 + return addr;
25549 +
25550 +#ifdef CONFIG_PAX_RANDMMAP
25551 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25552 +#endif
25553 +
25554 + if (addr) {
25555 + addr = PAGE_ALIGN(addr);
25556 + if (pax_task_size - len >= addr) {
25557 + vma = find_vma(mm, addr);
25558 + if (check_heap_stack_gap(vma, addr, len, offset))
25559 + return addr;
25560 + }
25561 + }
25562 +
25563 + info.flags = 0;
25564 + info.length = len;
25565 + info.align_mask = filp ? get_align_mask() : 0;
25566 + info.align_offset = pgoff << PAGE_SHIFT;
25567 + info.threadstack_offset = offset;
25568 +
25569 +#ifdef CONFIG_PAX_PAGEEXEC
25570 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25571 + info.low_limit = 0x00110000UL;
25572 + info.high_limit = mm->start_code;
25573 +
25574 +#ifdef CONFIG_PAX_RANDMMAP
25575 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25576 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25577 +#endif
25578 +
25579 + if (info.low_limit < info.high_limit) {
25580 + addr = vm_unmapped_area(&info);
25581 + if (!IS_ERR_VALUE(addr))
25582 + return addr;
25583 + }
25584 + } else
25585 +#endif
25586 +
25587 + info.low_limit = mm->mmap_base;
25588 + info.high_limit = pax_task_size;
25589 +
25590 + return vm_unmapped_area(&info);
25591 +}
25592 +
25593 +unsigned long
25594 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25595 + const unsigned long len, const unsigned long pgoff,
25596 + const unsigned long flags)
25597 +{
25598 + struct vm_area_struct *vma;
25599 + struct mm_struct *mm = current->mm;
25600 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25601 + struct vm_unmapped_area_info info;
25602 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25603 +
25604 +#ifdef CONFIG_PAX_SEGMEXEC
25605 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25606 + pax_task_size = SEGMEXEC_TASK_SIZE;
25607 +#endif
25608 +
25609 + pax_task_size -= PAGE_SIZE;
25610 +
25611 + /* requested length too big for entire address space */
25612 + if (len > pax_task_size)
25613 + return -ENOMEM;
25614 +
25615 + if (flags & MAP_FIXED)
25616 + return addr;
25617 +
25618 +#ifdef CONFIG_PAX_PAGEEXEC
25619 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25620 + goto bottomup;
25621 +#endif
25622 +
25623 +#ifdef CONFIG_PAX_RANDMMAP
25624 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25625 +#endif
25626 +
25627 + /* requesting a specific address */
25628 + if (addr) {
25629 + addr = PAGE_ALIGN(addr);
25630 + if (pax_task_size - len >= addr) {
25631 + vma = find_vma(mm, addr);
25632 + if (check_heap_stack_gap(vma, addr, len, offset))
25633 + return addr;
25634 + }
25635 + }
25636 +
25637 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25638 + info.length = len;
25639 + info.low_limit = PAGE_SIZE;
25640 + info.high_limit = mm->mmap_base;
25641 + info.align_mask = filp ? get_align_mask() : 0;
25642 + info.align_offset = pgoff << PAGE_SHIFT;
25643 + info.threadstack_offset = offset;
25644 +
25645 + addr = vm_unmapped_area(&info);
25646 + if (!(addr & ~PAGE_MASK))
25647 + return addr;
25648 + VM_BUG_ON(addr != -ENOMEM);
25649 +
25650 +bottomup:
25651 + /*
25652 + * A failed mmap() very likely causes application failure,
25653 + * so fall back to the bottom-up function here. This scenario
25654 + * can happen with large stack limits and large mmap()
25655 + * allocations.
25656 + */
25657 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25658 +}
25659 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25660 index 30277e2..5664a29 100644
25661 --- a/arch/x86/kernel/sys_x86_64.c
25662 +++ b/arch/x86/kernel/sys_x86_64.c
25663 @@ -81,8 +81,8 @@ out:
25664 return error;
25665 }
25666
25667 -static void find_start_end(unsigned long flags, unsigned long *begin,
25668 - unsigned long *end)
25669 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25670 + unsigned long *begin, unsigned long *end)
25671 {
25672 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25673 unsigned long new_begin;
25674 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25675 *begin = new_begin;
25676 }
25677 } else {
25678 - *begin = current->mm->mmap_legacy_base;
25679 + *begin = mm->mmap_legacy_base;
25680 *end = TASK_SIZE;
25681 }
25682 }
25683 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25684 struct vm_area_struct *vma;
25685 struct vm_unmapped_area_info info;
25686 unsigned long begin, end;
25687 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25688
25689 if (flags & MAP_FIXED)
25690 return addr;
25691
25692 - find_start_end(flags, &begin, &end);
25693 + find_start_end(mm, flags, &begin, &end);
25694
25695 if (len > end)
25696 return -ENOMEM;
25697
25698 +#ifdef CONFIG_PAX_RANDMMAP
25699 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25700 +#endif
25701 +
25702 if (addr) {
25703 addr = PAGE_ALIGN(addr);
25704 vma = find_vma(mm, addr);
25705 - if (end - len >= addr &&
25706 - (!vma || addr + len <= vma->vm_start))
25707 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25708 return addr;
25709 }
25710
25711 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25712 info.high_limit = end;
25713 info.align_mask = filp ? get_align_mask() : 0;
25714 info.align_offset = pgoff << PAGE_SHIFT;
25715 + info.threadstack_offset = offset;
25716 return vm_unmapped_area(&info);
25717 }
25718
25719 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25720 struct mm_struct *mm = current->mm;
25721 unsigned long addr = addr0;
25722 struct vm_unmapped_area_info info;
25723 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25724
25725 /* requested length too big for entire address space */
25726 if (len > TASK_SIZE)
25727 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25728 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25729 goto bottomup;
25730
25731 +#ifdef CONFIG_PAX_RANDMMAP
25732 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25733 +#endif
25734 +
25735 /* requesting a specific address */
25736 if (addr) {
25737 addr = PAGE_ALIGN(addr);
25738 vma = find_vma(mm, addr);
25739 - if (TASK_SIZE - len >= addr &&
25740 - (!vma || addr + len <= vma->vm_start))
25741 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25742 return addr;
25743 }
25744
25745 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25746 info.high_limit = mm->mmap_base;
25747 info.align_mask = filp ? get_align_mask() : 0;
25748 info.align_offset = pgoff << PAGE_SHIFT;
25749 + info.threadstack_offset = offset;
25750 addr = vm_unmapped_area(&info);
25751 if (!(addr & ~PAGE_MASK))
25752 return addr;
25753 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25754 index 91a4496..1730bff 100644
25755 --- a/arch/x86/kernel/tboot.c
25756 +++ b/arch/x86/kernel/tboot.c
25757 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25758
25759 void tboot_shutdown(u32 shutdown_type)
25760 {
25761 - void (*shutdown)(void);
25762 + void (* __noreturn shutdown)(void);
25763
25764 if (!tboot_enabled())
25765 return;
25766 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25767
25768 switch_to_tboot_pt();
25769
25770 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25771 + shutdown = (void *)tboot->shutdown_entry;
25772 shutdown();
25773
25774 /* should not reach here */
25775 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
25776 return -ENODEV;
25777 }
25778
25779 -static atomic_t ap_wfs_count;
25780 +static atomic_unchecked_t ap_wfs_count;
25781
25782 static int tboot_wait_for_aps(int num_aps)
25783 {
25784 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25785 {
25786 switch (action) {
25787 case CPU_DYING:
25788 - atomic_inc(&ap_wfs_count);
25789 + atomic_inc_unchecked(&ap_wfs_count);
25790 if (num_online_cpus() == 1)
25791 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25792 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25793 return NOTIFY_BAD;
25794 break;
25795 }
25796 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
25797
25798 tboot_create_trampoline();
25799
25800 - atomic_set(&ap_wfs_count, 0);
25801 + atomic_set_unchecked(&ap_wfs_count, 0);
25802 register_hotcpu_notifier(&tboot_cpu_notifier);
25803
25804 #ifdef CONFIG_DEBUG_FS
25805 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25806 index 24d3c91..d06b473 100644
25807 --- a/arch/x86/kernel/time.c
25808 +++ b/arch/x86/kernel/time.c
25809 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25810 {
25811 unsigned long pc = instruction_pointer(regs);
25812
25813 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25814 + if (!user_mode(regs) && in_lock_functions(pc)) {
25815 #ifdef CONFIG_FRAME_POINTER
25816 - return *(unsigned long *)(regs->bp + sizeof(long));
25817 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25818 #else
25819 unsigned long *sp =
25820 (unsigned long *)kernel_stack_pointer(regs);
25821 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25822 * or above a saved flags. Eflags has bits 22-31 zero,
25823 * kernel addresses don't.
25824 */
25825 +
25826 +#ifdef CONFIG_PAX_KERNEXEC
25827 + return ktla_ktva(sp[0]);
25828 +#else
25829 if (sp[0] >> 22)
25830 return sp[0];
25831 if (sp[1] >> 22)
25832 return sp[1];
25833 #endif
25834 +
25835 +#endif
25836 }
25837 return pc;
25838 }
25839 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25840 index f7fec09..9991981 100644
25841 --- a/arch/x86/kernel/tls.c
25842 +++ b/arch/x86/kernel/tls.c
25843 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25844 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25845 return -EINVAL;
25846
25847 +#ifdef CONFIG_PAX_SEGMEXEC
25848 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25849 + return -EINVAL;
25850 +#endif
25851 +
25852 set_tls_desc(p, idx, &info, 1);
25853
25854 return 0;
25855 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25856
25857 if (kbuf)
25858 info = kbuf;
25859 - else if (__copy_from_user(infobuf, ubuf, count))
25860 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25861 return -EFAULT;
25862 else
25863 info = infobuf;
25864 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25865 index 1c113db..287b42e 100644
25866 --- a/arch/x86/kernel/tracepoint.c
25867 +++ b/arch/x86/kernel/tracepoint.c
25868 @@ -9,11 +9,11 @@
25869 #include <linux/atomic.h>
25870
25871 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25872 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25873 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25874 (unsigned long) trace_idt_table };
25875
25876 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25877 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25878 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25879
25880 static int trace_irq_vector_refcount;
25881 static DEFINE_MUTEX(irq_vector_mutex);
25882 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25883 index 8c8093b..c93f581 100644
25884 --- a/arch/x86/kernel/traps.c
25885 +++ b/arch/x86/kernel/traps.c
25886 @@ -66,7 +66,7 @@
25887 #include <asm/proto.h>
25888
25889 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25890 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25891 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25892 #else
25893 #include <asm/processor-flags.h>
25894 #include <asm/setup.h>
25895 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
25896 #endif
25897
25898 /* Must be page-aligned because the real IDT is used in a fixmap. */
25899 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25900 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25901
25902 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25903 EXPORT_SYMBOL_GPL(used_vectors);
25904 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25905 }
25906
25907 static int __kprobes
25908 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25909 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25910 struct pt_regs *regs, long error_code)
25911 {
25912 #ifdef CONFIG_X86_32
25913 - if (regs->flags & X86_VM_MASK) {
25914 + if (v8086_mode(regs)) {
25915 /*
25916 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25917 * On nmi (interrupt 2), do_trap should not be called.
25918 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25919 return -1;
25920 }
25921 #endif
25922 - if (!user_mode(regs)) {
25923 + if (!user_mode_novm(regs)) {
25924 if (!fixup_exception(regs)) {
25925 tsk->thread.error_code = error_code;
25926 tsk->thread.trap_nr = trapnr;
25927 +
25928 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25929 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25930 + str = "PAX: suspicious stack segment fault";
25931 +#endif
25932 +
25933 die(str, regs, error_code);
25934 }
25935 +
25936 +#ifdef CONFIG_PAX_REFCOUNT
25937 + if (trapnr == 4)
25938 + pax_report_refcount_overflow(regs);
25939 +#endif
25940 +
25941 return 0;
25942 }
25943
25944 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25945 }
25946
25947 static void __kprobes
25948 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25949 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25950 long error_code, siginfo_t *info)
25951 {
25952 struct task_struct *tsk = current;
25953 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25954 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25955 printk_ratelimit()) {
25956 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25957 - tsk->comm, tsk->pid, str,
25958 + tsk->comm, task_pid_nr(tsk), str,
25959 regs->ip, regs->sp, error_code);
25960 print_vma_addr(" in ", regs->ip);
25961 pr_cont("\n");
25962 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25963 conditional_sti(regs);
25964
25965 #ifdef CONFIG_X86_32
25966 - if (regs->flags & X86_VM_MASK) {
25967 + if (v8086_mode(regs)) {
25968 local_irq_enable();
25969 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25970 goto exit;
25971 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25972 #endif
25973
25974 tsk = current;
25975 - if (!user_mode(regs)) {
25976 + if (!user_mode_novm(regs)) {
25977 if (fixup_exception(regs))
25978 goto exit;
25979
25980 tsk->thread.error_code = error_code;
25981 tsk->thread.trap_nr = X86_TRAP_GP;
25982 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25983 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25984 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25985 +
25986 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25987 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25988 + die("PAX: suspicious general protection fault", regs, error_code);
25989 + else
25990 +#endif
25991 +
25992 die("general protection fault", regs, error_code);
25993 + }
25994 goto exit;
25995 }
25996
25997 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25998 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25999 + struct mm_struct *mm = tsk->mm;
26000 + unsigned long limit;
26001 +
26002 + down_write(&mm->mmap_sem);
26003 + limit = mm->context.user_cs_limit;
26004 + if (limit < TASK_SIZE) {
26005 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26006 + up_write(&mm->mmap_sem);
26007 + return;
26008 + }
26009 + up_write(&mm->mmap_sem);
26010 + }
26011 +#endif
26012 +
26013 tsk->thread.error_code = error_code;
26014 tsk->thread.trap_nr = X86_TRAP_GP;
26015
26016 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26017 /* It's safe to allow irq's after DR6 has been saved */
26018 preempt_conditional_sti(regs);
26019
26020 - if (regs->flags & X86_VM_MASK) {
26021 + if (v8086_mode(regs)) {
26022 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26023 X86_TRAP_DB);
26024 preempt_conditional_cli(regs);
26025 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26026 * We already checked v86 mode above, so we can check for kernel mode
26027 * by just checking the CPL of CS.
26028 */
26029 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26030 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26031 tsk->thread.debugreg6 &= ~DR_STEP;
26032 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26033 regs->flags &= ~X86_EFLAGS_TF;
26034 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26035 return;
26036 conditional_sti(regs);
26037
26038 - if (!user_mode_vm(regs))
26039 + if (!user_mode(regs))
26040 {
26041 if (!fixup_exception(regs)) {
26042 task->thread.error_code = error_code;
26043 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26044 index 2ed8459..7cf329f 100644
26045 --- a/arch/x86/kernel/uprobes.c
26046 +++ b/arch/x86/kernel/uprobes.c
26047 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26048 int ret = NOTIFY_DONE;
26049
26050 /* We are only interested in userspace traps */
26051 - if (regs && !user_mode_vm(regs))
26052 + if (regs && !user_mode(regs))
26053 return NOTIFY_DONE;
26054
26055 switch (val) {
26056 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26057
26058 if (ncopied != rasize) {
26059 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26060 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26061 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26062
26063 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26064 }
26065 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26066 index b9242ba..50c5edd 100644
26067 --- a/arch/x86/kernel/verify_cpu.S
26068 +++ b/arch/x86/kernel/verify_cpu.S
26069 @@ -20,6 +20,7 @@
26070 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26071 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26072 * arch/x86/kernel/head_32.S: processor startup
26073 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26074 *
26075 * verify_cpu, returns the status of longmode and SSE in register %eax.
26076 * 0: Success 1: Failure
26077 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26078 index e8edcf5..27f9344 100644
26079 --- a/arch/x86/kernel/vm86_32.c
26080 +++ b/arch/x86/kernel/vm86_32.c
26081 @@ -44,6 +44,7 @@
26082 #include <linux/ptrace.h>
26083 #include <linux/audit.h>
26084 #include <linux/stddef.h>
26085 +#include <linux/grsecurity.h>
26086
26087 #include <asm/uaccess.h>
26088 #include <asm/io.h>
26089 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26090 do_exit(SIGSEGV);
26091 }
26092
26093 - tss = &per_cpu(init_tss, get_cpu());
26094 + tss = init_tss + get_cpu();
26095 current->thread.sp0 = current->thread.saved_sp0;
26096 current->thread.sysenter_cs = __KERNEL_CS;
26097 load_sp0(tss, &current->thread);
26098 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26099
26100 if (tsk->thread.saved_sp0)
26101 return -EPERM;
26102 +
26103 +#ifdef CONFIG_GRKERNSEC_VM86
26104 + if (!capable(CAP_SYS_RAWIO)) {
26105 + gr_handle_vm86();
26106 + return -EPERM;
26107 + }
26108 +#endif
26109 +
26110 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26111 offsetof(struct kernel_vm86_struct, vm86plus) -
26112 sizeof(info.regs));
26113 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26114 int tmp;
26115 struct vm86plus_struct __user *v86;
26116
26117 +#ifdef CONFIG_GRKERNSEC_VM86
26118 + if (!capable(CAP_SYS_RAWIO)) {
26119 + gr_handle_vm86();
26120 + return -EPERM;
26121 + }
26122 +#endif
26123 +
26124 tsk = current;
26125 switch (cmd) {
26126 case VM86_REQUEST_IRQ:
26127 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26128 tsk->thread.saved_fs = info->regs32->fs;
26129 tsk->thread.saved_gs = get_user_gs(info->regs32);
26130
26131 - tss = &per_cpu(init_tss, get_cpu());
26132 + tss = init_tss + get_cpu();
26133 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26134 if (cpu_has_sep)
26135 tsk->thread.sysenter_cs = 0;
26136 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26137 goto cannot_handle;
26138 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26139 goto cannot_handle;
26140 - intr_ptr = (unsigned long __user *) (i << 2);
26141 + intr_ptr = (__force unsigned long __user *) (i << 2);
26142 if (get_user(segoffs, intr_ptr))
26143 goto cannot_handle;
26144 if ((segoffs >> 16) == BIOSSEG)
26145 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26146 index 10c4f30..65408b9 100644
26147 --- a/arch/x86/kernel/vmlinux.lds.S
26148 +++ b/arch/x86/kernel/vmlinux.lds.S
26149 @@ -26,6 +26,13 @@
26150 #include <asm/page_types.h>
26151 #include <asm/cache.h>
26152 #include <asm/boot.h>
26153 +#include <asm/segment.h>
26154 +
26155 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26156 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26157 +#else
26158 +#define __KERNEL_TEXT_OFFSET 0
26159 +#endif
26160
26161 #undef i386 /* in case the preprocessor is a 32bit one */
26162
26163 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26164
26165 PHDRS {
26166 text PT_LOAD FLAGS(5); /* R_E */
26167 +#ifdef CONFIG_X86_32
26168 + module PT_LOAD FLAGS(5); /* R_E */
26169 +#endif
26170 +#ifdef CONFIG_XEN
26171 + rodata PT_LOAD FLAGS(5); /* R_E */
26172 +#else
26173 + rodata PT_LOAD FLAGS(4); /* R__ */
26174 +#endif
26175 data PT_LOAD FLAGS(6); /* RW_ */
26176 -#ifdef CONFIG_X86_64
26177 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26178 #ifdef CONFIG_SMP
26179 percpu PT_LOAD FLAGS(6); /* RW_ */
26180 #endif
26181 + text.init PT_LOAD FLAGS(5); /* R_E */
26182 + text.exit PT_LOAD FLAGS(5); /* R_E */
26183 init PT_LOAD FLAGS(7); /* RWE */
26184 -#endif
26185 note PT_NOTE FLAGS(0); /* ___ */
26186 }
26187
26188 SECTIONS
26189 {
26190 #ifdef CONFIG_X86_32
26191 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26192 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26193 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26194 #else
26195 - . = __START_KERNEL;
26196 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26197 + . = __START_KERNEL;
26198 #endif
26199
26200 /* Text and read-only data */
26201 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26202 - _text = .;
26203 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26204 /* bootstrapping code */
26205 +#ifdef CONFIG_X86_32
26206 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26207 +#else
26208 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26209 +#endif
26210 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26211 + _text = .;
26212 HEAD_TEXT
26213 . = ALIGN(8);
26214 _stext = .;
26215 @@ -104,13 +124,47 @@ SECTIONS
26216 IRQENTRY_TEXT
26217 *(.fixup)
26218 *(.gnu.warning)
26219 - /* End of text section */
26220 - _etext = .;
26221 } :text = 0x9090
26222
26223 - NOTES :text :note
26224 + . += __KERNEL_TEXT_OFFSET;
26225
26226 - EXCEPTION_TABLE(16) :text = 0x9090
26227 +#ifdef CONFIG_X86_32
26228 + . = ALIGN(PAGE_SIZE);
26229 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26230 +
26231 +#ifdef CONFIG_PAX_KERNEXEC
26232 + MODULES_EXEC_VADDR = .;
26233 + BYTE(0)
26234 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26235 + . = ALIGN(HPAGE_SIZE) - 1;
26236 + MODULES_EXEC_END = .;
26237 +#endif
26238 +
26239 + } :module
26240 +#endif
26241 +
26242 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26243 + /* End of text section */
26244 + BYTE(0)
26245 + _etext = . - __KERNEL_TEXT_OFFSET;
26246 + }
26247 +
26248 +#ifdef CONFIG_X86_32
26249 + . = ALIGN(PAGE_SIZE);
26250 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26251 + . = ALIGN(PAGE_SIZE);
26252 + *(.empty_zero_page)
26253 + *(.initial_pg_fixmap)
26254 + *(.initial_pg_pmd)
26255 + *(.initial_page_table)
26256 + *(.swapper_pg_dir)
26257 + } :rodata
26258 +#endif
26259 +
26260 + . = ALIGN(PAGE_SIZE);
26261 + NOTES :rodata :note
26262 +
26263 + EXCEPTION_TABLE(16) :rodata
26264
26265 #if defined(CONFIG_DEBUG_RODATA)
26266 /* .text should occupy whole number of pages */
26267 @@ -122,16 +176,20 @@ SECTIONS
26268
26269 /* Data */
26270 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26271 +
26272 +#ifdef CONFIG_PAX_KERNEXEC
26273 + . = ALIGN(HPAGE_SIZE);
26274 +#else
26275 + . = ALIGN(PAGE_SIZE);
26276 +#endif
26277 +
26278 /* Start of data section */
26279 _sdata = .;
26280
26281 /* init_task */
26282 INIT_TASK_DATA(THREAD_SIZE)
26283
26284 -#ifdef CONFIG_X86_32
26285 - /* 32 bit has nosave before _edata */
26286 NOSAVE_DATA
26287 -#endif
26288
26289 PAGE_ALIGNED_DATA(PAGE_SIZE)
26290
26291 @@ -172,12 +230,19 @@ SECTIONS
26292 #endif /* CONFIG_X86_64 */
26293
26294 /* Init code and data - will be freed after init */
26295 - . = ALIGN(PAGE_SIZE);
26296 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26297 + BYTE(0)
26298 +
26299 +#ifdef CONFIG_PAX_KERNEXEC
26300 + . = ALIGN(HPAGE_SIZE);
26301 +#else
26302 + . = ALIGN(PAGE_SIZE);
26303 +#endif
26304 +
26305 __init_begin = .; /* paired with __init_end */
26306 - }
26307 + } :init.begin
26308
26309 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26310 +#ifdef CONFIG_SMP
26311 /*
26312 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26313 * output PHDR, so the next output section - .init.text - should
26314 @@ -186,12 +251,27 @@ SECTIONS
26315 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26316 #endif
26317
26318 - INIT_TEXT_SECTION(PAGE_SIZE)
26319 -#ifdef CONFIG_X86_64
26320 - :init
26321 -#endif
26322 + . = ALIGN(PAGE_SIZE);
26323 + init_begin = .;
26324 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26325 + VMLINUX_SYMBOL(_sinittext) = .;
26326 + INIT_TEXT
26327 + VMLINUX_SYMBOL(_einittext) = .;
26328 + . = ALIGN(PAGE_SIZE);
26329 + } :text.init
26330
26331 - INIT_DATA_SECTION(16)
26332 + /*
26333 + * .exit.text is discard at runtime, not link time, to deal with
26334 + * references from .altinstructions and .eh_frame
26335 + */
26336 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26337 + EXIT_TEXT
26338 + . = ALIGN(16);
26339 + } :text.exit
26340 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26341 +
26342 + . = ALIGN(PAGE_SIZE);
26343 + INIT_DATA_SECTION(16) :init
26344
26345 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26346 __x86_cpu_dev_start = .;
26347 @@ -253,19 +333,12 @@ SECTIONS
26348 }
26349
26350 . = ALIGN(8);
26351 - /*
26352 - * .exit.text is discard at runtime, not link time, to deal with
26353 - * references from .altinstructions and .eh_frame
26354 - */
26355 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26356 - EXIT_TEXT
26357 - }
26358
26359 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26360 EXIT_DATA
26361 }
26362
26363 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26364 +#ifndef CONFIG_SMP
26365 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26366 #endif
26367
26368 @@ -284,16 +357,10 @@ SECTIONS
26369 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26370 __smp_locks = .;
26371 *(.smp_locks)
26372 - . = ALIGN(PAGE_SIZE);
26373 __smp_locks_end = .;
26374 + . = ALIGN(PAGE_SIZE);
26375 }
26376
26377 -#ifdef CONFIG_X86_64
26378 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26379 - NOSAVE_DATA
26380 - }
26381 -#endif
26382 -
26383 /* BSS */
26384 . = ALIGN(PAGE_SIZE);
26385 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26386 @@ -309,6 +376,7 @@ SECTIONS
26387 __brk_base = .;
26388 . += 64 * 1024; /* 64k alignment slop space */
26389 *(.brk_reservation) /* areas brk users have reserved */
26390 + . = ALIGN(HPAGE_SIZE);
26391 __brk_limit = .;
26392 }
26393
26394 @@ -335,13 +403,12 @@ SECTIONS
26395 * for the boot processor.
26396 */
26397 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26398 -INIT_PER_CPU(gdt_page);
26399 INIT_PER_CPU(irq_stack_union);
26400
26401 /*
26402 * Build-time check on the image size:
26403 */
26404 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26405 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26406 "kernel image bigger than KERNEL_IMAGE_SIZE");
26407
26408 #ifdef CONFIG_SMP
26409 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26410 index 1f96f93..d5c8f7a 100644
26411 --- a/arch/x86/kernel/vsyscall_64.c
26412 +++ b/arch/x86/kernel/vsyscall_64.c
26413 @@ -56,15 +56,13 @@
26414 DEFINE_VVAR(int, vgetcpu_mode);
26415 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26416
26417 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26418 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26419
26420 static int __init vsyscall_setup(char *str)
26421 {
26422 if (str) {
26423 if (!strcmp("emulate", str))
26424 vsyscall_mode = EMULATE;
26425 - else if (!strcmp("native", str))
26426 - vsyscall_mode = NATIVE;
26427 else if (!strcmp("none", str))
26428 vsyscall_mode = NONE;
26429 else
26430 @@ -323,8 +321,7 @@ do_ret:
26431 return true;
26432
26433 sigsegv:
26434 - force_sig(SIGSEGV, current);
26435 - return true;
26436 + do_group_exit(SIGKILL);
26437 }
26438
26439 /*
26440 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26441 extern char __vvar_page;
26442 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26443
26444 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26445 - vsyscall_mode == NATIVE
26446 - ? PAGE_KERNEL_VSYSCALL
26447 - : PAGE_KERNEL_VVAR);
26448 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26449 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26450 (unsigned long)VSYSCALL_START);
26451
26452 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26453 index b014d94..e775258 100644
26454 --- a/arch/x86/kernel/x8664_ksyms_64.c
26455 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26456 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26457 EXPORT_SYMBOL(copy_user_generic_unrolled);
26458 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26459 EXPORT_SYMBOL(__copy_user_nocache);
26460 -EXPORT_SYMBOL(_copy_from_user);
26461 -EXPORT_SYMBOL(_copy_to_user);
26462
26463 EXPORT_SYMBOL(copy_page);
26464 EXPORT_SYMBOL(clear_page);
26465 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26466 #ifndef CONFIG_PARAVIRT
26467 EXPORT_SYMBOL(native_load_gs_index);
26468 #endif
26469 +
26470 +#ifdef CONFIG_PAX_PER_CPU_PGD
26471 +EXPORT_SYMBOL(cpu_pgd);
26472 +#endif
26473 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26474 index 8ce0072..431a0e7 100644
26475 --- a/arch/x86/kernel/x86_init.c
26476 +++ b/arch/x86/kernel/x86_init.c
26477 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26478 static void default_nmi_init(void) { };
26479 static int default_i8042_detect(void) { return 1; };
26480
26481 -struct x86_platform_ops x86_platform = {
26482 +struct x86_platform_ops x86_platform __read_only = {
26483 .calibrate_tsc = native_calibrate_tsc,
26484 .get_wallclock = mach_get_cmos_time,
26485 .set_wallclock = mach_set_rtc_mmss,
26486 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
26487 EXPORT_SYMBOL_GPL(x86_platform);
26488
26489 #if defined(CONFIG_PCI_MSI)
26490 -struct x86_msi_ops x86_msi = {
26491 +struct x86_msi_ops x86_msi __read_only = {
26492 .setup_msi_irqs = native_setup_msi_irqs,
26493 .compose_msi_msg = native_compose_msi_msg,
26494 .teardown_msi_irq = native_teardown_msi_irq,
26495 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
26496 }
26497 #endif
26498
26499 -struct x86_io_apic_ops x86_io_apic_ops = {
26500 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26501 .init = native_io_apic_init_mappings,
26502 .read = native_io_apic_read,
26503 .write = native_io_apic_write,
26504 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26505 index 422fd82..c3687ca 100644
26506 --- a/arch/x86/kernel/xsave.c
26507 +++ b/arch/x86/kernel/xsave.c
26508 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26509 {
26510 int err;
26511
26512 + buf = (struct xsave_struct __user *)____m(buf);
26513 if (use_xsave())
26514 err = xsave_user(buf);
26515 else if (use_fxsr())
26516 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26517 */
26518 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26519 {
26520 + buf = (void __user *)____m(buf);
26521 if (use_xsave()) {
26522 if ((unsigned long)buf % 64 || fx_only) {
26523 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26524 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26525 index b110fe6..d9c19f2 100644
26526 --- a/arch/x86/kvm/cpuid.c
26527 +++ b/arch/x86/kvm/cpuid.c
26528 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26529 struct kvm_cpuid2 *cpuid,
26530 struct kvm_cpuid_entry2 __user *entries)
26531 {
26532 - int r;
26533 + int r, i;
26534
26535 r = -E2BIG;
26536 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26537 goto out;
26538 r = -EFAULT;
26539 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26540 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26541 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26542 goto out;
26543 + for (i = 0; i < cpuid->nent; ++i) {
26544 + struct kvm_cpuid_entry2 cpuid_entry;
26545 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26546 + goto out;
26547 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26548 + }
26549 vcpu->arch.cpuid_nent = cpuid->nent;
26550 kvm_apic_set_version(vcpu);
26551 kvm_x86_ops->cpuid_update(vcpu);
26552 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26553 struct kvm_cpuid2 *cpuid,
26554 struct kvm_cpuid_entry2 __user *entries)
26555 {
26556 - int r;
26557 + int r, i;
26558
26559 r = -E2BIG;
26560 if (cpuid->nent < vcpu->arch.cpuid_nent)
26561 goto out;
26562 r = -EFAULT;
26563 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26564 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26565 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26566 goto out;
26567 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26568 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26569 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26570 + goto out;
26571 + }
26572 return 0;
26573
26574 out:
26575 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26576 index 5439117..d08f3d4 100644
26577 --- a/arch/x86/kvm/lapic.c
26578 +++ b/arch/x86/kvm/lapic.c
26579 @@ -55,7 +55,7 @@
26580 #define APIC_BUS_CYCLE_NS 1
26581
26582 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26583 -#define apic_debug(fmt, arg...)
26584 +#define apic_debug(fmt, arg...) do {} while (0)
26585
26586 #define APIC_LVT_NUM 6
26587 /* 14 is the version for Xeon and Pentium 8.4.8*/
26588 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26589 index ad75d77..a679d32 100644
26590 --- a/arch/x86/kvm/paging_tmpl.h
26591 +++ b/arch/x86/kvm/paging_tmpl.h
26592 @@ -331,7 +331,7 @@ retry_walk:
26593 if (unlikely(kvm_is_error_hva(host_addr)))
26594 goto error;
26595
26596 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26597 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26598 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26599 goto error;
26600 walker->ptep_user[walker->level - 1] = ptep_user;
26601 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26602 index c0bc803..6837a50 100644
26603 --- a/arch/x86/kvm/svm.c
26604 +++ b/arch/x86/kvm/svm.c
26605 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26606 int cpu = raw_smp_processor_id();
26607
26608 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26609 +
26610 + pax_open_kernel();
26611 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26612 + pax_close_kernel();
26613 +
26614 load_TR_desc();
26615 }
26616
26617 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26618 #endif
26619 #endif
26620
26621 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26622 + __set_fs(current_thread_info()->addr_limit);
26623 +#endif
26624 +
26625 reload_tss(vcpu);
26626
26627 local_irq_disable();
26628 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26629 index 2b2fce1..da76be4 100644
26630 --- a/arch/x86/kvm/vmx.c
26631 +++ b/arch/x86/kvm/vmx.c
26632 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26633 #endif
26634 }
26635
26636 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26637 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26638 {
26639 vmcs_writel(field, vmcs_readl(field) & ~mask);
26640 }
26641
26642 -static void vmcs_set_bits(unsigned long field, u32 mask)
26643 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26644 {
26645 vmcs_writel(field, vmcs_readl(field) | mask);
26646 }
26647 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
26648 struct desc_struct *descs;
26649
26650 descs = (void *)gdt->address;
26651 +
26652 + pax_open_kernel();
26653 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26654 + pax_close_kernel();
26655 +
26656 load_TR_desc();
26657 }
26658
26659 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26660 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26661 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26662
26663 +#ifdef CONFIG_PAX_PER_CPU_PGD
26664 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26665 +#endif
26666 +
26667 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26668 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26669 vmx->loaded_vmcs->cpu = cpu;
26670 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
26671 * reads and returns guest's timestamp counter "register"
26672 * guest_tsc = host_tsc + tsc_offset -- 21.3
26673 */
26674 -static u64 guest_read_tsc(void)
26675 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
26676 {
26677 u64 host_tsc, tsc_offset;
26678
26679 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
26680 if (!cpu_has_vmx_flexpriority())
26681 flexpriority_enabled = 0;
26682
26683 - if (!cpu_has_vmx_tpr_shadow())
26684 - kvm_x86_ops->update_cr8_intercept = NULL;
26685 + if (!cpu_has_vmx_tpr_shadow()) {
26686 + pax_open_kernel();
26687 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26688 + pax_close_kernel();
26689 + }
26690
26691 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26692 kvm_disable_largepages();
26693 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
26694 if (!cpu_has_vmx_apicv())
26695 enable_apicv = 0;
26696
26697 + pax_open_kernel();
26698 if (enable_apicv)
26699 - kvm_x86_ops->update_cr8_intercept = NULL;
26700 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26701 else {
26702 - kvm_x86_ops->hwapic_irr_update = NULL;
26703 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26704 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26705 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26706 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26707 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26708 }
26709 + pax_close_kernel();
26710
26711 if (nested)
26712 nested_vmx_setup_ctls_msrs();
26713 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26714
26715 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26716 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26717 +
26718 +#ifndef CONFIG_PAX_PER_CPU_PGD
26719 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26720 +#endif
26721
26722 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26723 #ifdef CONFIG_X86_64
26724 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26725 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26726 vmx->host_idt_base = dt.address;
26727
26728 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26729 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26730
26731 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26732 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26733 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26734 "jmp 2f \n\t"
26735 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26736 "2: "
26737 +
26738 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26739 + "ljmp %[cs],$3f\n\t"
26740 + "3: "
26741 +#endif
26742 +
26743 /* Save guest registers, load host registers, keep flags */
26744 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26745 "pop %0 \n\t"
26746 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26747 #endif
26748 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26749 [wordsize]"i"(sizeof(ulong))
26750 +
26751 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26752 + ,[cs]"i"(__KERNEL_CS)
26753 +#endif
26754 +
26755 : "cc", "memory"
26756 #ifdef CONFIG_X86_64
26757 , "rax", "rbx", "rdi", "rsi"
26758 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26759 if (debugctlmsr)
26760 update_debugctlmsr(debugctlmsr);
26761
26762 -#ifndef CONFIG_X86_64
26763 +#ifdef CONFIG_X86_32
26764 /*
26765 * The sysexit path does not restore ds/es, so we must set them to
26766 * a reasonable value ourselves.
26767 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26768 * may be executed in interrupt context, which saves and restore segments
26769 * around it, nullifying its effect.
26770 */
26771 - loadsegment(ds, __USER_DS);
26772 - loadsegment(es, __USER_DS);
26773 + loadsegment(ds, __KERNEL_DS);
26774 + loadsegment(es, __KERNEL_DS);
26775 + loadsegment(ss, __KERNEL_DS);
26776 +
26777 +#ifdef CONFIG_PAX_KERNEXEC
26778 + loadsegment(fs, __KERNEL_PERCPU);
26779 +#endif
26780 +
26781 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26782 + __set_fs(current_thread_info()->addr_limit);
26783 +#endif
26784 +
26785 #endif
26786
26787 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26788 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26789 index e5ca72a..83d5177 100644
26790 --- a/arch/x86/kvm/x86.c
26791 +++ b/arch/x86/kvm/x86.c
26792 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26793 {
26794 struct kvm *kvm = vcpu->kvm;
26795 int lm = is_long_mode(vcpu);
26796 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26797 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26798 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26799 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26800 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26801 : kvm->arch.xen_hvm_config.blob_size_32;
26802 u32 page_num = data & ~PAGE_MASK;
26803 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26804 if (n < msr_list.nmsrs)
26805 goto out;
26806 r = -EFAULT;
26807 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26808 + goto out;
26809 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26810 num_msrs_to_save * sizeof(u32)))
26811 goto out;
26812 @@ -5462,7 +5464,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26813 };
26814 #endif
26815
26816 -int kvm_arch_init(void *opaque)
26817 +int kvm_arch_init(const void *opaque)
26818 {
26819 int r;
26820 struct kvm_x86_ops *ops = opaque;
26821 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26822 index bdf8532..f63c587 100644
26823 --- a/arch/x86/lguest/boot.c
26824 +++ b/arch/x86/lguest/boot.c
26825 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26826 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26827 * Launcher to reboot us.
26828 */
26829 -static void lguest_restart(char *reason)
26830 +static __noreturn void lguest_restart(char *reason)
26831 {
26832 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26833 + BUG();
26834 }
26835
26836 /*G:050
26837 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26838 index 00933d5..3a64af9 100644
26839 --- a/arch/x86/lib/atomic64_386_32.S
26840 +++ b/arch/x86/lib/atomic64_386_32.S
26841 @@ -48,6 +48,10 @@ BEGIN(read)
26842 movl (v), %eax
26843 movl 4(v), %edx
26844 RET_ENDP
26845 +BEGIN(read_unchecked)
26846 + movl (v), %eax
26847 + movl 4(v), %edx
26848 +RET_ENDP
26849 #undef v
26850
26851 #define v %esi
26852 @@ -55,6 +59,10 @@ BEGIN(set)
26853 movl %ebx, (v)
26854 movl %ecx, 4(v)
26855 RET_ENDP
26856 +BEGIN(set_unchecked)
26857 + movl %ebx, (v)
26858 + movl %ecx, 4(v)
26859 +RET_ENDP
26860 #undef v
26861
26862 #define v %esi
26863 @@ -70,6 +78,20 @@ RET_ENDP
26864 BEGIN(add)
26865 addl %eax, (v)
26866 adcl %edx, 4(v)
26867 +
26868 +#ifdef CONFIG_PAX_REFCOUNT
26869 + jno 0f
26870 + subl %eax, (v)
26871 + sbbl %edx, 4(v)
26872 + int $4
26873 +0:
26874 + _ASM_EXTABLE(0b, 0b)
26875 +#endif
26876 +
26877 +RET_ENDP
26878 +BEGIN(add_unchecked)
26879 + addl %eax, (v)
26880 + adcl %edx, 4(v)
26881 RET_ENDP
26882 #undef v
26883
26884 @@ -77,6 +99,24 @@ RET_ENDP
26885 BEGIN(add_return)
26886 addl (v), %eax
26887 adcl 4(v), %edx
26888 +
26889 +#ifdef CONFIG_PAX_REFCOUNT
26890 + into
26891 +1234:
26892 + _ASM_EXTABLE(1234b, 2f)
26893 +#endif
26894 +
26895 + movl %eax, (v)
26896 + movl %edx, 4(v)
26897 +
26898 +#ifdef CONFIG_PAX_REFCOUNT
26899 +2:
26900 +#endif
26901 +
26902 +RET_ENDP
26903 +BEGIN(add_return_unchecked)
26904 + addl (v), %eax
26905 + adcl 4(v), %edx
26906 movl %eax, (v)
26907 movl %edx, 4(v)
26908 RET_ENDP
26909 @@ -86,6 +126,20 @@ RET_ENDP
26910 BEGIN(sub)
26911 subl %eax, (v)
26912 sbbl %edx, 4(v)
26913 +
26914 +#ifdef CONFIG_PAX_REFCOUNT
26915 + jno 0f
26916 + addl %eax, (v)
26917 + adcl %edx, 4(v)
26918 + int $4
26919 +0:
26920 + _ASM_EXTABLE(0b, 0b)
26921 +#endif
26922 +
26923 +RET_ENDP
26924 +BEGIN(sub_unchecked)
26925 + subl %eax, (v)
26926 + sbbl %edx, 4(v)
26927 RET_ENDP
26928 #undef v
26929
26930 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26931 sbbl $0, %edx
26932 addl (v), %eax
26933 adcl 4(v), %edx
26934 +
26935 +#ifdef CONFIG_PAX_REFCOUNT
26936 + into
26937 +1234:
26938 + _ASM_EXTABLE(1234b, 2f)
26939 +#endif
26940 +
26941 + movl %eax, (v)
26942 + movl %edx, 4(v)
26943 +
26944 +#ifdef CONFIG_PAX_REFCOUNT
26945 +2:
26946 +#endif
26947 +
26948 +RET_ENDP
26949 +BEGIN(sub_return_unchecked)
26950 + negl %edx
26951 + negl %eax
26952 + sbbl $0, %edx
26953 + addl (v), %eax
26954 + adcl 4(v), %edx
26955 movl %eax, (v)
26956 movl %edx, 4(v)
26957 RET_ENDP
26958 @@ -105,6 +180,20 @@ RET_ENDP
26959 BEGIN(inc)
26960 addl $1, (v)
26961 adcl $0, 4(v)
26962 +
26963 +#ifdef CONFIG_PAX_REFCOUNT
26964 + jno 0f
26965 + subl $1, (v)
26966 + sbbl $0, 4(v)
26967 + int $4
26968 +0:
26969 + _ASM_EXTABLE(0b, 0b)
26970 +#endif
26971 +
26972 +RET_ENDP
26973 +BEGIN(inc_unchecked)
26974 + addl $1, (v)
26975 + adcl $0, 4(v)
26976 RET_ENDP
26977 #undef v
26978
26979 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26980 movl 4(v), %edx
26981 addl $1, %eax
26982 adcl $0, %edx
26983 +
26984 +#ifdef CONFIG_PAX_REFCOUNT
26985 + into
26986 +1234:
26987 + _ASM_EXTABLE(1234b, 2f)
26988 +#endif
26989 +
26990 + movl %eax, (v)
26991 + movl %edx, 4(v)
26992 +
26993 +#ifdef CONFIG_PAX_REFCOUNT
26994 +2:
26995 +#endif
26996 +
26997 +RET_ENDP
26998 +BEGIN(inc_return_unchecked)
26999 + movl (v), %eax
27000 + movl 4(v), %edx
27001 + addl $1, %eax
27002 + adcl $0, %edx
27003 movl %eax, (v)
27004 movl %edx, 4(v)
27005 RET_ENDP
27006 @@ -123,6 +232,20 @@ RET_ENDP
27007 BEGIN(dec)
27008 subl $1, (v)
27009 sbbl $0, 4(v)
27010 +
27011 +#ifdef CONFIG_PAX_REFCOUNT
27012 + jno 0f
27013 + addl $1, (v)
27014 + adcl $0, 4(v)
27015 + int $4
27016 +0:
27017 + _ASM_EXTABLE(0b, 0b)
27018 +#endif
27019 +
27020 +RET_ENDP
27021 +BEGIN(dec_unchecked)
27022 + subl $1, (v)
27023 + sbbl $0, 4(v)
27024 RET_ENDP
27025 #undef v
27026
27027 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27028 movl 4(v), %edx
27029 subl $1, %eax
27030 sbbl $0, %edx
27031 +
27032 +#ifdef CONFIG_PAX_REFCOUNT
27033 + into
27034 +1234:
27035 + _ASM_EXTABLE(1234b, 2f)
27036 +#endif
27037 +
27038 + movl %eax, (v)
27039 + movl %edx, 4(v)
27040 +
27041 +#ifdef CONFIG_PAX_REFCOUNT
27042 +2:
27043 +#endif
27044 +
27045 +RET_ENDP
27046 +BEGIN(dec_return_unchecked)
27047 + movl (v), %eax
27048 + movl 4(v), %edx
27049 + subl $1, %eax
27050 + sbbl $0, %edx
27051 movl %eax, (v)
27052 movl %edx, 4(v)
27053 RET_ENDP
27054 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27055 adcl %edx, %edi
27056 addl (v), %eax
27057 adcl 4(v), %edx
27058 +
27059 +#ifdef CONFIG_PAX_REFCOUNT
27060 + into
27061 +1234:
27062 + _ASM_EXTABLE(1234b, 2f)
27063 +#endif
27064 +
27065 cmpl %eax, %ecx
27066 je 3f
27067 1:
27068 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27069 1:
27070 addl $1, %eax
27071 adcl $0, %edx
27072 +
27073 +#ifdef CONFIG_PAX_REFCOUNT
27074 + into
27075 +1234:
27076 + _ASM_EXTABLE(1234b, 2f)
27077 +#endif
27078 +
27079 movl %eax, (v)
27080 movl %edx, 4(v)
27081 movl $1, %eax
27082 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27083 movl 4(v), %edx
27084 subl $1, %eax
27085 sbbl $0, %edx
27086 +
27087 +#ifdef CONFIG_PAX_REFCOUNT
27088 + into
27089 +1234:
27090 + _ASM_EXTABLE(1234b, 1f)
27091 +#endif
27092 +
27093 js 1f
27094 movl %eax, (v)
27095 movl %edx, 4(v)
27096 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27097 index f5cc9eb..51fa319 100644
27098 --- a/arch/x86/lib/atomic64_cx8_32.S
27099 +++ b/arch/x86/lib/atomic64_cx8_32.S
27100 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27101 CFI_STARTPROC
27102
27103 read64 %ecx
27104 + pax_force_retaddr
27105 ret
27106 CFI_ENDPROC
27107 ENDPROC(atomic64_read_cx8)
27108
27109 +ENTRY(atomic64_read_unchecked_cx8)
27110 + CFI_STARTPROC
27111 +
27112 + read64 %ecx
27113 + pax_force_retaddr
27114 + ret
27115 + CFI_ENDPROC
27116 +ENDPROC(atomic64_read_unchecked_cx8)
27117 +
27118 ENTRY(atomic64_set_cx8)
27119 CFI_STARTPROC
27120
27121 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27122 cmpxchg8b (%esi)
27123 jne 1b
27124
27125 + pax_force_retaddr
27126 ret
27127 CFI_ENDPROC
27128 ENDPROC(atomic64_set_cx8)
27129
27130 +ENTRY(atomic64_set_unchecked_cx8)
27131 + CFI_STARTPROC
27132 +
27133 +1:
27134 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27135 + * are atomic on 586 and newer */
27136 + cmpxchg8b (%esi)
27137 + jne 1b
27138 +
27139 + pax_force_retaddr
27140 + ret
27141 + CFI_ENDPROC
27142 +ENDPROC(atomic64_set_unchecked_cx8)
27143 +
27144 ENTRY(atomic64_xchg_cx8)
27145 CFI_STARTPROC
27146
27147 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27148 cmpxchg8b (%esi)
27149 jne 1b
27150
27151 + pax_force_retaddr
27152 ret
27153 CFI_ENDPROC
27154 ENDPROC(atomic64_xchg_cx8)
27155
27156 -.macro addsub_return func ins insc
27157 -ENTRY(atomic64_\func\()_return_cx8)
27158 +.macro addsub_return func ins insc unchecked=""
27159 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27160 CFI_STARTPROC
27161 SAVE ebp
27162 SAVE ebx
27163 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27164 movl %edx, %ecx
27165 \ins\()l %esi, %ebx
27166 \insc\()l %edi, %ecx
27167 +
27168 +.ifb \unchecked
27169 +#ifdef CONFIG_PAX_REFCOUNT
27170 + into
27171 +2:
27172 + _ASM_EXTABLE(2b, 3f)
27173 +#endif
27174 +.endif
27175 +
27176 LOCK_PREFIX
27177 cmpxchg8b (%ebp)
27178 jne 1b
27179 -
27180 -10:
27181 movl %ebx, %eax
27182 movl %ecx, %edx
27183 +
27184 +.ifb \unchecked
27185 +#ifdef CONFIG_PAX_REFCOUNT
27186 +3:
27187 +#endif
27188 +.endif
27189 +
27190 RESTORE edi
27191 RESTORE esi
27192 RESTORE ebx
27193 RESTORE ebp
27194 + pax_force_retaddr
27195 ret
27196 CFI_ENDPROC
27197 -ENDPROC(atomic64_\func\()_return_cx8)
27198 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27199 .endm
27200
27201 addsub_return add add adc
27202 addsub_return sub sub sbb
27203 +addsub_return add add adc _unchecked
27204 +addsub_return sub sub sbb _unchecked
27205
27206 -.macro incdec_return func ins insc
27207 -ENTRY(atomic64_\func\()_return_cx8)
27208 +.macro incdec_return func ins insc unchecked=""
27209 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27210 CFI_STARTPROC
27211 SAVE ebx
27212
27213 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27214 movl %edx, %ecx
27215 \ins\()l $1, %ebx
27216 \insc\()l $0, %ecx
27217 +
27218 +.ifb \unchecked
27219 +#ifdef CONFIG_PAX_REFCOUNT
27220 + into
27221 +2:
27222 + _ASM_EXTABLE(2b, 3f)
27223 +#endif
27224 +.endif
27225 +
27226 LOCK_PREFIX
27227 cmpxchg8b (%esi)
27228 jne 1b
27229
27230 -10:
27231 movl %ebx, %eax
27232 movl %ecx, %edx
27233 +
27234 +.ifb \unchecked
27235 +#ifdef CONFIG_PAX_REFCOUNT
27236 +3:
27237 +#endif
27238 +.endif
27239 +
27240 RESTORE ebx
27241 + pax_force_retaddr
27242 ret
27243 CFI_ENDPROC
27244 -ENDPROC(atomic64_\func\()_return_cx8)
27245 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27246 .endm
27247
27248 incdec_return inc add adc
27249 incdec_return dec sub sbb
27250 +incdec_return inc add adc _unchecked
27251 +incdec_return dec sub sbb _unchecked
27252
27253 ENTRY(atomic64_dec_if_positive_cx8)
27254 CFI_STARTPROC
27255 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27256 movl %edx, %ecx
27257 subl $1, %ebx
27258 sbb $0, %ecx
27259 +
27260 +#ifdef CONFIG_PAX_REFCOUNT
27261 + into
27262 +1234:
27263 + _ASM_EXTABLE(1234b, 2f)
27264 +#endif
27265 +
27266 js 2f
27267 LOCK_PREFIX
27268 cmpxchg8b (%esi)
27269 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27270 movl %ebx, %eax
27271 movl %ecx, %edx
27272 RESTORE ebx
27273 + pax_force_retaddr
27274 ret
27275 CFI_ENDPROC
27276 ENDPROC(atomic64_dec_if_positive_cx8)
27277 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27278 movl %edx, %ecx
27279 addl %ebp, %ebx
27280 adcl %edi, %ecx
27281 +
27282 +#ifdef CONFIG_PAX_REFCOUNT
27283 + into
27284 +1234:
27285 + _ASM_EXTABLE(1234b, 3f)
27286 +#endif
27287 +
27288 LOCK_PREFIX
27289 cmpxchg8b (%esi)
27290 jne 1b
27291 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27292 CFI_ADJUST_CFA_OFFSET -8
27293 RESTORE ebx
27294 RESTORE ebp
27295 + pax_force_retaddr
27296 ret
27297 4:
27298 cmpl %edx, 4(%esp)
27299 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27300 xorl %ecx, %ecx
27301 addl $1, %ebx
27302 adcl %edx, %ecx
27303 +
27304 +#ifdef CONFIG_PAX_REFCOUNT
27305 + into
27306 +1234:
27307 + _ASM_EXTABLE(1234b, 3f)
27308 +#endif
27309 +
27310 LOCK_PREFIX
27311 cmpxchg8b (%esi)
27312 jne 1b
27313 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27314 movl $1, %eax
27315 3:
27316 RESTORE ebx
27317 + pax_force_retaddr
27318 ret
27319 CFI_ENDPROC
27320 ENDPROC(atomic64_inc_not_zero_cx8)
27321 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27322 index e78b8ee..7e173a8 100644
27323 --- a/arch/x86/lib/checksum_32.S
27324 +++ b/arch/x86/lib/checksum_32.S
27325 @@ -29,7 +29,8 @@
27326 #include <asm/dwarf2.h>
27327 #include <asm/errno.h>
27328 #include <asm/asm.h>
27329 -
27330 +#include <asm/segment.h>
27331 +
27332 /*
27333 * computes a partial checksum, e.g. for TCP/UDP fragments
27334 */
27335 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27336
27337 #define ARGBASE 16
27338 #define FP 12
27339 -
27340 -ENTRY(csum_partial_copy_generic)
27341 +
27342 +ENTRY(csum_partial_copy_generic_to_user)
27343 CFI_STARTPROC
27344 +
27345 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27346 + pushl_cfi %gs
27347 + popl_cfi %es
27348 + jmp csum_partial_copy_generic
27349 +#endif
27350 +
27351 +ENTRY(csum_partial_copy_generic_from_user)
27352 +
27353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27354 + pushl_cfi %gs
27355 + popl_cfi %ds
27356 +#endif
27357 +
27358 +ENTRY(csum_partial_copy_generic)
27359 subl $4,%esp
27360 CFI_ADJUST_CFA_OFFSET 4
27361 pushl_cfi %edi
27362 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27363 jmp 4f
27364 SRC(1: movw (%esi), %bx )
27365 addl $2, %esi
27366 -DST( movw %bx, (%edi) )
27367 +DST( movw %bx, %es:(%edi) )
27368 addl $2, %edi
27369 addw %bx, %ax
27370 adcl $0, %eax
27371 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27372 SRC(1: movl (%esi), %ebx )
27373 SRC( movl 4(%esi), %edx )
27374 adcl %ebx, %eax
27375 -DST( movl %ebx, (%edi) )
27376 +DST( movl %ebx, %es:(%edi) )
27377 adcl %edx, %eax
27378 -DST( movl %edx, 4(%edi) )
27379 +DST( movl %edx, %es:4(%edi) )
27380
27381 SRC( movl 8(%esi), %ebx )
27382 SRC( movl 12(%esi), %edx )
27383 adcl %ebx, %eax
27384 -DST( movl %ebx, 8(%edi) )
27385 +DST( movl %ebx, %es:8(%edi) )
27386 adcl %edx, %eax
27387 -DST( movl %edx, 12(%edi) )
27388 +DST( movl %edx, %es:12(%edi) )
27389
27390 SRC( movl 16(%esi), %ebx )
27391 SRC( movl 20(%esi), %edx )
27392 adcl %ebx, %eax
27393 -DST( movl %ebx, 16(%edi) )
27394 +DST( movl %ebx, %es:16(%edi) )
27395 adcl %edx, %eax
27396 -DST( movl %edx, 20(%edi) )
27397 +DST( movl %edx, %es:20(%edi) )
27398
27399 SRC( movl 24(%esi), %ebx )
27400 SRC( movl 28(%esi), %edx )
27401 adcl %ebx, %eax
27402 -DST( movl %ebx, 24(%edi) )
27403 +DST( movl %ebx, %es:24(%edi) )
27404 adcl %edx, %eax
27405 -DST( movl %edx, 28(%edi) )
27406 +DST( movl %edx, %es:28(%edi) )
27407
27408 lea 32(%esi), %esi
27409 lea 32(%edi), %edi
27410 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27411 shrl $2, %edx # This clears CF
27412 SRC(3: movl (%esi), %ebx )
27413 adcl %ebx, %eax
27414 -DST( movl %ebx, (%edi) )
27415 +DST( movl %ebx, %es:(%edi) )
27416 lea 4(%esi), %esi
27417 lea 4(%edi), %edi
27418 dec %edx
27419 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27420 jb 5f
27421 SRC( movw (%esi), %cx )
27422 leal 2(%esi), %esi
27423 -DST( movw %cx, (%edi) )
27424 +DST( movw %cx, %es:(%edi) )
27425 leal 2(%edi), %edi
27426 je 6f
27427 shll $16,%ecx
27428 SRC(5: movb (%esi), %cl )
27429 -DST( movb %cl, (%edi) )
27430 +DST( movb %cl, %es:(%edi) )
27431 6: addl %ecx, %eax
27432 adcl $0, %eax
27433 7:
27434 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27435
27436 6001:
27437 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27438 - movl $-EFAULT, (%ebx)
27439 + movl $-EFAULT, %ss:(%ebx)
27440
27441 # zero the complete destination - computing the rest
27442 # is too much work
27443 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27444
27445 6002:
27446 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27447 - movl $-EFAULT,(%ebx)
27448 + movl $-EFAULT,%ss:(%ebx)
27449 jmp 5000b
27450
27451 .previous
27452
27453 + pushl_cfi %ss
27454 + popl_cfi %ds
27455 + pushl_cfi %ss
27456 + popl_cfi %es
27457 popl_cfi %ebx
27458 CFI_RESTORE ebx
27459 popl_cfi %esi
27460 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27461 popl_cfi %ecx # equivalent to addl $4,%esp
27462 ret
27463 CFI_ENDPROC
27464 -ENDPROC(csum_partial_copy_generic)
27465 +ENDPROC(csum_partial_copy_generic_to_user)
27466
27467 #else
27468
27469 /* Version for PentiumII/PPro */
27470
27471 #define ROUND1(x) \
27472 + nop; nop; nop; \
27473 SRC(movl x(%esi), %ebx ) ; \
27474 addl %ebx, %eax ; \
27475 - DST(movl %ebx, x(%edi) ) ;
27476 + DST(movl %ebx, %es:x(%edi)) ;
27477
27478 #define ROUND(x) \
27479 + nop; nop; nop; \
27480 SRC(movl x(%esi), %ebx ) ; \
27481 adcl %ebx, %eax ; \
27482 - DST(movl %ebx, x(%edi) ) ;
27483 + DST(movl %ebx, %es:x(%edi)) ;
27484
27485 #define ARGBASE 12
27486 -
27487 -ENTRY(csum_partial_copy_generic)
27488 +
27489 +ENTRY(csum_partial_copy_generic_to_user)
27490 CFI_STARTPROC
27491 +
27492 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27493 + pushl_cfi %gs
27494 + popl_cfi %es
27495 + jmp csum_partial_copy_generic
27496 +#endif
27497 +
27498 +ENTRY(csum_partial_copy_generic_from_user)
27499 +
27500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27501 + pushl_cfi %gs
27502 + popl_cfi %ds
27503 +#endif
27504 +
27505 +ENTRY(csum_partial_copy_generic)
27506 pushl_cfi %ebx
27507 CFI_REL_OFFSET ebx, 0
27508 pushl_cfi %edi
27509 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27510 subl %ebx, %edi
27511 lea -1(%esi),%edx
27512 andl $-32,%edx
27513 - lea 3f(%ebx,%ebx), %ebx
27514 + lea 3f(%ebx,%ebx,2), %ebx
27515 testl %esi, %esi
27516 jmp *%ebx
27517 1: addl $64,%esi
27518 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27519 jb 5f
27520 SRC( movw (%esi), %dx )
27521 leal 2(%esi), %esi
27522 -DST( movw %dx, (%edi) )
27523 +DST( movw %dx, %es:(%edi) )
27524 leal 2(%edi), %edi
27525 je 6f
27526 shll $16,%edx
27527 5:
27528 SRC( movb (%esi), %dl )
27529 -DST( movb %dl, (%edi) )
27530 +DST( movb %dl, %es:(%edi) )
27531 6: addl %edx, %eax
27532 adcl $0, %eax
27533 7:
27534 .section .fixup, "ax"
27535 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27536 - movl $-EFAULT, (%ebx)
27537 + movl $-EFAULT, %ss:(%ebx)
27538 # zero the complete destination (computing the rest is too much work)
27539 movl ARGBASE+8(%esp),%edi # dst
27540 movl ARGBASE+12(%esp),%ecx # len
27541 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27542 rep; stosb
27543 jmp 7b
27544 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27545 - movl $-EFAULT, (%ebx)
27546 + movl $-EFAULT, %ss:(%ebx)
27547 jmp 7b
27548 .previous
27549
27550 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27551 + pushl_cfi %ss
27552 + popl_cfi %ds
27553 + pushl_cfi %ss
27554 + popl_cfi %es
27555 +#endif
27556 +
27557 popl_cfi %esi
27558 CFI_RESTORE esi
27559 popl_cfi %edi
27560 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27561 CFI_RESTORE ebx
27562 ret
27563 CFI_ENDPROC
27564 -ENDPROC(csum_partial_copy_generic)
27565 +ENDPROC(csum_partial_copy_generic_to_user)
27566
27567 #undef ROUND
27568 #undef ROUND1
27569 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27570 index f2145cf..cea889d 100644
27571 --- a/arch/x86/lib/clear_page_64.S
27572 +++ b/arch/x86/lib/clear_page_64.S
27573 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27574 movl $4096/8,%ecx
27575 xorl %eax,%eax
27576 rep stosq
27577 + pax_force_retaddr
27578 ret
27579 CFI_ENDPROC
27580 ENDPROC(clear_page_c)
27581 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27582 movl $4096,%ecx
27583 xorl %eax,%eax
27584 rep stosb
27585 + pax_force_retaddr
27586 ret
27587 CFI_ENDPROC
27588 ENDPROC(clear_page_c_e)
27589 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27590 leaq 64(%rdi),%rdi
27591 jnz .Lloop
27592 nop
27593 + pax_force_retaddr
27594 ret
27595 CFI_ENDPROC
27596 .Lclear_page_end:
27597 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27598
27599 #include <asm/cpufeature.h>
27600
27601 - .section .altinstr_replacement,"ax"
27602 + .section .altinstr_replacement,"a"
27603 1: .byte 0xeb /* jmp <disp8> */
27604 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27605 2: .byte 0xeb /* jmp <disp8> */
27606 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27607 index 1e572c5..2a162cd 100644
27608 --- a/arch/x86/lib/cmpxchg16b_emu.S
27609 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27610 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27611
27612 popf
27613 mov $1, %al
27614 + pax_force_retaddr
27615 ret
27616
27617 not_same:
27618 popf
27619 xor %al,%al
27620 + pax_force_retaddr
27621 ret
27622
27623 CFI_ENDPROC
27624 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27625 index 176cca6..1166c50 100644
27626 --- a/arch/x86/lib/copy_page_64.S
27627 +++ b/arch/x86/lib/copy_page_64.S
27628 @@ -9,6 +9,7 @@ copy_page_rep:
27629 CFI_STARTPROC
27630 movl $4096/8, %ecx
27631 rep movsq
27632 + pax_force_retaddr
27633 ret
27634 CFI_ENDPROC
27635 ENDPROC(copy_page_rep)
27636 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27637
27638 ENTRY(copy_page)
27639 CFI_STARTPROC
27640 - subq $2*8, %rsp
27641 - CFI_ADJUST_CFA_OFFSET 2*8
27642 + subq $3*8, %rsp
27643 + CFI_ADJUST_CFA_OFFSET 3*8
27644 movq %rbx, (%rsp)
27645 CFI_REL_OFFSET rbx, 0
27646 movq %r12, 1*8(%rsp)
27647 CFI_REL_OFFSET r12, 1*8
27648 + movq %r13, 2*8(%rsp)
27649 + CFI_REL_OFFSET r13, 2*8
27650
27651 movl $(4096/64)-5, %ecx
27652 .p2align 4
27653 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27654 movq 0x8*2(%rsi), %rdx
27655 movq 0x8*3(%rsi), %r8
27656 movq 0x8*4(%rsi), %r9
27657 - movq 0x8*5(%rsi), %r10
27658 + movq 0x8*5(%rsi), %r13
27659 movq 0x8*6(%rsi), %r11
27660 movq 0x8*7(%rsi), %r12
27661
27662 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27663 movq %rdx, 0x8*2(%rdi)
27664 movq %r8, 0x8*3(%rdi)
27665 movq %r9, 0x8*4(%rdi)
27666 - movq %r10, 0x8*5(%rdi)
27667 + movq %r13, 0x8*5(%rdi)
27668 movq %r11, 0x8*6(%rdi)
27669 movq %r12, 0x8*7(%rdi)
27670
27671 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27672 movq 0x8*2(%rsi), %rdx
27673 movq 0x8*3(%rsi), %r8
27674 movq 0x8*4(%rsi), %r9
27675 - movq 0x8*5(%rsi), %r10
27676 + movq 0x8*5(%rsi), %r13
27677 movq 0x8*6(%rsi), %r11
27678 movq 0x8*7(%rsi), %r12
27679
27680 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27681 movq %rdx, 0x8*2(%rdi)
27682 movq %r8, 0x8*3(%rdi)
27683 movq %r9, 0x8*4(%rdi)
27684 - movq %r10, 0x8*5(%rdi)
27685 + movq %r13, 0x8*5(%rdi)
27686 movq %r11, 0x8*6(%rdi)
27687 movq %r12, 0x8*7(%rdi)
27688
27689 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27690 CFI_RESTORE rbx
27691 movq 1*8(%rsp), %r12
27692 CFI_RESTORE r12
27693 - addq $2*8, %rsp
27694 - CFI_ADJUST_CFA_OFFSET -2*8
27695 + movq 2*8(%rsp), %r13
27696 + CFI_RESTORE r13
27697 + addq $3*8, %rsp
27698 + CFI_ADJUST_CFA_OFFSET -3*8
27699 + pax_force_retaddr
27700 ret
27701 .Lcopy_page_end:
27702 CFI_ENDPROC
27703 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27704
27705 #include <asm/cpufeature.h>
27706
27707 - .section .altinstr_replacement,"ax"
27708 + .section .altinstr_replacement,"a"
27709 1: .byte 0xeb /* jmp <disp8> */
27710 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27711 2:
27712 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27713 index a30ca15..6b3f4e1 100644
27714 --- a/arch/x86/lib/copy_user_64.S
27715 +++ b/arch/x86/lib/copy_user_64.S
27716 @@ -18,31 +18,7 @@
27717 #include <asm/alternative-asm.h>
27718 #include <asm/asm.h>
27719 #include <asm/smap.h>
27720 -
27721 -/*
27722 - * By placing feature2 after feature1 in altinstructions section, we logically
27723 - * implement:
27724 - * If CPU has feature2, jmp to alt2 is used
27725 - * else if CPU has feature1, jmp to alt1 is used
27726 - * else jmp to orig is used.
27727 - */
27728 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27729 -0:
27730 - .byte 0xe9 /* 32bit jump */
27731 - .long \orig-1f /* by default jump to orig */
27732 -1:
27733 - .section .altinstr_replacement,"ax"
27734 -2: .byte 0xe9 /* near jump with 32bit immediate */
27735 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27736 -3: .byte 0xe9 /* near jump with 32bit immediate */
27737 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27738 - .previous
27739 -
27740 - .section .altinstructions,"a"
27741 - altinstruction_entry 0b,2b,\feature1,5,5
27742 - altinstruction_entry 0b,3b,\feature2,5,5
27743 - .previous
27744 - .endm
27745 +#include <asm/pgtable.h>
27746
27747 .macro ALIGN_DESTINATION
27748 #ifdef FIX_ALIGNMENT
27749 @@ -70,52 +46,6 @@
27750 #endif
27751 .endm
27752
27753 -/* Standard copy_to_user with segment limit checking */
27754 -ENTRY(_copy_to_user)
27755 - CFI_STARTPROC
27756 - GET_THREAD_INFO(%rax)
27757 - movq %rdi,%rcx
27758 - addq %rdx,%rcx
27759 - jc bad_to_user
27760 - cmpq TI_addr_limit(%rax),%rcx
27761 - ja bad_to_user
27762 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27763 - copy_user_generic_unrolled,copy_user_generic_string, \
27764 - copy_user_enhanced_fast_string
27765 - CFI_ENDPROC
27766 -ENDPROC(_copy_to_user)
27767 -
27768 -/* Standard copy_from_user with segment limit checking */
27769 -ENTRY(_copy_from_user)
27770 - CFI_STARTPROC
27771 - GET_THREAD_INFO(%rax)
27772 - movq %rsi,%rcx
27773 - addq %rdx,%rcx
27774 - jc bad_from_user
27775 - cmpq TI_addr_limit(%rax),%rcx
27776 - ja bad_from_user
27777 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27778 - copy_user_generic_unrolled,copy_user_generic_string, \
27779 - copy_user_enhanced_fast_string
27780 - CFI_ENDPROC
27781 -ENDPROC(_copy_from_user)
27782 -
27783 - .section .fixup,"ax"
27784 - /* must zero dest */
27785 -ENTRY(bad_from_user)
27786 -bad_from_user:
27787 - CFI_STARTPROC
27788 - movl %edx,%ecx
27789 - xorl %eax,%eax
27790 - rep
27791 - stosb
27792 -bad_to_user:
27793 - movl %edx,%eax
27794 - ret
27795 - CFI_ENDPROC
27796 -ENDPROC(bad_from_user)
27797 - .previous
27798 -
27799 /*
27800 * copy_user_generic_unrolled - memory copy with exception handling.
27801 * This version is for CPUs like P4 that don't have efficient micro
27802 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27803 */
27804 ENTRY(copy_user_generic_unrolled)
27805 CFI_STARTPROC
27806 + ASM_PAX_OPEN_USERLAND
27807 ASM_STAC
27808 cmpl $8,%edx
27809 jb 20f /* less then 8 bytes, go to byte copy loop */
27810 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27811 jz 17f
27812 1: movq (%rsi),%r8
27813 2: movq 1*8(%rsi),%r9
27814 -3: movq 2*8(%rsi),%r10
27815 +3: movq 2*8(%rsi),%rax
27816 4: movq 3*8(%rsi),%r11
27817 5: movq %r8,(%rdi)
27818 6: movq %r9,1*8(%rdi)
27819 -7: movq %r10,2*8(%rdi)
27820 +7: movq %rax,2*8(%rdi)
27821 8: movq %r11,3*8(%rdi)
27822 9: movq 4*8(%rsi),%r8
27823 10: movq 5*8(%rsi),%r9
27824 -11: movq 6*8(%rsi),%r10
27825 +11: movq 6*8(%rsi),%rax
27826 12: movq 7*8(%rsi),%r11
27827 13: movq %r8,4*8(%rdi)
27828 14: movq %r9,5*8(%rdi)
27829 -15: movq %r10,6*8(%rdi)
27830 +15: movq %rax,6*8(%rdi)
27831 16: movq %r11,7*8(%rdi)
27832 leaq 64(%rsi),%rsi
27833 leaq 64(%rdi),%rdi
27834 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27835 jnz 21b
27836 23: xor %eax,%eax
27837 ASM_CLAC
27838 + ASM_PAX_CLOSE_USERLAND
27839 + pax_force_retaddr
27840 ret
27841
27842 .section .fixup,"ax"
27843 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27844 */
27845 ENTRY(copy_user_generic_string)
27846 CFI_STARTPROC
27847 + ASM_PAX_OPEN_USERLAND
27848 ASM_STAC
27849 andl %edx,%edx
27850 jz 4f
27851 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27852 movsb
27853 4: xorl %eax,%eax
27854 ASM_CLAC
27855 + ASM_PAX_CLOSE_USERLAND
27856 + pax_force_retaddr
27857 ret
27858
27859 .section .fixup,"ax"
27860 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27861 */
27862 ENTRY(copy_user_enhanced_fast_string)
27863 CFI_STARTPROC
27864 + ASM_PAX_OPEN_USERLAND
27865 ASM_STAC
27866 andl %edx,%edx
27867 jz 2f
27868 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27869 movsb
27870 2: xorl %eax,%eax
27871 ASM_CLAC
27872 + ASM_PAX_CLOSE_USERLAND
27873 + pax_force_retaddr
27874 ret
27875
27876 .section .fixup,"ax"
27877 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27878 index 6a4f43c..55d26f2 100644
27879 --- a/arch/x86/lib/copy_user_nocache_64.S
27880 +++ b/arch/x86/lib/copy_user_nocache_64.S
27881 @@ -8,6 +8,7 @@
27882
27883 #include <linux/linkage.h>
27884 #include <asm/dwarf2.h>
27885 +#include <asm/alternative-asm.h>
27886
27887 #define FIX_ALIGNMENT 1
27888
27889 @@ -16,6 +17,7 @@
27890 #include <asm/thread_info.h>
27891 #include <asm/asm.h>
27892 #include <asm/smap.h>
27893 +#include <asm/pgtable.h>
27894
27895 .macro ALIGN_DESTINATION
27896 #ifdef FIX_ALIGNMENT
27897 @@ -49,6 +51,16 @@
27898 */
27899 ENTRY(__copy_user_nocache)
27900 CFI_STARTPROC
27901 +
27902 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27903 + mov pax_user_shadow_base,%rcx
27904 + cmp %rcx,%rsi
27905 + jae 1f
27906 + add %rcx,%rsi
27907 +1:
27908 +#endif
27909 +
27910 + ASM_PAX_OPEN_USERLAND
27911 ASM_STAC
27912 cmpl $8,%edx
27913 jb 20f /* less then 8 bytes, go to byte copy loop */
27914 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27915 jz 17f
27916 1: movq (%rsi),%r8
27917 2: movq 1*8(%rsi),%r9
27918 -3: movq 2*8(%rsi),%r10
27919 +3: movq 2*8(%rsi),%rax
27920 4: movq 3*8(%rsi),%r11
27921 5: movnti %r8,(%rdi)
27922 6: movnti %r9,1*8(%rdi)
27923 -7: movnti %r10,2*8(%rdi)
27924 +7: movnti %rax,2*8(%rdi)
27925 8: movnti %r11,3*8(%rdi)
27926 9: movq 4*8(%rsi),%r8
27927 10: movq 5*8(%rsi),%r9
27928 -11: movq 6*8(%rsi),%r10
27929 +11: movq 6*8(%rsi),%rax
27930 12: movq 7*8(%rsi),%r11
27931 13: movnti %r8,4*8(%rdi)
27932 14: movnti %r9,5*8(%rdi)
27933 -15: movnti %r10,6*8(%rdi)
27934 +15: movnti %rax,6*8(%rdi)
27935 16: movnti %r11,7*8(%rdi)
27936 leaq 64(%rsi),%rsi
27937 leaq 64(%rdi),%rdi
27938 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27939 jnz 21b
27940 23: xorl %eax,%eax
27941 ASM_CLAC
27942 + ASM_PAX_CLOSE_USERLAND
27943 sfence
27944 + pax_force_retaddr
27945 ret
27946
27947 .section .fixup,"ax"
27948 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27949 index 2419d5f..953ee51 100644
27950 --- a/arch/x86/lib/csum-copy_64.S
27951 +++ b/arch/x86/lib/csum-copy_64.S
27952 @@ -9,6 +9,7 @@
27953 #include <asm/dwarf2.h>
27954 #include <asm/errno.h>
27955 #include <asm/asm.h>
27956 +#include <asm/alternative-asm.h>
27957
27958 /*
27959 * Checksum copy with exception handling.
27960 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27961 CFI_RESTORE rbp
27962 addq $7*8, %rsp
27963 CFI_ADJUST_CFA_OFFSET -7*8
27964 + pax_force_retaddr 0, 1
27965 ret
27966 CFI_RESTORE_STATE
27967
27968 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27969 index 7609e0e..b449b98 100644
27970 --- a/arch/x86/lib/csum-wrappers_64.c
27971 +++ b/arch/x86/lib/csum-wrappers_64.c
27972 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27973 len -= 2;
27974 }
27975 }
27976 + pax_open_userland();
27977 stac();
27978 - isum = csum_partial_copy_generic((__force const void *)src,
27979 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27980 dst, len, isum, errp, NULL);
27981 clac();
27982 + pax_close_userland();
27983 if (unlikely(*errp))
27984 goto out_err;
27985
27986 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27987 }
27988
27989 *errp = 0;
27990 + pax_open_userland();
27991 stac();
27992 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27993 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27994 len, isum, NULL, errp);
27995 clac();
27996 + pax_close_userland();
27997 return ret;
27998 }
27999 EXPORT_SYMBOL(csum_partial_copy_to_user);
28000 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28001 index a451235..1daa956 100644
28002 --- a/arch/x86/lib/getuser.S
28003 +++ b/arch/x86/lib/getuser.S
28004 @@ -33,17 +33,40 @@
28005 #include <asm/thread_info.h>
28006 #include <asm/asm.h>
28007 #include <asm/smap.h>
28008 +#include <asm/segment.h>
28009 +#include <asm/pgtable.h>
28010 +#include <asm/alternative-asm.h>
28011 +
28012 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28013 +#define __copyuser_seg gs;
28014 +#else
28015 +#define __copyuser_seg
28016 +#endif
28017
28018 .text
28019 ENTRY(__get_user_1)
28020 CFI_STARTPROC
28021 +
28022 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28023 GET_THREAD_INFO(%_ASM_DX)
28024 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28025 jae bad_get_user
28026 ASM_STAC
28027 -1: movzbl (%_ASM_AX),%edx
28028 +
28029 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28030 + mov pax_user_shadow_base,%_ASM_DX
28031 + cmp %_ASM_DX,%_ASM_AX
28032 + jae 1234f
28033 + add %_ASM_DX,%_ASM_AX
28034 +1234:
28035 +#endif
28036 +
28037 +#endif
28038 +
28039 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28040 xor %eax,%eax
28041 ASM_CLAC
28042 + pax_force_retaddr
28043 ret
28044 CFI_ENDPROC
28045 ENDPROC(__get_user_1)
28046 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28047 ENTRY(__get_user_2)
28048 CFI_STARTPROC
28049 add $1,%_ASM_AX
28050 +
28051 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28052 jc bad_get_user
28053 GET_THREAD_INFO(%_ASM_DX)
28054 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28055 jae bad_get_user
28056 ASM_STAC
28057 -2: movzwl -1(%_ASM_AX),%edx
28058 +
28059 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28060 + mov pax_user_shadow_base,%_ASM_DX
28061 + cmp %_ASM_DX,%_ASM_AX
28062 + jae 1234f
28063 + add %_ASM_DX,%_ASM_AX
28064 +1234:
28065 +#endif
28066 +
28067 +#endif
28068 +
28069 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28070 xor %eax,%eax
28071 ASM_CLAC
28072 + pax_force_retaddr
28073 ret
28074 CFI_ENDPROC
28075 ENDPROC(__get_user_2)
28076 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28077 ENTRY(__get_user_4)
28078 CFI_STARTPROC
28079 add $3,%_ASM_AX
28080 +
28081 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28082 jc bad_get_user
28083 GET_THREAD_INFO(%_ASM_DX)
28084 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28085 jae bad_get_user
28086 ASM_STAC
28087 -3: movl -3(%_ASM_AX),%edx
28088 +
28089 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28090 + mov pax_user_shadow_base,%_ASM_DX
28091 + cmp %_ASM_DX,%_ASM_AX
28092 + jae 1234f
28093 + add %_ASM_DX,%_ASM_AX
28094 +1234:
28095 +#endif
28096 +
28097 +#endif
28098 +
28099 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28100 xor %eax,%eax
28101 ASM_CLAC
28102 + pax_force_retaddr
28103 ret
28104 CFI_ENDPROC
28105 ENDPROC(__get_user_4)
28106 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28107 GET_THREAD_INFO(%_ASM_DX)
28108 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28109 jae bad_get_user
28110 +
28111 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28112 + mov pax_user_shadow_base,%_ASM_DX
28113 + cmp %_ASM_DX,%_ASM_AX
28114 + jae 1234f
28115 + add %_ASM_DX,%_ASM_AX
28116 +1234:
28117 +#endif
28118 +
28119 ASM_STAC
28120 4: movq -7(%_ASM_AX),%rdx
28121 xor %eax,%eax
28122 ASM_CLAC
28123 + pax_force_retaddr
28124 ret
28125 #else
28126 add $7,%_ASM_AX
28127 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28128 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28129 jae bad_get_user_8
28130 ASM_STAC
28131 -4: movl -7(%_ASM_AX),%edx
28132 -5: movl -3(%_ASM_AX),%ecx
28133 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28134 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28135 xor %eax,%eax
28136 ASM_CLAC
28137 + pax_force_retaddr
28138 ret
28139 #endif
28140 CFI_ENDPROC
28141 @@ -113,6 +175,7 @@ bad_get_user:
28142 xor %edx,%edx
28143 mov $(-EFAULT),%_ASM_AX
28144 ASM_CLAC
28145 + pax_force_retaddr
28146 ret
28147 CFI_ENDPROC
28148 END(bad_get_user)
28149 @@ -124,6 +187,7 @@ bad_get_user_8:
28150 xor %ecx,%ecx
28151 mov $(-EFAULT),%_ASM_AX
28152 ASM_CLAC
28153 + pax_force_retaddr
28154 ret
28155 CFI_ENDPROC
28156 END(bad_get_user_8)
28157 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28158 index 54fcffe..7be149e 100644
28159 --- a/arch/x86/lib/insn.c
28160 +++ b/arch/x86/lib/insn.c
28161 @@ -20,8 +20,10 @@
28162
28163 #ifdef __KERNEL__
28164 #include <linux/string.h>
28165 +#include <asm/pgtable_types.h>
28166 #else
28167 #include <string.h>
28168 +#define ktla_ktva(addr) addr
28169 #endif
28170 #include <asm/inat.h>
28171 #include <asm/insn.h>
28172 @@ -53,8 +55,8 @@
28173 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28174 {
28175 memset(insn, 0, sizeof(*insn));
28176 - insn->kaddr = kaddr;
28177 - insn->next_byte = kaddr;
28178 + insn->kaddr = ktla_ktva(kaddr);
28179 + insn->next_byte = ktla_ktva(kaddr);
28180 insn->x86_64 = x86_64 ? 1 : 0;
28181 insn->opnd_bytes = 4;
28182 if (x86_64)
28183 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28184 index 05a95e7..326f2fa 100644
28185 --- a/arch/x86/lib/iomap_copy_64.S
28186 +++ b/arch/x86/lib/iomap_copy_64.S
28187 @@ -17,6 +17,7 @@
28188
28189 #include <linux/linkage.h>
28190 #include <asm/dwarf2.h>
28191 +#include <asm/alternative-asm.h>
28192
28193 /*
28194 * override generic version in lib/iomap_copy.c
28195 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28196 CFI_STARTPROC
28197 movl %edx,%ecx
28198 rep movsd
28199 + pax_force_retaddr
28200 ret
28201 CFI_ENDPROC
28202 ENDPROC(__iowrite32_copy)
28203 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28204 index 56313a3..9b59269 100644
28205 --- a/arch/x86/lib/memcpy_64.S
28206 +++ b/arch/x86/lib/memcpy_64.S
28207 @@ -24,7 +24,7 @@
28208 * This gets patched over the unrolled variant (below) via the
28209 * alternative instructions framework:
28210 */
28211 - .section .altinstr_replacement, "ax", @progbits
28212 + .section .altinstr_replacement, "a", @progbits
28213 .Lmemcpy_c:
28214 movq %rdi, %rax
28215 movq %rdx, %rcx
28216 @@ -33,6 +33,7 @@
28217 rep movsq
28218 movl %edx, %ecx
28219 rep movsb
28220 + pax_force_retaddr
28221 ret
28222 .Lmemcpy_e:
28223 .previous
28224 @@ -44,11 +45,12 @@
28225 * This gets patched over the unrolled variant (below) via the
28226 * alternative instructions framework:
28227 */
28228 - .section .altinstr_replacement, "ax", @progbits
28229 + .section .altinstr_replacement, "a", @progbits
28230 .Lmemcpy_c_e:
28231 movq %rdi, %rax
28232 movq %rdx, %rcx
28233 rep movsb
28234 + pax_force_retaddr
28235 ret
28236 .Lmemcpy_e_e:
28237 .previous
28238 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28239 */
28240 movq 0*8(%rsi), %r8
28241 movq 1*8(%rsi), %r9
28242 - movq 2*8(%rsi), %r10
28243 + movq 2*8(%rsi), %rcx
28244 movq 3*8(%rsi), %r11
28245 leaq 4*8(%rsi), %rsi
28246
28247 movq %r8, 0*8(%rdi)
28248 movq %r9, 1*8(%rdi)
28249 - movq %r10, 2*8(%rdi)
28250 + movq %rcx, 2*8(%rdi)
28251 movq %r11, 3*8(%rdi)
28252 leaq 4*8(%rdi), %rdi
28253 jae .Lcopy_forward_loop
28254 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28255 subq $0x20, %rdx
28256 movq -1*8(%rsi), %r8
28257 movq -2*8(%rsi), %r9
28258 - movq -3*8(%rsi), %r10
28259 + movq -3*8(%rsi), %rcx
28260 movq -4*8(%rsi), %r11
28261 leaq -4*8(%rsi), %rsi
28262 movq %r8, -1*8(%rdi)
28263 movq %r9, -2*8(%rdi)
28264 - movq %r10, -3*8(%rdi)
28265 + movq %rcx, -3*8(%rdi)
28266 movq %r11, -4*8(%rdi)
28267 leaq -4*8(%rdi), %rdi
28268 jae .Lcopy_backward_loop
28269 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28270 */
28271 movq 0*8(%rsi), %r8
28272 movq 1*8(%rsi), %r9
28273 - movq -2*8(%rsi, %rdx), %r10
28274 + movq -2*8(%rsi, %rdx), %rcx
28275 movq -1*8(%rsi, %rdx), %r11
28276 movq %r8, 0*8(%rdi)
28277 movq %r9, 1*8(%rdi)
28278 - movq %r10, -2*8(%rdi, %rdx)
28279 + movq %rcx, -2*8(%rdi, %rdx)
28280 movq %r11, -1*8(%rdi, %rdx)
28281 + pax_force_retaddr
28282 retq
28283 .p2align 4
28284 .Lless_16bytes:
28285 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28286 movq -1*8(%rsi, %rdx), %r9
28287 movq %r8, 0*8(%rdi)
28288 movq %r9, -1*8(%rdi, %rdx)
28289 + pax_force_retaddr
28290 retq
28291 .p2align 4
28292 .Lless_8bytes:
28293 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28294 movl -4(%rsi, %rdx), %r8d
28295 movl %ecx, (%rdi)
28296 movl %r8d, -4(%rdi, %rdx)
28297 + pax_force_retaddr
28298 retq
28299 .p2align 4
28300 .Lless_3bytes:
28301 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28302 movb %cl, (%rdi)
28303
28304 .Lend:
28305 + pax_force_retaddr
28306 retq
28307 CFI_ENDPROC
28308 ENDPROC(memcpy)
28309 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28310 index 65268a6..5aa7815 100644
28311 --- a/arch/x86/lib/memmove_64.S
28312 +++ b/arch/x86/lib/memmove_64.S
28313 @@ -61,13 +61,13 @@ ENTRY(memmove)
28314 5:
28315 sub $0x20, %rdx
28316 movq 0*8(%rsi), %r11
28317 - movq 1*8(%rsi), %r10
28318 + movq 1*8(%rsi), %rcx
28319 movq 2*8(%rsi), %r9
28320 movq 3*8(%rsi), %r8
28321 leaq 4*8(%rsi), %rsi
28322
28323 movq %r11, 0*8(%rdi)
28324 - movq %r10, 1*8(%rdi)
28325 + movq %rcx, 1*8(%rdi)
28326 movq %r9, 2*8(%rdi)
28327 movq %r8, 3*8(%rdi)
28328 leaq 4*8(%rdi), %rdi
28329 @@ -81,10 +81,10 @@ ENTRY(memmove)
28330 4:
28331 movq %rdx, %rcx
28332 movq -8(%rsi, %rdx), %r11
28333 - lea -8(%rdi, %rdx), %r10
28334 + lea -8(%rdi, %rdx), %r9
28335 shrq $3, %rcx
28336 rep movsq
28337 - movq %r11, (%r10)
28338 + movq %r11, (%r9)
28339 jmp 13f
28340 .Lmemmove_end_forward:
28341
28342 @@ -95,14 +95,14 @@ ENTRY(memmove)
28343 7:
28344 movq %rdx, %rcx
28345 movq (%rsi), %r11
28346 - movq %rdi, %r10
28347 + movq %rdi, %r9
28348 leaq -8(%rsi, %rdx), %rsi
28349 leaq -8(%rdi, %rdx), %rdi
28350 shrq $3, %rcx
28351 std
28352 rep movsq
28353 cld
28354 - movq %r11, (%r10)
28355 + movq %r11, (%r9)
28356 jmp 13f
28357
28358 /*
28359 @@ -127,13 +127,13 @@ ENTRY(memmove)
28360 8:
28361 subq $0x20, %rdx
28362 movq -1*8(%rsi), %r11
28363 - movq -2*8(%rsi), %r10
28364 + movq -2*8(%rsi), %rcx
28365 movq -3*8(%rsi), %r9
28366 movq -4*8(%rsi), %r8
28367 leaq -4*8(%rsi), %rsi
28368
28369 movq %r11, -1*8(%rdi)
28370 - movq %r10, -2*8(%rdi)
28371 + movq %rcx, -2*8(%rdi)
28372 movq %r9, -3*8(%rdi)
28373 movq %r8, -4*8(%rdi)
28374 leaq -4*8(%rdi), %rdi
28375 @@ -151,11 +151,11 @@ ENTRY(memmove)
28376 * Move data from 16 bytes to 31 bytes.
28377 */
28378 movq 0*8(%rsi), %r11
28379 - movq 1*8(%rsi), %r10
28380 + movq 1*8(%rsi), %rcx
28381 movq -2*8(%rsi, %rdx), %r9
28382 movq -1*8(%rsi, %rdx), %r8
28383 movq %r11, 0*8(%rdi)
28384 - movq %r10, 1*8(%rdi)
28385 + movq %rcx, 1*8(%rdi)
28386 movq %r9, -2*8(%rdi, %rdx)
28387 movq %r8, -1*8(%rdi, %rdx)
28388 jmp 13f
28389 @@ -167,9 +167,9 @@ ENTRY(memmove)
28390 * Move data from 8 bytes to 15 bytes.
28391 */
28392 movq 0*8(%rsi), %r11
28393 - movq -1*8(%rsi, %rdx), %r10
28394 + movq -1*8(%rsi, %rdx), %r9
28395 movq %r11, 0*8(%rdi)
28396 - movq %r10, -1*8(%rdi, %rdx)
28397 + movq %r9, -1*8(%rdi, %rdx)
28398 jmp 13f
28399 10:
28400 cmpq $4, %rdx
28401 @@ -178,9 +178,9 @@ ENTRY(memmove)
28402 * Move data from 4 bytes to 7 bytes.
28403 */
28404 movl (%rsi), %r11d
28405 - movl -4(%rsi, %rdx), %r10d
28406 + movl -4(%rsi, %rdx), %r9d
28407 movl %r11d, (%rdi)
28408 - movl %r10d, -4(%rdi, %rdx)
28409 + movl %r9d, -4(%rdi, %rdx)
28410 jmp 13f
28411 11:
28412 cmp $2, %rdx
28413 @@ -189,9 +189,9 @@ ENTRY(memmove)
28414 * Move data from 2 bytes to 3 bytes.
28415 */
28416 movw (%rsi), %r11w
28417 - movw -2(%rsi, %rdx), %r10w
28418 + movw -2(%rsi, %rdx), %r9w
28419 movw %r11w, (%rdi)
28420 - movw %r10w, -2(%rdi, %rdx)
28421 + movw %r9w, -2(%rdi, %rdx)
28422 jmp 13f
28423 12:
28424 cmp $1, %rdx
28425 @@ -202,14 +202,16 @@ ENTRY(memmove)
28426 movb (%rsi), %r11b
28427 movb %r11b, (%rdi)
28428 13:
28429 + pax_force_retaddr
28430 retq
28431 CFI_ENDPROC
28432
28433 - .section .altinstr_replacement,"ax"
28434 + .section .altinstr_replacement,"a"
28435 .Lmemmove_begin_forward_efs:
28436 /* Forward moving data. */
28437 movq %rdx, %rcx
28438 rep movsb
28439 + pax_force_retaddr
28440 retq
28441 .Lmemmove_end_forward_efs:
28442 .previous
28443 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28444 index 2dcb380..50a78bc 100644
28445 --- a/arch/x86/lib/memset_64.S
28446 +++ b/arch/x86/lib/memset_64.S
28447 @@ -16,7 +16,7 @@
28448 *
28449 * rax original destination
28450 */
28451 - .section .altinstr_replacement, "ax", @progbits
28452 + .section .altinstr_replacement, "a", @progbits
28453 .Lmemset_c:
28454 movq %rdi,%r9
28455 movq %rdx,%rcx
28456 @@ -30,6 +30,7 @@
28457 movl %edx,%ecx
28458 rep stosb
28459 movq %r9,%rax
28460 + pax_force_retaddr
28461 ret
28462 .Lmemset_e:
28463 .previous
28464 @@ -45,13 +46,14 @@
28465 *
28466 * rax original destination
28467 */
28468 - .section .altinstr_replacement, "ax", @progbits
28469 + .section .altinstr_replacement, "a", @progbits
28470 .Lmemset_c_e:
28471 movq %rdi,%r9
28472 movb %sil,%al
28473 movq %rdx,%rcx
28474 rep stosb
28475 movq %r9,%rax
28476 + pax_force_retaddr
28477 ret
28478 .Lmemset_e_e:
28479 .previous
28480 @@ -59,7 +61,7 @@
28481 ENTRY(memset)
28482 ENTRY(__memset)
28483 CFI_STARTPROC
28484 - movq %rdi,%r10
28485 + movq %rdi,%r11
28486
28487 /* expand byte value */
28488 movzbl %sil,%ecx
28489 @@ -117,7 +119,8 @@ ENTRY(__memset)
28490 jnz .Lloop_1
28491
28492 .Lende:
28493 - movq %r10,%rax
28494 + movq %r11,%rax
28495 + pax_force_retaddr
28496 ret
28497
28498 CFI_RESTORE_STATE
28499 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28500 index c9f2d9b..e7fd2c0 100644
28501 --- a/arch/x86/lib/mmx_32.c
28502 +++ b/arch/x86/lib/mmx_32.c
28503 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28504 {
28505 void *p;
28506 int i;
28507 + unsigned long cr0;
28508
28509 if (unlikely(in_interrupt()))
28510 return __memcpy(to, from, len);
28511 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28512 kernel_fpu_begin();
28513
28514 __asm__ __volatile__ (
28515 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28516 - " prefetch 64(%0)\n"
28517 - " prefetch 128(%0)\n"
28518 - " prefetch 192(%0)\n"
28519 - " prefetch 256(%0)\n"
28520 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28521 + " prefetch 64(%1)\n"
28522 + " prefetch 128(%1)\n"
28523 + " prefetch 192(%1)\n"
28524 + " prefetch 256(%1)\n"
28525 "2: \n"
28526 ".section .fixup, \"ax\"\n"
28527 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28528 + "3: \n"
28529 +
28530 +#ifdef CONFIG_PAX_KERNEXEC
28531 + " movl %%cr0, %0\n"
28532 + " movl %0, %%eax\n"
28533 + " andl $0xFFFEFFFF, %%eax\n"
28534 + " movl %%eax, %%cr0\n"
28535 +#endif
28536 +
28537 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28538 +
28539 +#ifdef CONFIG_PAX_KERNEXEC
28540 + " movl %0, %%cr0\n"
28541 +#endif
28542 +
28543 " jmp 2b\n"
28544 ".previous\n"
28545 _ASM_EXTABLE(1b, 3b)
28546 - : : "r" (from));
28547 + : "=&r" (cr0) : "r" (from) : "ax");
28548
28549 for ( ; i > 5; i--) {
28550 __asm__ __volatile__ (
28551 - "1: prefetch 320(%0)\n"
28552 - "2: movq (%0), %%mm0\n"
28553 - " movq 8(%0), %%mm1\n"
28554 - " movq 16(%0), %%mm2\n"
28555 - " movq 24(%0), %%mm3\n"
28556 - " movq %%mm0, (%1)\n"
28557 - " movq %%mm1, 8(%1)\n"
28558 - " movq %%mm2, 16(%1)\n"
28559 - " movq %%mm3, 24(%1)\n"
28560 - " movq 32(%0), %%mm0\n"
28561 - " movq 40(%0), %%mm1\n"
28562 - " movq 48(%0), %%mm2\n"
28563 - " movq 56(%0), %%mm3\n"
28564 - " movq %%mm0, 32(%1)\n"
28565 - " movq %%mm1, 40(%1)\n"
28566 - " movq %%mm2, 48(%1)\n"
28567 - " movq %%mm3, 56(%1)\n"
28568 + "1: prefetch 320(%1)\n"
28569 + "2: movq (%1), %%mm0\n"
28570 + " movq 8(%1), %%mm1\n"
28571 + " movq 16(%1), %%mm2\n"
28572 + " movq 24(%1), %%mm3\n"
28573 + " movq %%mm0, (%2)\n"
28574 + " movq %%mm1, 8(%2)\n"
28575 + " movq %%mm2, 16(%2)\n"
28576 + " movq %%mm3, 24(%2)\n"
28577 + " movq 32(%1), %%mm0\n"
28578 + " movq 40(%1), %%mm1\n"
28579 + " movq 48(%1), %%mm2\n"
28580 + " movq 56(%1), %%mm3\n"
28581 + " movq %%mm0, 32(%2)\n"
28582 + " movq %%mm1, 40(%2)\n"
28583 + " movq %%mm2, 48(%2)\n"
28584 + " movq %%mm3, 56(%2)\n"
28585 ".section .fixup, \"ax\"\n"
28586 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28587 + "3:\n"
28588 +
28589 +#ifdef CONFIG_PAX_KERNEXEC
28590 + " movl %%cr0, %0\n"
28591 + " movl %0, %%eax\n"
28592 + " andl $0xFFFEFFFF, %%eax\n"
28593 + " movl %%eax, %%cr0\n"
28594 +#endif
28595 +
28596 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28597 +
28598 +#ifdef CONFIG_PAX_KERNEXEC
28599 + " movl %0, %%cr0\n"
28600 +#endif
28601 +
28602 " jmp 2b\n"
28603 ".previous\n"
28604 _ASM_EXTABLE(1b, 3b)
28605 - : : "r" (from), "r" (to) : "memory");
28606 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28607
28608 from += 64;
28609 to += 64;
28610 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28611 static void fast_copy_page(void *to, void *from)
28612 {
28613 int i;
28614 + unsigned long cr0;
28615
28616 kernel_fpu_begin();
28617
28618 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28619 * but that is for later. -AV
28620 */
28621 __asm__ __volatile__(
28622 - "1: prefetch (%0)\n"
28623 - " prefetch 64(%0)\n"
28624 - " prefetch 128(%0)\n"
28625 - " prefetch 192(%0)\n"
28626 - " prefetch 256(%0)\n"
28627 + "1: prefetch (%1)\n"
28628 + " prefetch 64(%1)\n"
28629 + " prefetch 128(%1)\n"
28630 + " prefetch 192(%1)\n"
28631 + " prefetch 256(%1)\n"
28632 "2: \n"
28633 ".section .fixup, \"ax\"\n"
28634 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28635 + "3: \n"
28636 +
28637 +#ifdef CONFIG_PAX_KERNEXEC
28638 + " movl %%cr0, %0\n"
28639 + " movl %0, %%eax\n"
28640 + " andl $0xFFFEFFFF, %%eax\n"
28641 + " movl %%eax, %%cr0\n"
28642 +#endif
28643 +
28644 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28645 +
28646 +#ifdef CONFIG_PAX_KERNEXEC
28647 + " movl %0, %%cr0\n"
28648 +#endif
28649 +
28650 " jmp 2b\n"
28651 ".previous\n"
28652 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28653 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28654
28655 for (i = 0; i < (4096-320)/64; i++) {
28656 __asm__ __volatile__ (
28657 - "1: prefetch 320(%0)\n"
28658 - "2: movq (%0), %%mm0\n"
28659 - " movntq %%mm0, (%1)\n"
28660 - " movq 8(%0), %%mm1\n"
28661 - " movntq %%mm1, 8(%1)\n"
28662 - " movq 16(%0), %%mm2\n"
28663 - " movntq %%mm2, 16(%1)\n"
28664 - " movq 24(%0), %%mm3\n"
28665 - " movntq %%mm3, 24(%1)\n"
28666 - " movq 32(%0), %%mm4\n"
28667 - " movntq %%mm4, 32(%1)\n"
28668 - " movq 40(%0), %%mm5\n"
28669 - " movntq %%mm5, 40(%1)\n"
28670 - " movq 48(%0), %%mm6\n"
28671 - " movntq %%mm6, 48(%1)\n"
28672 - " movq 56(%0), %%mm7\n"
28673 - " movntq %%mm7, 56(%1)\n"
28674 + "1: prefetch 320(%1)\n"
28675 + "2: movq (%1), %%mm0\n"
28676 + " movntq %%mm0, (%2)\n"
28677 + " movq 8(%1), %%mm1\n"
28678 + " movntq %%mm1, 8(%2)\n"
28679 + " movq 16(%1), %%mm2\n"
28680 + " movntq %%mm2, 16(%2)\n"
28681 + " movq 24(%1), %%mm3\n"
28682 + " movntq %%mm3, 24(%2)\n"
28683 + " movq 32(%1), %%mm4\n"
28684 + " movntq %%mm4, 32(%2)\n"
28685 + " movq 40(%1), %%mm5\n"
28686 + " movntq %%mm5, 40(%2)\n"
28687 + " movq 48(%1), %%mm6\n"
28688 + " movntq %%mm6, 48(%2)\n"
28689 + " movq 56(%1), %%mm7\n"
28690 + " movntq %%mm7, 56(%2)\n"
28691 ".section .fixup, \"ax\"\n"
28692 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28693 + "3:\n"
28694 +
28695 +#ifdef CONFIG_PAX_KERNEXEC
28696 + " movl %%cr0, %0\n"
28697 + " movl %0, %%eax\n"
28698 + " andl $0xFFFEFFFF, %%eax\n"
28699 + " movl %%eax, %%cr0\n"
28700 +#endif
28701 +
28702 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28703 +
28704 +#ifdef CONFIG_PAX_KERNEXEC
28705 + " movl %0, %%cr0\n"
28706 +#endif
28707 +
28708 " jmp 2b\n"
28709 ".previous\n"
28710 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28711 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28712
28713 from += 64;
28714 to += 64;
28715 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28716 static void fast_copy_page(void *to, void *from)
28717 {
28718 int i;
28719 + unsigned long cr0;
28720
28721 kernel_fpu_begin();
28722
28723 __asm__ __volatile__ (
28724 - "1: prefetch (%0)\n"
28725 - " prefetch 64(%0)\n"
28726 - " prefetch 128(%0)\n"
28727 - " prefetch 192(%0)\n"
28728 - " prefetch 256(%0)\n"
28729 + "1: prefetch (%1)\n"
28730 + " prefetch 64(%1)\n"
28731 + " prefetch 128(%1)\n"
28732 + " prefetch 192(%1)\n"
28733 + " prefetch 256(%1)\n"
28734 "2: \n"
28735 ".section .fixup, \"ax\"\n"
28736 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28737 + "3: \n"
28738 +
28739 +#ifdef CONFIG_PAX_KERNEXEC
28740 + " movl %%cr0, %0\n"
28741 + " movl %0, %%eax\n"
28742 + " andl $0xFFFEFFFF, %%eax\n"
28743 + " movl %%eax, %%cr0\n"
28744 +#endif
28745 +
28746 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28747 +
28748 +#ifdef CONFIG_PAX_KERNEXEC
28749 + " movl %0, %%cr0\n"
28750 +#endif
28751 +
28752 " jmp 2b\n"
28753 ".previous\n"
28754 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28755 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28756
28757 for (i = 0; i < 4096/64; i++) {
28758 __asm__ __volatile__ (
28759 - "1: prefetch 320(%0)\n"
28760 - "2: movq (%0), %%mm0\n"
28761 - " movq 8(%0), %%mm1\n"
28762 - " movq 16(%0), %%mm2\n"
28763 - " movq 24(%0), %%mm3\n"
28764 - " movq %%mm0, (%1)\n"
28765 - " movq %%mm1, 8(%1)\n"
28766 - " movq %%mm2, 16(%1)\n"
28767 - " movq %%mm3, 24(%1)\n"
28768 - " movq 32(%0), %%mm0\n"
28769 - " movq 40(%0), %%mm1\n"
28770 - " movq 48(%0), %%mm2\n"
28771 - " movq 56(%0), %%mm3\n"
28772 - " movq %%mm0, 32(%1)\n"
28773 - " movq %%mm1, 40(%1)\n"
28774 - " movq %%mm2, 48(%1)\n"
28775 - " movq %%mm3, 56(%1)\n"
28776 + "1: prefetch 320(%1)\n"
28777 + "2: movq (%1), %%mm0\n"
28778 + " movq 8(%1), %%mm1\n"
28779 + " movq 16(%1), %%mm2\n"
28780 + " movq 24(%1), %%mm3\n"
28781 + " movq %%mm0, (%2)\n"
28782 + " movq %%mm1, 8(%2)\n"
28783 + " movq %%mm2, 16(%2)\n"
28784 + " movq %%mm3, 24(%2)\n"
28785 + " movq 32(%1), %%mm0\n"
28786 + " movq 40(%1), %%mm1\n"
28787 + " movq 48(%1), %%mm2\n"
28788 + " movq 56(%1), %%mm3\n"
28789 + " movq %%mm0, 32(%2)\n"
28790 + " movq %%mm1, 40(%2)\n"
28791 + " movq %%mm2, 48(%2)\n"
28792 + " movq %%mm3, 56(%2)\n"
28793 ".section .fixup, \"ax\"\n"
28794 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28795 + "3:\n"
28796 +
28797 +#ifdef CONFIG_PAX_KERNEXEC
28798 + " movl %%cr0, %0\n"
28799 + " movl %0, %%eax\n"
28800 + " andl $0xFFFEFFFF, %%eax\n"
28801 + " movl %%eax, %%cr0\n"
28802 +#endif
28803 +
28804 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28805 +
28806 +#ifdef CONFIG_PAX_KERNEXEC
28807 + " movl %0, %%cr0\n"
28808 +#endif
28809 +
28810 " jmp 2b\n"
28811 ".previous\n"
28812 _ASM_EXTABLE(1b, 3b)
28813 - : : "r" (from), "r" (to) : "memory");
28814 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28815
28816 from += 64;
28817 to += 64;
28818 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28819 index f6d13ee..aca5f0b 100644
28820 --- a/arch/x86/lib/msr-reg.S
28821 +++ b/arch/x86/lib/msr-reg.S
28822 @@ -3,6 +3,7 @@
28823 #include <asm/dwarf2.h>
28824 #include <asm/asm.h>
28825 #include <asm/msr.h>
28826 +#include <asm/alternative-asm.h>
28827
28828 #ifdef CONFIG_X86_64
28829 /*
28830 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28831 CFI_STARTPROC
28832 pushq_cfi %rbx
28833 pushq_cfi %rbp
28834 - movq %rdi, %r10 /* Save pointer */
28835 + movq %rdi, %r9 /* Save pointer */
28836 xorl %r11d, %r11d /* Return value */
28837 movl (%rdi), %eax
28838 movl 4(%rdi), %ecx
28839 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28840 movl 28(%rdi), %edi
28841 CFI_REMEMBER_STATE
28842 1: \op
28843 -2: movl %eax, (%r10)
28844 +2: movl %eax, (%r9)
28845 movl %r11d, %eax /* Return value */
28846 - movl %ecx, 4(%r10)
28847 - movl %edx, 8(%r10)
28848 - movl %ebx, 12(%r10)
28849 - movl %ebp, 20(%r10)
28850 - movl %esi, 24(%r10)
28851 - movl %edi, 28(%r10)
28852 + movl %ecx, 4(%r9)
28853 + movl %edx, 8(%r9)
28854 + movl %ebx, 12(%r9)
28855 + movl %ebp, 20(%r9)
28856 + movl %esi, 24(%r9)
28857 + movl %edi, 28(%r9)
28858 popq_cfi %rbp
28859 popq_cfi %rbx
28860 + pax_force_retaddr
28861 ret
28862 3:
28863 CFI_RESTORE_STATE
28864 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28865 index fc6ba17..d4d989d 100644
28866 --- a/arch/x86/lib/putuser.S
28867 +++ b/arch/x86/lib/putuser.S
28868 @@ -16,7 +16,9 @@
28869 #include <asm/errno.h>
28870 #include <asm/asm.h>
28871 #include <asm/smap.h>
28872 -
28873 +#include <asm/segment.h>
28874 +#include <asm/pgtable.h>
28875 +#include <asm/alternative-asm.h>
28876
28877 /*
28878 * __put_user_X
28879 @@ -30,57 +32,125 @@
28880 * as they get called from within inline assembly.
28881 */
28882
28883 -#define ENTER CFI_STARTPROC ; \
28884 - GET_THREAD_INFO(%_ASM_BX)
28885 -#define EXIT ASM_CLAC ; \
28886 - ret ; \
28887 +#define ENTER CFI_STARTPROC
28888 +#define EXIT ASM_CLAC ; \
28889 + pax_force_retaddr ; \
28890 + ret ; \
28891 CFI_ENDPROC
28892
28893 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28894 +#define _DEST %_ASM_CX,%_ASM_BX
28895 +#else
28896 +#define _DEST %_ASM_CX
28897 +#endif
28898 +
28899 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28900 +#define __copyuser_seg gs;
28901 +#else
28902 +#define __copyuser_seg
28903 +#endif
28904 +
28905 .text
28906 ENTRY(__put_user_1)
28907 ENTER
28908 +
28909 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28910 + GET_THREAD_INFO(%_ASM_BX)
28911 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28912 jae bad_put_user
28913 ASM_STAC
28914 -1: movb %al,(%_ASM_CX)
28915 +
28916 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28917 + mov pax_user_shadow_base,%_ASM_BX
28918 + cmp %_ASM_BX,%_ASM_CX
28919 + jb 1234f
28920 + xor %ebx,%ebx
28921 +1234:
28922 +#endif
28923 +
28924 +#endif
28925 +
28926 +1: __copyuser_seg movb %al,(_DEST)
28927 xor %eax,%eax
28928 EXIT
28929 ENDPROC(__put_user_1)
28930
28931 ENTRY(__put_user_2)
28932 ENTER
28933 +
28934 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28935 + GET_THREAD_INFO(%_ASM_BX)
28936 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28937 sub $1,%_ASM_BX
28938 cmp %_ASM_BX,%_ASM_CX
28939 jae bad_put_user
28940 ASM_STAC
28941 -2: movw %ax,(%_ASM_CX)
28942 +
28943 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28944 + mov pax_user_shadow_base,%_ASM_BX
28945 + cmp %_ASM_BX,%_ASM_CX
28946 + jb 1234f
28947 + xor %ebx,%ebx
28948 +1234:
28949 +#endif
28950 +
28951 +#endif
28952 +
28953 +2: __copyuser_seg movw %ax,(_DEST)
28954 xor %eax,%eax
28955 EXIT
28956 ENDPROC(__put_user_2)
28957
28958 ENTRY(__put_user_4)
28959 ENTER
28960 +
28961 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28962 + GET_THREAD_INFO(%_ASM_BX)
28963 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28964 sub $3,%_ASM_BX
28965 cmp %_ASM_BX,%_ASM_CX
28966 jae bad_put_user
28967 ASM_STAC
28968 -3: movl %eax,(%_ASM_CX)
28969 +
28970 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28971 + mov pax_user_shadow_base,%_ASM_BX
28972 + cmp %_ASM_BX,%_ASM_CX
28973 + jb 1234f
28974 + xor %ebx,%ebx
28975 +1234:
28976 +#endif
28977 +
28978 +#endif
28979 +
28980 +3: __copyuser_seg movl %eax,(_DEST)
28981 xor %eax,%eax
28982 EXIT
28983 ENDPROC(__put_user_4)
28984
28985 ENTRY(__put_user_8)
28986 ENTER
28987 +
28988 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28989 + GET_THREAD_INFO(%_ASM_BX)
28990 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28991 sub $7,%_ASM_BX
28992 cmp %_ASM_BX,%_ASM_CX
28993 jae bad_put_user
28994 ASM_STAC
28995 -4: mov %_ASM_AX,(%_ASM_CX)
28996 +
28997 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28998 + mov pax_user_shadow_base,%_ASM_BX
28999 + cmp %_ASM_BX,%_ASM_CX
29000 + jb 1234f
29001 + xor %ebx,%ebx
29002 +1234:
29003 +#endif
29004 +
29005 +#endif
29006 +
29007 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29008 #ifdef CONFIG_X86_32
29009 -5: movl %edx,4(%_ASM_CX)
29010 +5: __copyuser_seg movl %edx,4(_DEST)
29011 #endif
29012 xor %eax,%eax
29013 EXIT
29014 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29015 index 1cad221..de671ee 100644
29016 --- a/arch/x86/lib/rwlock.S
29017 +++ b/arch/x86/lib/rwlock.S
29018 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29019 FRAME
29020 0: LOCK_PREFIX
29021 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29022 +
29023 +#ifdef CONFIG_PAX_REFCOUNT
29024 + jno 1234f
29025 + LOCK_PREFIX
29026 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29027 + int $4
29028 +1234:
29029 + _ASM_EXTABLE(1234b, 1234b)
29030 +#endif
29031 +
29032 1: rep; nop
29033 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29034 jne 1b
29035 LOCK_PREFIX
29036 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29037 +
29038 +#ifdef CONFIG_PAX_REFCOUNT
29039 + jno 1234f
29040 + LOCK_PREFIX
29041 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29042 + int $4
29043 +1234:
29044 + _ASM_EXTABLE(1234b, 1234b)
29045 +#endif
29046 +
29047 jnz 0b
29048 ENDFRAME
29049 + pax_force_retaddr
29050 ret
29051 CFI_ENDPROC
29052 END(__write_lock_failed)
29053 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29054 FRAME
29055 0: LOCK_PREFIX
29056 READ_LOCK_SIZE(inc) (%__lock_ptr)
29057 +
29058 +#ifdef CONFIG_PAX_REFCOUNT
29059 + jno 1234f
29060 + LOCK_PREFIX
29061 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29062 + int $4
29063 +1234:
29064 + _ASM_EXTABLE(1234b, 1234b)
29065 +#endif
29066 +
29067 1: rep; nop
29068 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29069 js 1b
29070 LOCK_PREFIX
29071 READ_LOCK_SIZE(dec) (%__lock_ptr)
29072 +
29073 +#ifdef CONFIG_PAX_REFCOUNT
29074 + jno 1234f
29075 + LOCK_PREFIX
29076 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29077 + int $4
29078 +1234:
29079 + _ASM_EXTABLE(1234b, 1234b)
29080 +#endif
29081 +
29082 js 0b
29083 ENDFRAME
29084 + pax_force_retaddr
29085 ret
29086 CFI_ENDPROC
29087 END(__read_lock_failed)
29088 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29089 index 5dff5f0..cadebf4 100644
29090 --- a/arch/x86/lib/rwsem.S
29091 +++ b/arch/x86/lib/rwsem.S
29092 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29093 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29094 CFI_RESTORE __ASM_REG(dx)
29095 restore_common_regs
29096 + pax_force_retaddr
29097 ret
29098 CFI_ENDPROC
29099 ENDPROC(call_rwsem_down_read_failed)
29100 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29101 movq %rax,%rdi
29102 call rwsem_down_write_failed
29103 restore_common_regs
29104 + pax_force_retaddr
29105 ret
29106 CFI_ENDPROC
29107 ENDPROC(call_rwsem_down_write_failed)
29108 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29109 movq %rax,%rdi
29110 call rwsem_wake
29111 restore_common_regs
29112 -1: ret
29113 +1: pax_force_retaddr
29114 + ret
29115 CFI_ENDPROC
29116 ENDPROC(call_rwsem_wake)
29117
29118 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29119 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29120 CFI_RESTORE __ASM_REG(dx)
29121 restore_common_regs
29122 + pax_force_retaddr
29123 ret
29124 CFI_ENDPROC
29125 ENDPROC(call_rwsem_downgrade_wake)
29126 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29127 index a63efd6..ccecad8 100644
29128 --- a/arch/x86/lib/thunk_64.S
29129 +++ b/arch/x86/lib/thunk_64.S
29130 @@ -8,6 +8,7 @@
29131 #include <linux/linkage.h>
29132 #include <asm/dwarf2.h>
29133 #include <asm/calling.h>
29134 +#include <asm/alternative-asm.h>
29135
29136 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29137 .macro THUNK name, func, put_ret_addr_in_rdi=0
29138 @@ -41,5 +42,6 @@
29139 SAVE_ARGS
29140 restore:
29141 RESTORE_ARGS
29142 + pax_force_retaddr
29143 ret
29144 CFI_ENDPROC
29145 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29146 index 3eb18ac..4b22130 100644
29147 --- a/arch/x86/lib/usercopy_32.c
29148 +++ b/arch/x86/lib/usercopy_32.c
29149 @@ -42,11 +42,13 @@ do { \
29150 int __d0; \
29151 might_fault(); \
29152 __asm__ __volatile__( \
29153 + __COPYUSER_SET_ES \
29154 ASM_STAC "\n" \
29155 "0: rep; stosl\n" \
29156 " movl %2,%0\n" \
29157 "1: rep; stosb\n" \
29158 "2: " ASM_CLAC "\n" \
29159 + __COPYUSER_RESTORE_ES \
29160 ".section .fixup,\"ax\"\n" \
29161 "3: lea 0(%2,%0,4),%0\n" \
29162 " jmp 2b\n" \
29163 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29164
29165 #ifdef CONFIG_X86_INTEL_USERCOPY
29166 static unsigned long
29167 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29168 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29169 {
29170 int d0, d1;
29171 __asm__ __volatile__(
29172 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29173 " .align 2,0x90\n"
29174 "3: movl 0(%4), %%eax\n"
29175 "4: movl 4(%4), %%edx\n"
29176 - "5: movl %%eax, 0(%3)\n"
29177 - "6: movl %%edx, 4(%3)\n"
29178 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29179 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29180 "7: movl 8(%4), %%eax\n"
29181 "8: movl 12(%4),%%edx\n"
29182 - "9: movl %%eax, 8(%3)\n"
29183 - "10: movl %%edx, 12(%3)\n"
29184 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29185 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29186 "11: movl 16(%4), %%eax\n"
29187 "12: movl 20(%4), %%edx\n"
29188 - "13: movl %%eax, 16(%3)\n"
29189 - "14: movl %%edx, 20(%3)\n"
29190 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29191 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29192 "15: movl 24(%4), %%eax\n"
29193 "16: movl 28(%4), %%edx\n"
29194 - "17: movl %%eax, 24(%3)\n"
29195 - "18: movl %%edx, 28(%3)\n"
29196 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29197 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29198 "19: movl 32(%4), %%eax\n"
29199 "20: movl 36(%4), %%edx\n"
29200 - "21: movl %%eax, 32(%3)\n"
29201 - "22: movl %%edx, 36(%3)\n"
29202 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29203 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29204 "23: movl 40(%4), %%eax\n"
29205 "24: movl 44(%4), %%edx\n"
29206 - "25: movl %%eax, 40(%3)\n"
29207 - "26: movl %%edx, 44(%3)\n"
29208 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29209 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29210 "27: movl 48(%4), %%eax\n"
29211 "28: movl 52(%4), %%edx\n"
29212 - "29: movl %%eax, 48(%3)\n"
29213 - "30: movl %%edx, 52(%3)\n"
29214 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29215 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29216 "31: movl 56(%4), %%eax\n"
29217 "32: movl 60(%4), %%edx\n"
29218 - "33: movl %%eax, 56(%3)\n"
29219 - "34: movl %%edx, 60(%3)\n"
29220 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29221 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29222 " addl $-64, %0\n"
29223 " addl $64, %4\n"
29224 " addl $64, %3\n"
29225 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29226 " shrl $2, %0\n"
29227 " andl $3, %%eax\n"
29228 " cld\n"
29229 + __COPYUSER_SET_ES
29230 "99: rep; movsl\n"
29231 "36: movl %%eax, %0\n"
29232 "37: rep; movsb\n"
29233 "100:\n"
29234 + __COPYUSER_RESTORE_ES
29235 + ".section .fixup,\"ax\"\n"
29236 + "101: lea 0(%%eax,%0,4),%0\n"
29237 + " jmp 100b\n"
29238 + ".previous\n"
29239 + _ASM_EXTABLE(1b,100b)
29240 + _ASM_EXTABLE(2b,100b)
29241 + _ASM_EXTABLE(3b,100b)
29242 + _ASM_EXTABLE(4b,100b)
29243 + _ASM_EXTABLE(5b,100b)
29244 + _ASM_EXTABLE(6b,100b)
29245 + _ASM_EXTABLE(7b,100b)
29246 + _ASM_EXTABLE(8b,100b)
29247 + _ASM_EXTABLE(9b,100b)
29248 + _ASM_EXTABLE(10b,100b)
29249 + _ASM_EXTABLE(11b,100b)
29250 + _ASM_EXTABLE(12b,100b)
29251 + _ASM_EXTABLE(13b,100b)
29252 + _ASM_EXTABLE(14b,100b)
29253 + _ASM_EXTABLE(15b,100b)
29254 + _ASM_EXTABLE(16b,100b)
29255 + _ASM_EXTABLE(17b,100b)
29256 + _ASM_EXTABLE(18b,100b)
29257 + _ASM_EXTABLE(19b,100b)
29258 + _ASM_EXTABLE(20b,100b)
29259 + _ASM_EXTABLE(21b,100b)
29260 + _ASM_EXTABLE(22b,100b)
29261 + _ASM_EXTABLE(23b,100b)
29262 + _ASM_EXTABLE(24b,100b)
29263 + _ASM_EXTABLE(25b,100b)
29264 + _ASM_EXTABLE(26b,100b)
29265 + _ASM_EXTABLE(27b,100b)
29266 + _ASM_EXTABLE(28b,100b)
29267 + _ASM_EXTABLE(29b,100b)
29268 + _ASM_EXTABLE(30b,100b)
29269 + _ASM_EXTABLE(31b,100b)
29270 + _ASM_EXTABLE(32b,100b)
29271 + _ASM_EXTABLE(33b,100b)
29272 + _ASM_EXTABLE(34b,100b)
29273 + _ASM_EXTABLE(35b,100b)
29274 + _ASM_EXTABLE(36b,100b)
29275 + _ASM_EXTABLE(37b,100b)
29276 + _ASM_EXTABLE(99b,101b)
29277 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29278 + : "1"(to), "2"(from), "0"(size)
29279 + : "eax", "edx", "memory");
29280 + return size;
29281 +}
29282 +
29283 +static unsigned long
29284 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29285 +{
29286 + int d0, d1;
29287 + __asm__ __volatile__(
29288 + " .align 2,0x90\n"
29289 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29290 + " cmpl $67, %0\n"
29291 + " jbe 3f\n"
29292 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29293 + " .align 2,0x90\n"
29294 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29295 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29296 + "5: movl %%eax, 0(%3)\n"
29297 + "6: movl %%edx, 4(%3)\n"
29298 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29299 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29300 + "9: movl %%eax, 8(%3)\n"
29301 + "10: movl %%edx, 12(%3)\n"
29302 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29303 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29304 + "13: movl %%eax, 16(%3)\n"
29305 + "14: movl %%edx, 20(%3)\n"
29306 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29307 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29308 + "17: movl %%eax, 24(%3)\n"
29309 + "18: movl %%edx, 28(%3)\n"
29310 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29311 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29312 + "21: movl %%eax, 32(%3)\n"
29313 + "22: movl %%edx, 36(%3)\n"
29314 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29315 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29316 + "25: movl %%eax, 40(%3)\n"
29317 + "26: movl %%edx, 44(%3)\n"
29318 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29319 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29320 + "29: movl %%eax, 48(%3)\n"
29321 + "30: movl %%edx, 52(%3)\n"
29322 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29323 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29324 + "33: movl %%eax, 56(%3)\n"
29325 + "34: movl %%edx, 60(%3)\n"
29326 + " addl $-64, %0\n"
29327 + " addl $64, %4\n"
29328 + " addl $64, %3\n"
29329 + " cmpl $63, %0\n"
29330 + " ja 1b\n"
29331 + "35: movl %0, %%eax\n"
29332 + " shrl $2, %0\n"
29333 + " andl $3, %%eax\n"
29334 + " cld\n"
29335 + "99: rep; "__copyuser_seg" movsl\n"
29336 + "36: movl %%eax, %0\n"
29337 + "37: rep; "__copyuser_seg" movsb\n"
29338 + "100:\n"
29339 ".section .fixup,\"ax\"\n"
29340 "101: lea 0(%%eax,%0,4),%0\n"
29341 " jmp 100b\n"
29342 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29343 int d0, d1;
29344 __asm__ __volatile__(
29345 " .align 2,0x90\n"
29346 - "0: movl 32(%4), %%eax\n"
29347 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29348 " cmpl $67, %0\n"
29349 " jbe 2f\n"
29350 - "1: movl 64(%4), %%eax\n"
29351 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29352 " .align 2,0x90\n"
29353 - "2: movl 0(%4), %%eax\n"
29354 - "21: movl 4(%4), %%edx\n"
29355 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29356 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29357 " movl %%eax, 0(%3)\n"
29358 " movl %%edx, 4(%3)\n"
29359 - "3: movl 8(%4), %%eax\n"
29360 - "31: movl 12(%4),%%edx\n"
29361 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29362 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29363 " movl %%eax, 8(%3)\n"
29364 " movl %%edx, 12(%3)\n"
29365 - "4: movl 16(%4), %%eax\n"
29366 - "41: movl 20(%4), %%edx\n"
29367 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29368 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29369 " movl %%eax, 16(%3)\n"
29370 " movl %%edx, 20(%3)\n"
29371 - "10: movl 24(%4), %%eax\n"
29372 - "51: movl 28(%4), %%edx\n"
29373 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29374 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29375 " movl %%eax, 24(%3)\n"
29376 " movl %%edx, 28(%3)\n"
29377 - "11: movl 32(%4), %%eax\n"
29378 - "61: movl 36(%4), %%edx\n"
29379 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29380 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29381 " movl %%eax, 32(%3)\n"
29382 " movl %%edx, 36(%3)\n"
29383 - "12: movl 40(%4), %%eax\n"
29384 - "71: movl 44(%4), %%edx\n"
29385 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29386 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29387 " movl %%eax, 40(%3)\n"
29388 " movl %%edx, 44(%3)\n"
29389 - "13: movl 48(%4), %%eax\n"
29390 - "81: movl 52(%4), %%edx\n"
29391 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29392 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29393 " movl %%eax, 48(%3)\n"
29394 " movl %%edx, 52(%3)\n"
29395 - "14: movl 56(%4), %%eax\n"
29396 - "91: movl 60(%4), %%edx\n"
29397 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29398 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29399 " movl %%eax, 56(%3)\n"
29400 " movl %%edx, 60(%3)\n"
29401 " addl $-64, %0\n"
29402 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29403 " shrl $2, %0\n"
29404 " andl $3, %%eax\n"
29405 " cld\n"
29406 - "6: rep; movsl\n"
29407 + "6: rep; "__copyuser_seg" movsl\n"
29408 " movl %%eax,%0\n"
29409 - "7: rep; movsb\n"
29410 + "7: rep; "__copyuser_seg" movsb\n"
29411 "8:\n"
29412 ".section .fixup,\"ax\"\n"
29413 "9: lea 0(%%eax,%0,4),%0\n"
29414 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29415
29416 __asm__ __volatile__(
29417 " .align 2,0x90\n"
29418 - "0: movl 32(%4), %%eax\n"
29419 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29420 " cmpl $67, %0\n"
29421 " jbe 2f\n"
29422 - "1: movl 64(%4), %%eax\n"
29423 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29424 " .align 2,0x90\n"
29425 - "2: movl 0(%4), %%eax\n"
29426 - "21: movl 4(%4), %%edx\n"
29427 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29428 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29429 " movnti %%eax, 0(%3)\n"
29430 " movnti %%edx, 4(%3)\n"
29431 - "3: movl 8(%4), %%eax\n"
29432 - "31: movl 12(%4),%%edx\n"
29433 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29434 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29435 " movnti %%eax, 8(%3)\n"
29436 " movnti %%edx, 12(%3)\n"
29437 - "4: movl 16(%4), %%eax\n"
29438 - "41: movl 20(%4), %%edx\n"
29439 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29440 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29441 " movnti %%eax, 16(%3)\n"
29442 " movnti %%edx, 20(%3)\n"
29443 - "10: movl 24(%4), %%eax\n"
29444 - "51: movl 28(%4), %%edx\n"
29445 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29446 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29447 " movnti %%eax, 24(%3)\n"
29448 " movnti %%edx, 28(%3)\n"
29449 - "11: movl 32(%4), %%eax\n"
29450 - "61: movl 36(%4), %%edx\n"
29451 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29452 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29453 " movnti %%eax, 32(%3)\n"
29454 " movnti %%edx, 36(%3)\n"
29455 - "12: movl 40(%4), %%eax\n"
29456 - "71: movl 44(%4), %%edx\n"
29457 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29458 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29459 " movnti %%eax, 40(%3)\n"
29460 " movnti %%edx, 44(%3)\n"
29461 - "13: movl 48(%4), %%eax\n"
29462 - "81: movl 52(%4), %%edx\n"
29463 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29464 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29465 " movnti %%eax, 48(%3)\n"
29466 " movnti %%edx, 52(%3)\n"
29467 - "14: movl 56(%4), %%eax\n"
29468 - "91: movl 60(%4), %%edx\n"
29469 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29470 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29471 " movnti %%eax, 56(%3)\n"
29472 " movnti %%edx, 60(%3)\n"
29473 " addl $-64, %0\n"
29474 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29475 " shrl $2, %0\n"
29476 " andl $3, %%eax\n"
29477 " cld\n"
29478 - "6: rep; movsl\n"
29479 + "6: rep; "__copyuser_seg" movsl\n"
29480 " movl %%eax,%0\n"
29481 - "7: rep; movsb\n"
29482 + "7: rep; "__copyuser_seg" movsb\n"
29483 "8:\n"
29484 ".section .fixup,\"ax\"\n"
29485 "9: lea 0(%%eax,%0,4),%0\n"
29486 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
29487
29488 __asm__ __volatile__(
29489 " .align 2,0x90\n"
29490 - "0: movl 32(%4), %%eax\n"
29491 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29492 " cmpl $67, %0\n"
29493 " jbe 2f\n"
29494 - "1: movl 64(%4), %%eax\n"
29495 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29496 " .align 2,0x90\n"
29497 - "2: movl 0(%4), %%eax\n"
29498 - "21: movl 4(%4), %%edx\n"
29499 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29500 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29501 " movnti %%eax, 0(%3)\n"
29502 " movnti %%edx, 4(%3)\n"
29503 - "3: movl 8(%4), %%eax\n"
29504 - "31: movl 12(%4),%%edx\n"
29505 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29506 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29507 " movnti %%eax, 8(%3)\n"
29508 " movnti %%edx, 12(%3)\n"
29509 - "4: movl 16(%4), %%eax\n"
29510 - "41: movl 20(%4), %%edx\n"
29511 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29512 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29513 " movnti %%eax, 16(%3)\n"
29514 " movnti %%edx, 20(%3)\n"
29515 - "10: movl 24(%4), %%eax\n"
29516 - "51: movl 28(%4), %%edx\n"
29517 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29518 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29519 " movnti %%eax, 24(%3)\n"
29520 " movnti %%edx, 28(%3)\n"
29521 - "11: movl 32(%4), %%eax\n"
29522 - "61: movl 36(%4), %%edx\n"
29523 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29524 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29525 " movnti %%eax, 32(%3)\n"
29526 " movnti %%edx, 36(%3)\n"
29527 - "12: movl 40(%4), %%eax\n"
29528 - "71: movl 44(%4), %%edx\n"
29529 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29530 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29531 " movnti %%eax, 40(%3)\n"
29532 " movnti %%edx, 44(%3)\n"
29533 - "13: movl 48(%4), %%eax\n"
29534 - "81: movl 52(%4), %%edx\n"
29535 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29536 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29537 " movnti %%eax, 48(%3)\n"
29538 " movnti %%edx, 52(%3)\n"
29539 - "14: movl 56(%4), %%eax\n"
29540 - "91: movl 60(%4), %%edx\n"
29541 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29542 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29543 " movnti %%eax, 56(%3)\n"
29544 " movnti %%edx, 60(%3)\n"
29545 " addl $-64, %0\n"
29546 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29547 " shrl $2, %0\n"
29548 " andl $3, %%eax\n"
29549 " cld\n"
29550 - "6: rep; movsl\n"
29551 + "6: rep; "__copyuser_seg" movsl\n"
29552 " movl %%eax,%0\n"
29553 - "7: rep; movsb\n"
29554 + "7: rep; "__copyuser_seg" movsb\n"
29555 "8:\n"
29556 ".section .fixup,\"ax\"\n"
29557 "9: lea 0(%%eax,%0,4),%0\n"
29558 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29559 */
29560 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29561 unsigned long size);
29562 -unsigned long __copy_user_intel(void __user *to, const void *from,
29563 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29564 + unsigned long size);
29565 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29566 unsigned long size);
29567 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29568 const void __user *from, unsigned long size);
29569 #endif /* CONFIG_X86_INTEL_USERCOPY */
29570
29571 /* Generic arbitrary sized copy. */
29572 -#define __copy_user(to, from, size) \
29573 +#define __copy_user(to, from, size, prefix, set, restore) \
29574 do { \
29575 int __d0, __d1, __d2; \
29576 __asm__ __volatile__( \
29577 + set \
29578 " cmp $7,%0\n" \
29579 " jbe 1f\n" \
29580 " movl %1,%0\n" \
29581 " negl %0\n" \
29582 " andl $7,%0\n" \
29583 " subl %0,%3\n" \
29584 - "4: rep; movsb\n" \
29585 + "4: rep; "prefix"movsb\n" \
29586 " movl %3,%0\n" \
29587 " shrl $2,%0\n" \
29588 " andl $3,%3\n" \
29589 " .align 2,0x90\n" \
29590 - "0: rep; movsl\n" \
29591 + "0: rep; "prefix"movsl\n" \
29592 " movl %3,%0\n" \
29593 - "1: rep; movsb\n" \
29594 + "1: rep; "prefix"movsb\n" \
29595 "2:\n" \
29596 + restore \
29597 ".section .fixup,\"ax\"\n" \
29598 "5: addl %3,%0\n" \
29599 " jmp 2b\n" \
29600 @@ -538,14 +650,14 @@ do { \
29601 " negl %0\n" \
29602 " andl $7,%0\n" \
29603 " subl %0,%3\n" \
29604 - "4: rep; movsb\n" \
29605 + "4: rep; "__copyuser_seg"movsb\n" \
29606 " movl %3,%0\n" \
29607 " shrl $2,%0\n" \
29608 " andl $3,%3\n" \
29609 " .align 2,0x90\n" \
29610 - "0: rep; movsl\n" \
29611 + "0: rep; "__copyuser_seg"movsl\n" \
29612 " movl %3,%0\n" \
29613 - "1: rep; movsb\n" \
29614 + "1: rep; "__copyuser_seg"movsb\n" \
29615 "2:\n" \
29616 ".section .fixup,\"ax\"\n" \
29617 "5: addl %3,%0\n" \
29618 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29619 {
29620 stac();
29621 if (movsl_is_ok(to, from, n))
29622 - __copy_user(to, from, n);
29623 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29624 else
29625 - n = __copy_user_intel(to, from, n);
29626 + n = __generic_copy_to_user_intel(to, from, n);
29627 clac();
29628 return n;
29629 }
29630 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29631 {
29632 stac();
29633 if (movsl_is_ok(to, from, n))
29634 - __copy_user(to, from, n);
29635 + __copy_user(to, from, n, __copyuser_seg, "", "");
29636 else
29637 - n = __copy_user_intel((void __user *)to,
29638 - (const void *)from, n);
29639 + n = __generic_copy_from_user_intel(to, from, n);
29640 clac();
29641 return n;
29642 }
29643 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29644 if (n > 64 && cpu_has_xmm2)
29645 n = __copy_user_intel_nocache(to, from, n);
29646 else
29647 - __copy_user(to, from, n);
29648 + __copy_user(to, from, n, __copyuser_seg, "", "");
29649 #else
29650 - __copy_user(to, from, n);
29651 + __copy_user(to, from, n, __copyuser_seg, "", "");
29652 #endif
29653 clac();
29654 return n;
29655 }
29656 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29657
29658 -/**
29659 - * copy_to_user: - Copy a block of data into user space.
29660 - * @to: Destination address, in user space.
29661 - * @from: Source address, in kernel space.
29662 - * @n: Number of bytes to copy.
29663 - *
29664 - * Context: User context only. This function may sleep.
29665 - *
29666 - * Copy data from kernel space to user space.
29667 - *
29668 - * Returns number of bytes that could not be copied.
29669 - * On success, this will be zero.
29670 - */
29671 -unsigned long
29672 -copy_to_user(void __user *to, const void *from, unsigned long n)
29673 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29674 +void __set_fs(mm_segment_t x)
29675 {
29676 - if (access_ok(VERIFY_WRITE, to, n))
29677 - n = __copy_to_user(to, from, n);
29678 - return n;
29679 + switch (x.seg) {
29680 + case 0:
29681 + loadsegment(gs, 0);
29682 + break;
29683 + case TASK_SIZE_MAX:
29684 + loadsegment(gs, __USER_DS);
29685 + break;
29686 + case -1UL:
29687 + loadsegment(gs, __KERNEL_DS);
29688 + break;
29689 + default:
29690 + BUG();
29691 + }
29692 }
29693 -EXPORT_SYMBOL(copy_to_user);
29694 +EXPORT_SYMBOL(__set_fs);
29695
29696 -/**
29697 - * copy_from_user: - Copy a block of data from user space.
29698 - * @to: Destination address, in kernel space.
29699 - * @from: Source address, in user space.
29700 - * @n: Number of bytes to copy.
29701 - *
29702 - * Context: User context only. This function may sleep.
29703 - *
29704 - * Copy data from user space to kernel space.
29705 - *
29706 - * Returns number of bytes that could not be copied.
29707 - * On success, this will be zero.
29708 - *
29709 - * If some data could not be copied, this function will pad the copied
29710 - * data to the requested size using zero bytes.
29711 - */
29712 -unsigned long
29713 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29714 +void set_fs(mm_segment_t x)
29715 {
29716 - if (access_ok(VERIFY_READ, from, n))
29717 - n = __copy_from_user(to, from, n);
29718 - else
29719 - memset(to, 0, n);
29720 - return n;
29721 + current_thread_info()->addr_limit = x;
29722 + __set_fs(x);
29723 }
29724 -EXPORT_SYMBOL(_copy_from_user);
29725 +EXPORT_SYMBOL(set_fs);
29726 +#endif
29727 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29728 index c905e89..01ab928 100644
29729 --- a/arch/x86/lib/usercopy_64.c
29730 +++ b/arch/x86/lib/usercopy_64.c
29731 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29732 might_fault();
29733 /* no memory constraint because it doesn't change any memory gcc knows
29734 about */
29735 + pax_open_userland();
29736 stac();
29737 asm volatile(
29738 " testq %[size8],%[size8]\n"
29739 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29740 _ASM_EXTABLE(0b,3b)
29741 _ASM_EXTABLE(1b,2b)
29742 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29743 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29744 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29745 [zero] "r" (0UL), [eight] "r" (8UL));
29746 clac();
29747 + pax_close_userland();
29748 return size;
29749 }
29750 EXPORT_SYMBOL(__clear_user);
29751 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29752 }
29753 EXPORT_SYMBOL(clear_user);
29754
29755 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29756 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29757 {
29758 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29759 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29760 - }
29761 - return len;
29762 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29763 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29764 + return len;
29765 }
29766 EXPORT_SYMBOL(copy_in_user);
29767
29768 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29769 * it is not necessary to optimize tail handling.
29770 */
29771 __visible unsigned long
29772 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29773 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29774 {
29775 char c;
29776 unsigned zero_len;
29777
29778 + clac();
29779 + pax_close_userland();
29780 for (; len; --len, to++) {
29781 if (__get_user_nocheck(c, from++, sizeof(char)))
29782 break;
29783 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29784 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29785 if (__put_user_nocheck(c, to++, sizeof(char)))
29786 break;
29787 - clac();
29788 return len;
29789 }
29790 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29791 index 23d8e5f..9ccc13a 100644
29792 --- a/arch/x86/mm/Makefile
29793 +++ b/arch/x86/mm/Makefile
29794 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29795 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29796
29797 obj-$(CONFIG_MEMTEST) += memtest.o
29798 +
29799 +quote:="
29800 +obj-$(CONFIG_X86_64) += uderef_64.o
29801 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29802 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29803 index 903ec1e..c4166b2 100644
29804 --- a/arch/x86/mm/extable.c
29805 +++ b/arch/x86/mm/extable.c
29806 @@ -6,12 +6,24 @@
29807 static inline unsigned long
29808 ex_insn_addr(const struct exception_table_entry *x)
29809 {
29810 - return (unsigned long)&x->insn + x->insn;
29811 + unsigned long reloc = 0;
29812 +
29813 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29814 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29815 +#endif
29816 +
29817 + return (unsigned long)&x->insn + x->insn + reloc;
29818 }
29819 static inline unsigned long
29820 ex_fixup_addr(const struct exception_table_entry *x)
29821 {
29822 - return (unsigned long)&x->fixup + x->fixup;
29823 + unsigned long reloc = 0;
29824 +
29825 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29826 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29827 +#endif
29828 +
29829 + return (unsigned long)&x->fixup + x->fixup + reloc;
29830 }
29831
29832 int fixup_exception(struct pt_regs *regs)
29833 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29834 unsigned long new_ip;
29835
29836 #ifdef CONFIG_PNPBIOS
29837 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29838 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29839 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29840 extern u32 pnp_bios_is_utter_crap;
29841 pnp_bios_is_utter_crap = 1;
29842 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29843 i += 4;
29844 p->fixup -= i;
29845 i += 4;
29846 +
29847 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29848 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29849 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29850 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29851 +#endif
29852 +
29853 }
29854 }
29855
29856 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29857 index 3aaeffc..42ea9fb 100644
29858 --- a/arch/x86/mm/fault.c
29859 +++ b/arch/x86/mm/fault.c
29860 @@ -14,11 +14,18 @@
29861 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29862 #include <linux/prefetch.h> /* prefetchw */
29863 #include <linux/context_tracking.h> /* exception_enter(), ... */
29864 +#include <linux/unistd.h>
29865 +#include <linux/compiler.h>
29866
29867 #include <asm/traps.h> /* dotraplinkage, ... */
29868 #include <asm/pgalloc.h> /* pgd_*(), ... */
29869 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29870 #include <asm/fixmap.h> /* VSYSCALL_START */
29871 +#include <asm/tlbflush.h>
29872 +
29873 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29874 +#include <asm/stacktrace.h>
29875 +#endif
29876
29877 /*
29878 * Page fault error code bits:
29879 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29880 int ret = 0;
29881
29882 /* kprobe_running() needs smp_processor_id() */
29883 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29884 + if (kprobes_built_in() && !user_mode(regs)) {
29885 preempt_disable();
29886 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29887 ret = 1;
29888 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29889 return !instr_lo || (instr_lo>>1) == 1;
29890 case 0x00:
29891 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29892 - if (probe_kernel_address(instr, opcode))
29893 + if (user_mode(regs)) {
29894 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29895 + return 0;
29896 + } else if (probe_kernel_address(instr, opcode))
29897 return 0;
29898
29899 *prefetch = (instr_lo == 0xF) &&
29900 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29901 while (instr < max_instr) {
29902 unsigned char opcode;
29903
29904 - if (probe_kernel_address(instr, opcode))
29905 + if (user_mode(regs)) {
29906 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29907 + break;
29908 + } else if (probe_kernel_address(instr, opcode))
29909 break;
29910
29911 instr++;
29912 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29913 force_sig_info(si_signo, &info, tsk);
29914 }
29915
29916 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29917 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29918 +#endif
29919 +
29920 +#ifdef CONFIG_PAX_EMUTRAMP
29921 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29922 +#endif
29923 +
29924 +#ifdef CONFIG_PAX_PAGEEXEC
29925 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29926 +{
29927 + pgd_t *pgd;
29928 + pud_t *pud;
29929 + pmd_t *pmd;
29930 +
29931 + pgd = pgd_offset(mm, address);
29932 + if (!pgd_present(*pgd))
29933 + return NULL;
29934 + pud = pud_offset(pgd, address);
29935 + if (!pud_present(*pud))
29936 + return NULL;
29937 + pmd = pmd_offset(pud, address);
29938 + if (!pmd_present(*pmd))
29939 + return NULL;
29940 + return pmd;
29941 +}
29942 +#endif
29943 +
29944 DEFINE_SPINLOCK(pgd_lock);
29945 LIST_HEAD(pgd_list);
29946
29947 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29948 for (address = VMALLOC_START & PMD_MASK;
29949 address >= TASK_SIZE && address < FIXADDR_TOP;
29950 address += PMD_SIZE) {
29951 +
29952 +#ifdef CONFIG_PAX_PER_CPU_PGD
29953 + unsigned long cpu;
29954 +#else
29955 struct page *page;
29956 +#endif
29957
29958 spin_lock(&pgd_lock);
29959 +
29960 +#ifdef CONFIG_PAX_PER_CPU_PGD
29961 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29962 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29963 + pmd_t *ret;
29964 +
29965 + ret = vmalloc_sync_one(pgd, address);
29966 + if (!ret)
29967 + break;
29968 + pgd = get_cpu_pgd(cpu, kernel);
29969 +#else
29970 list_for_each_entry(page, &pgd_list, lru) {
29971 + pgd_t *pgd;
29972 spinlock_t *pgt_lock;
29973 pmd_t *ret;
29974
29975 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29976 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29977
29978 spin_lock(pgt_lock);
29979 - ret = vmalloc_sync_one(page_address(page), address);
29980 + pgd = page_address(page);
29981 +#endif
29982 +
29983 + ret = vmalloc_sync_one(pgd, address);
29984 +
29985 +#ifndef CONFIG_PAX_PER_CPU_PGD
29986 spin_unlock(pgt_lock);
29987 +#endif
29988
29989 if (!ret)
29990 break;
29991 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29992 * an interrupt in the middle of a task switch..
29993 */
29994 pgd_paddr = read_cr3();
29995 +
29996 +#ifdef CONFIG_PAX_PER_CPU_PGD
29997 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29998 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29999 +#endif
30000 +
30001 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30002 if (!pmd_k)
30003 return -1;
30004 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30005 * happen within a race in page table update. In the later
30006 * case just flush:
30007 */
30008 - pgd = pgd_offset(current->active_mm, address);
30009 +
30010 pgd_ref = pgd_offset_k(address);
30011 if (pgd_none(*pgd_ref))
30012 return -1;
30013
30014 +#ifdef CONFIG_PAX_PER_CPU_PGD
30015 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30016 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30017 + if (pgd_none(*pgd)) {
30018 + set_pgd(pgd, *pgd_ref);
30019 + arch_flush_lazy_mmu_mode();
30020 + } else {
30021 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30022 + }
30023 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30024 +#else
30025 + pgd = pgd_offset(current->active_mm, address);
30026 +#endif
30027 +
30028 if (pgd_none(*pgd)) {
30029 set_pgd(pgd, *pgd_ref);
30030 arch_flush_lazy_mmu_mode();
30031 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30032 static int is_errata100(struct pt_regs *regs, unsigned long address)
30033 {
30034 #ifdef CONFIG_X86_64
30035 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30036 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30037 return 1;
30038 #endif
30039 return 0;
30040 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30041 }
30042
30043 static const char nx_warning[] = KERN_CRIT
30044 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30045 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30046
30047 static void
30048 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30049 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30050 if (!oops_may_print())
30051 return;
30052
30053 - if (error_code & PF_INSTR) {
30054 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30055 unsigned int level;
30056
30057 pte_t *pte = lookup_address(address, &level);
30058
30059 if (pte && pte_present(*pte) && !pte_exec(*pte))
30060 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30061 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30062 }
30063
30064 +#ifdef CONFIG_PAX_KERNEXEC
30065 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30066 + if (current->signal->curr_ip)
30067 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30068 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30069 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30070 + else
30071 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30072 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30073 + }
30074 +#endif
30075 +
30076 printk(KERN_ALERT "BUG: unable to handle kernel ");
30077 if (address < PAGE_SIZE)
30078 printk(KERN_CONT "NULL pointer dereference");
30079 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30080 return;
30081 }
30082 #endif
30083 +
30084 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30085 + if (pax_is_fetch_fault(regs, error_code, address)) {
30086 +
30087 +#ifdef CONFIG_PAX_EMUTRAMP
30088 + switch (pax_handle_fetch_fault(regs)) {
30089 + case 2:
30090 + return;
30091 + }
30092 +#endif
30093 +
30094 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30095 + do_group_exit(SIGKILL);
30096 + }
30097 +#endif
30098 +
30099 /* Kernel addresses are always protection faults: */
30100 if (address >= TASK_SIZE)
30101 error_code |= PF_PROT;
30102 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30103 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30104 printk(KERN_ERR
30105 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30106 - tsk->comm, tsk->pid, address);
30107 + tsk->comm, task_pid_nr(tsk), address);
30108 code = BUS_MCEERR_AR;
30109 }
30110 #endif
30111 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30112 return 1;
30113 }
30114
30115 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30116 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30117 +{
30118 + pte_t *pte;
30119 + pmd_t *pmd;
30120 + spinlock_t *ptl;
30121 + unsigned char pte_mask;
30122 +
30123 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30124 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30125 + return 0;
30126 +
30127 + /* PaX: it's our fault, let's handle it if we can */
30128 +
30129 + /* PaX: take a look at read faults before acquiring any locks */
30130 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30131 + /* instruction fetch attempt from a protected page in user mode */
30132 + up_read(&mm->mmap_sem);
30133 +
30134 +#ifdef CONFIG_PAX_EMUTRAMP
30135 + switch (pax_handle_fetch_fault(regs)) {
30136 + case 2:
30137 + return 1;
30138 + }
30139 +#endif
30140 +
30141 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30142 + do_group_exit(SIGKILL);
30143 + }
30144 +
30145 + pmd = pax_get_pmd(mm, address);
30146 + if (unlikely(!pmd))
30147 + return 0;
30148 +
30149 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30150 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30151 + pte_unmap_unlock(pte, ptl);
30152 + return 0;
30153 + }
30154 +
30155 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30156 + /* write attempt to a protected page in user mode */
30157 + pte_unmap_unlock(pte, ptl);
30158 + return 0;
30159 + }
30160 +
30161 +#ifdef CONFIG_SMP
30162 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30163 +#else
30164 + if (likely(address > get_limit(regs->cs)))
30165 +#endif
30166 + {
30167 + set_pte(pte, pte_mkread(*pte));
30168 + __flush_tlb_one(address);
30169 + pte_unmap_unlock(pte, ptl);
30170 + up_read(&mm->mmap_sem);
30171 + return 1;
30172 + }
30173 +
30174 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30175 +
30176 + /*
30177 + * PaX: fill DTLB with user rights and retry
30178 + */
30179 + __asm__ __volatile__ (
30180 + "orb %2,(%1)\n"
30181 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30182 +/*
30183 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30184 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30185 + * page fault when examined during a TLB load attempt. this is true not only
30186 + * for PTEs holding a non-present entry but also present entries that will
30187 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30188 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30189 + * for our target pages since their PTEs are simply not in the TLBs at all.
30190 +
30191 + * the best thing in omitting it is that we gain around 15-20% speed in the
30192 + * fast path of the page fault handler and can get rid of tracing since we
30193 + * can no longer flush unintended entries.
30194 + */
30195 + "invlpg (%0)\n"
30196 +#endif
30197 + __copyuser_seg"testb $0,(%0)\n"
30198 + "xorb %3,(%1)\n"
30199 + :
30200 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30201 + : "memory", "cc");
30202 + pte_unmap_unlock(pte, ptl);
30203 + up_read(&mm->mmap_sem);
30204 + return 1;
30205 +}
30206 +#endif
30207 +
30208 /*
30209 * Handle a spurious fault caused by a stale TLB entry.
30210 *
30211 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30212 static inline int
30213 access_error(unsigned long error_code, struct vm_area_struct *vma)
30214 {
30215 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30216 + return 1;
30217 +
30218 if (error_code & PF_WRITE) {
30219 /* write, present and write, not present: */
30220 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30221 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30222 if (error_code & PF_USER)
30223 return false;
30224
30225 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30226 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30227 return false;
30228
30229 return true;
30230 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30231 /* Get the faulting address: */
30232 address = read_cr2();
30233
30234 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30235 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30236 + if (!search_exception_tables(regs->ip)) {
30237 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30238 + bad_area_nosemaphore(regs, error_code, address);
30239 + return;
30240 + }
30241 + if (address < pax_user_shadow_base) {
30242 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30243 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30244 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30245 + } else
30246 + address -= pax_user_shadow_base;
30247 + }
30248 +#endif
30249 +
30250 /*
30251 * Detect and handle instructions that would cause a page fault for
30252 * both a tracked kernel page and a userspace page.
30253 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30254 * User-mode registers count as a user access even for any
30255 * potential system fault or CPU buglet:
30256 */
30257 - if (user_mode_vm(regs)) {
30258 + if (user_mode(regs)) {
30259 local_irq_enable();
30260 error_code |= PF_USER;
30261 flags |= FAULT_FLAG_USER;
30262 @@ -1135,6 +1359,11 @@ retry:
30263 might_sleep();
30264 }
30265
30266 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30267 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30268 + return;
30269 +#endif
30270 +
30271 vma = find_vma(mm, address);
30272 if (unlikely(!vma)) {
30273 bad_area(regs, error_code, address);
30274 @@ -1146,18 +1375,24 @@ retry:
30275 bad_area(regs, error_code, address);
30276 return;
30277 }
30278 - if (error_code & PF_USER) {
30279 - /*
30280 - * Accessing the stack below %sp is always a bug.
30281 - * The large cushion allows instructions like enter
30282 - * and pusha to work. ("enter $65535, $31" pushes
30283 - * 32 pointers and then decrements %sp by 65535.)
30284 - */
30285 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30286 - bad_area(regs, error_code, address);
30287 - return;
30288 - }
30289 + /*
30290 + * Accessing the stack below %sp is always a bug.
30291 + * The large cushion allows instructions like enter
30292 + * and pusha to work. ("enter $65535, $31" pushes
30293 + * 32 pointers and then decrements %sp by 65535.)
30294 + */
30295 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30296 + bad_area(regs, error_code, address);
30297 + return;
30298 }
30299 +
30300 +#ifdef CONFIG_PAX_SEGMEXEC
30301 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30302 + bad_area(regs, error_code, address);
30303 + return;
30304 + }
30305 +#endif
30306 +
30307 if (unlikely(expand_stack(vma, address))) {
30308 bad_area(regs, error_code, address);
30309 return;
30310 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30311 __do_page_fault(regs, error_code);
30312 exception_exit(prev_state);
30313 }
30314 +
30315 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30316 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30317 +{
30318 + struct mm_struct *mm = current->mm;
30319 + unsigned long ip = regs->ip;
30320 +
30321 + if (v8086_mode(regs))
30322 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30323 +
30324 +#ifdef CONFIG_PAX_PAGEEXEC
30325 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30326 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30327 + return true;
30328 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30329 + return true;
30330 + return false;
30331 + }
30332 +#endif
30333 +
30334 +#ifdef CONFIG_PAX_SEGMEXEC
30335 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30336 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30337 + return true;
30338 + return false;
30339 + }
30340 +#endif
30341 +
30342 + return false;
30343 +}
30344 +#endif
30345 +
30346 +#ifdef CONFIG_PAX_EMUTRAMP
30347 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30348 +{
30349 + int err;
30350 +
30351 + do { /* PaX: libffi trampoline emulation */
30352 + unsigned char mov, jmp;
30353 + unsigned int addr1, addr2;
30354 +
30355 +#ifdef CONFIG_X86_64
30356 + if ((regs->ip + 9) >> 32)
30357 + break;
30358 +#endif
30359 +
30360 + err = get_user(mov, (unsigned char __user *)regs->ip);
30361 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30362 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30363 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30364 +
30365 + if (err)
30366 + break;
30367 +
30368 + if (mov == 0xB8 && jmp == 0xE9) {
30369 + regs->ax = addr1;
30370 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30371 + return 2;
30372 + }
30373 + } while (0);
30374 +
30375 + do { /* PaX: gcc trampoline emulation #1 */
30376 + unsigned char mov1, mov2;
30377 + unsigned short jmp;
30378 + unsigned int addr1, addr2;
30379 +
30380 +#ifdef CONFIG_X86_64
30381 + if ((regs->ip + 11) >> 32)
30382 + break;
30383 +#endif
30384 +
30385 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30386 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30387 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30388 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30389 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30390 +
30391 + if (err)
30392 + break;
30393 +
30394 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30395 + regs->cx = addr1;
30396 + regs->ax = addr2;
30397 + regs->ip = addr2;
30398 + return 2;
30399 + }
30400 + } while (0);
30401 +
30402 + do { /* PaX: gcc trampoline emulation #2 */
30403 + unsigned char mov, jmp;
30404 + unsigned int addr1, addr2;
30405 +
30406 +#ifdef CONFIG_X86_64
30407 + if ((regs->ip + 9) >> 32)
30408 + break;
30409 +#endif
30410 +
30411 + err = get_user(mov, (unsigned char __user *)regs->ip);
30412 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30413 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30414 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30415 +
30416 + if (err)
30417 + break;
30418 +
30419 + if (mov == 0xB9 && jmp == 0xE9) {
30420 + regs->cx = addr1;
30421 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30422 + return 2;
30423 + }
30424 + } while (0);
30425 +
30426 + return 1; /* PaX in action */
30427 +}
30428 +
30429 +#ifdef CONFIG_X86_64
30430 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30431 +{
30432 + int err;
30433 +
30434 + do { /* PaX: libffi trampoline emulation */
30435 + unsigned short mov1, mov2, jmp1;
30436 + unsigned char stcclc, jmp2;
30437 + unsigned long addr1, addr2;
30438 +
30439 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30440 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30441 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30442 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30443 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30444 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30445 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30446 +
30447 + if (err)
30448 + break;
30449 +
30450 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30451 + regs->r11 = addr1;
30452 + regs->r10 = addr2;
30453 + if (stcclc == 0xF8)
30454 + regs->flags &= ~X86_EFLAGS_CF;
30455 + else
30456 + regs->flags |= X86_EFLAGS_CF;
30457 + regs->ip = addr1;
30458 + return 2;
30459 + }
30460 + } while (0);
30461 +
30462 + do { /* PaX: gcc trampoline emulation #1 */
30463 + unsigned short mov1, mov2, jmp1;
30464 + unsigned char jmp2;
30465 + unsigned int addr1;
30466 + unsigned long addr2;
30467 +
30468 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30469 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30470 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30471 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30472 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30473 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30474 +
30475 + if (err)
30476 + break;
30477 +
30478 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30479 + regs->r11 = addr1;
30480 + regs->r10 = addr2;
30481 + regs->ip = addr1;
30482 + return 2;
30483 + }
30484 + } while (0);
30485 +
30486 + do { /* PaX: gcc trampoline emulation #2 */
30487 + unsigned short mov1, mov2, jmp1;
30488 + unsigned char jmp2;
30489 + unsigned long addr1, addr2;
30490 +
30491 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30492 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30493 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30494 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30495 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30496 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30497 +
30498 + if (err)
30499 + break;
30500 +
30501 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30502 + regs->r11 = addr1;
30503 + regs->r10 = addr2;
30504 + regs->ip = addr1;
30505 + return 2;
30506 + }
30507 + } while (0);
30508 +
30509 + return 1; /* PaX in action */
30510 +}
30511 +#endif
30512 +
30513 +/*
30514 + * PaX: decide what to do with offenders (regs->ip = fault address)
30515 + *
30516 + * returns 1 when task should be killed
30517 + * 2 when gcc trampoline was detected
30518 + */
30519 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30520 +{
30521 + if (v8086_mode(regs))
30522 + return 1;
30523 +
30524 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30525 + return 1;
30526 +
30527 +#ifdef CONFIG_X86_32
30528 + return pax_handle_fetch_fault_32(regs);
30529 +#else
30530 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30531 + return pax_handle_fetch_fault_32(regs);
30532 + else
30533 + return pax_handle_fetch_fault_64(regs);
30534 +#endif
30535 +}
30536 +#endif
30537 +
30538 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30539 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30540 +{
30541 + long i;
30542 +
30543 + printk(KERN_ERR "PAX: bytes at PC: ");
30544 + for (i = 0; i < 20; i++) {
30545 + unsigned char c;
30546 + if (get_user(c, (unsigned char __force_user *)pc+i))
30547 + printk(KERN_CONT "?? ");
30548 + else
30549 + printk(KERN_CONT "%02x ", c);
30550 + }
30551 + printk("\n");
30552 +
30553 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30554 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30555 + unsigned long c;
30556 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30557 +#ifdef CONFIG_X86_32
30558 + printk(KERN_CONT "???????? ");
30559 +#else
30560 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30561 + printk(KERN_CONT "???????? ???????? ");
30562 + else
30563 + printk(KERN_CONT "???????????????? ");
30564 +#endif
30565 + } else {
30566 +#ifdef CONFIG_X86_64
30567 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30568 + printk(KERN_CONT "%08x ", (unsigned int)c);
30569 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30570 + } else
30571 +#endif
30572 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30573 + }
30574 + }
30575 + printk("\n");
30576 +}
30577 +#endif
30578 +
30579 +/**
30580 + * probe_kernel_write(): safely attempt to write to a location
30581 + * @dst: address to write to
30582 + * @src: pointer to the data that shall be written
30583 + * @size: size of the data chunk
30584 + *
30585 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30586 + * happens, handle that and return -EFAULT.
30587 + */
30588 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30589 +{
30590 + long ret;
30591 + mm_segment_t old_fs = get_fs();
30592 +
30593 + set_fs(KERNEL_DS);
30594 + pagefault_disable();
30595 + pax_open_kernel();
30596 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30597 + pax_close_kernel();
30598 + pagefault_enable();
30599 + set_fs(old_fs);
30600 +
30601 + return ret ? -EFAULT : 0;
30602 +}
30603 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30604 index dd74e46..7d26398 100644
30605 --- a/arch/x86/mm/gup.c
30606 +++ b/arch/x86/mm/gup.c
30607 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30608 addr = start;
30609 len = (unsigned long) nr_pages << PAGE_SHIFT;
30610 end = start + len;
30611 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30612 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30613 (void __user *)start, len)))
30614 return 0;
30615
30616 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30617 index 4500142..53a363c 100644
30618 --- a/arch/x86/mm/highmem_32.c
30619 +++ b/arch/x86/mm/highmem_32.c
30620 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30621 idx = type + KM_TYPE_NR*smp_processor_id();
30622 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30623 BUG_ON(!pte_none(*(kmap_pte-idx)));
30624 +
30625 + pax_open_kernel();
30626 set_pte(kmap_pte-idx, mk_pte(page, prot));
30627 + pax_close_kernel();
30628 +
30629 arch_flush_lazy_mmu_mode();
30630
30631 return (void *)vaddr;
30632 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30633 index 9d980d8..6bbfacb 100644
30634 --- a/arch/x86/mm/hugetlbpage.c
30635 +++ b/arch/x86/mm/hugetlbpage.c
30636 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
30637 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30638 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30639 unsigned long addr, unsigned long len,
30640 - unsigned long pgoff, unsigned long flags)
30641 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30642 {
30643 struct hstate *h = hstate_file(file);
30644 struct vm_unmapped_area_info info;
30645 -
30646 +
30647 info.flags = 0;
30648 info.length = len;
30649 info.low_limit = TASK_UNMAPPED_BASE;
30650 +
30651 +#ifdef CONFIG_PAX_RANDMMAP
30652 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30653 + info.low_limit += current->mm->delta_mmap;
30654 +#endif
30655 +
30656 info.high_limit = TASK_SIZE;
30657 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30658 info.align_offset = 0;
30659 + info.threadstack_offset = offset;
30660 return vm_unmapped_area(&info);
30661 }
30662
30663 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30664 unsigned long addr0, unsigned long len,
30665 - unsigned long pgoff, unsigned long flags)
30666 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30667 {
30668 struct hstate *h = hstate_file(file);
30669 struct vm_unmapped_area_info info;
30670 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30671 info.high_limit = current->mm->mmap_base;
30672 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30673 info.align_offset = 0;
30674 + info.threadstack_offset = offset;
30675 addr = vm_unmapped_area(&info);
30676
30677 /*
30678 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30679 VM_BUG_ON(addr != -ENOMEM);
30680 info.flags = 0;
30681 info.low_limit = TASK_UNMAPPED_BASE;
30682 +
30683 +#ifdef CONFIG_PAX_RANDMMAP
30684 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30685 + info.low_limit += current->mm->delta_mmap;
30686 +#endif
30687 +
30688 info.high_limit = TASK_SIZE;
30689 addr = vm_unmapped_area(&info);
30690 }
30691 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30692 struct hstate *h = hstate_file(file);
30693 struct mm_struct *mm = current->mm;
30694 struct vm_area_struct *vma;
30695 + unsigned long pax_task_size = TASK_SIZE;
30696 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30697
30698 if (len & ~huge_page_mask(h))
30699 return -EINVAL;
30700 - if (len > TASK_SIZE)
30701 +
30702 +#ifdef CONFIG_PAX_SEGMEXEC
30703 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30704 + pax_task_size = SEGMEXEC_TASK_SIZE;
30705 +#endif
30706 +
30707 + pax_task_size -= PAGE_SIZE;
30708 +
30709 + if (len > pax_task_size)
30710 return -ENOMEM;
30711
30712 if (flags & MAP_FIXED) {
30713 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30714 return addr;
30715 }
30716
30717 +#ifdef CONFIG_PAX_RANDMMAP
30718 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30719 +#endif
30720 +
30721 if (addr) {
30722 addr = ALIGN(addr, huge_page_size(h));
30723 vma = find_vma(mm, addr);
30724 - if (TASK_SIZE - len >= addr &&
30725 - (!vma || addr + len <= vma->vm_start))
30726 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30727 return addr;
30728 }
30729 if (mm->get_unmapped_area == arch_get_unmapped_area)
30730 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30731 - pgoff, flags);
30732 + pgoff, flags, offset);
30733 else
30734 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30735 - pgoff, flags);
30736 + pgoff, flags, offset);
30737 }
30738
30739 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30740 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30741 index 04664cd..dae6e5d 100644
30742 --- a/arch/x86/mm/init.c
30743 +++ b/arch/x86/mm/init.c
30744 @@ -4,6 +4,7 @@
30745 #include <linux/swap.h>
30746 #include <linux/memblock.h>
30747 #include <linux/bootmem.h> /* for max_low_pfn */
30748 +#include <linux/tboot.h>
30749
30750 #include <asm/cacheflush.h>
30751 #include <asm/e820.h>
30752 @@ -17,6 +18,8 @@
30753 #include <asm/proto.h>
30754 #include <asm/dma.h> /* for MAX_DMA_PFN */
30755 #include <asm/microcode.h>
30756 +#include <asm/desc.h>
30757 +#include <asm/bios_ebda.h>
30758
30759 #include "mm_internal.h"
30760
30761 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30762 early_ioremap_page_table_range_init();
30763 #endif
30764
30765 +#ifdef CONFIG_PAX_PER_CPU_PGD
30766 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30767 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30768 + KERNEL_PGD_PTRS);
30769 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30770 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30771 + KERNEL_PGD_PTRS);
30772 + load_cr3(get_cpu_pgd(0, kernel));
30773 +#else
30774 load_cr3(swapper_pg_dir);
30775 +#endif
30776 +
30777 __flush_tlb_all();
30778
30779 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30780 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30781 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30782 * mmio resources as well as potential bios/acpi data regions.
30783 */
30784 +
30785 +#ifdef CONFIG_GRKERNSEC_KMEM
30786 +static unsigned int ebda_start __read_only;
30787 +static unsigned int ebda_end __read_only;
30788 +#endif
30789 +
30790 int devmem_is_allowed(unsigned long pagenr)
30791 {
30792 - if (pagenr < 256)
30793 +#ifdef CONFIG_GRKERNSEC_KMEM
30794 + /* allow BDA */
30795 + if (!pagenr)
30796 return 1;
30797 + /* allow EBDA */
30798 + if (pagenr >= ebda_start && pagenr < ebda_end)
30799 + return 1;
30800 + /* if tboot is in use, allow access to its hardcoded serial log range */
30801 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30802 + return 1;
30803 +#else
30804 + if (!pagenr)
30805 + return 1;
30806 +#ifdef CONFIG_VM86
30807 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30808 + return 1;
30809 +#endif
30810 +#endif
30811 +
30812 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30813 + return 1;
30814 +#ifdef CONFIG_GRKERNSEC_KMEM
30815 + /* throw out everything else below 1MB */
30816 + if (pagenr <= 256)
30817 + return 0;
30818 +#endif
30819 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30820 return 0;
30821 if (!page_is_ram(pagenr))
30822 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30823 #endif
30824 }
30825
30826 +#ifdef CONFIG_GRKERNSEC_KMEM
30827 +static inline void gr_init_ebda(void)
30828 +{
30829 + unsigned int ebda_addr;
30830 + unsigned int ebda_size = 0;
30831 +
30832 + ebda_addr = get_bios_ebda();
30833 + if (ebda_addr) {
30834 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30835 + ebda_size <<= 10;
30836 + }
30837 + if (ebda_addr && ebda_size) {
30838 + ebda_start = ebda_addr >> PAGE_SHIFT;
30839 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30840 + } else {
30841 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30842 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30843 + }
30844 +}
30845 +#else
30846 +static inline void gr_init_ebda(void) { }
30847 +#endif
30848 +
30849 void free_initmem(void)
30850 {
30851 +#ifdef CONFIG_PAX_KERNEXEC
30852 +#ifdef CONFIG_X86_32
30853 + /* PaX: limit KERNEL_CS to actual size */
30854 + unsigned long addr, limit;
30855 + struct desc_struct d;
30856 + int cpu;
30857 +#else
30858 + pgd_t *pgd;
30859 + pud_t *pud;
30860 + pmd_t *pmd;
30861 + unsigned long addr, end;
30862 +#endif
30863 +#endif
30864 +
30865 + gr_init_ebda();
30866 +
30867 +#ifdef CONFIG_PAX_KERNEXEC
30868 +#ifdef CONFIG_X86_32
30869 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30870 + limit = (limit - 1UL) >> PAGE_SHIFT;
30871 +
30872 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30873 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30874 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30875 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30876 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30877 + }
30878 +
30879 + /* PaX: make KERNEL_CS read-only */
30880 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30881 + if (!paravirt_enabled())
30882 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30883 +/*
30884 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30885 + pgd = pgd_offset_k(addr);
30886 + pud = pud_offset(pgd, addr);
30887 + pmd = pmd_offset(pud, addr);
30888 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30889 + }
30890 +*/
30891 +#ifdef CONFIG_X86_PAE
30892 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30893 +/*
30894 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30895 + pgd = pgd_offset_k(addr);
30896 + pud = pud_offset(pgd, addr);
30897 + pmd = pmd_offset(pud, addr);
30898 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30899 + }
30900 +*/
30901 +#endif
30902 +
30903 +#ifdef CONFIG_MODULES
30904 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30905 +#endif
30906 +
30907 +#else
30908 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30909 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30910 + pgd = pgd_offset_k(addr);
30911 + pud = pud_offset(pgd, addr);
30912 + pmd = pmd_offset(pud, addr);
30913 + if (!pmd_present(*pmd))
30914 + continue;
30915 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30916 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30917 + else
30918 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30919 + }
30920 +
30921 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30922 + end = addr + KERNEL_IMAGE_SIZE;
30923 + for (; addr < end; addr += PMD_SIZE) {
30924 + pgd = pgd_offset_k(addr);
30925 + pud = pud_offset(pgd, addr);
30926 + pmd = pmd_offset(pud, addr);
30927 + if (!pmd_present(*pmd))
30928 + continue;
30929 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30930 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30931 + }
30932 +#endif
30933 +
30934 + flush_tlb_all();
30935 +#endif
30936 +
30937 free_init_pages("unused kernel",
30938 (unsigned long)(&__init_begin),
30939 (unsigned long)(&__init_end));
30940 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30941 index 4287f1f..3b99c71 100644
30942 --- a/arch/x86/mm/init_32.c
30943 +++ b/arch/x86/mm/init_32.c
30944 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30945 bool __read_mostly __vmalloc_start_set = false;
30946
30947 /*
30948 - * Creates a middle page table and puts a pointer to it in the
30949 - * given global directory entry. This only returns the gd entry
30950 - * in non-PAE compilation mode, since the middle layer is folded.
30951 - */
30952 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30953 -{
30954 - pud_t *pud;
30955 - pmd_t *pmd_table;
30956 -
30957 -#ifdef CONFIG_X86_PAE
30958 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30959 - pmd_table = (pmd_t *)alloc_low_page();
30960 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30961 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30962 - pud = pud_offset(pgd, 0);
30963 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30964 -
30965 - return pmd_table;
30966 - }
30967 -#endif
30968 - pud = pud_offset(pgd, 0);
30969 - pmd_table = pmd_offset(pud, 0);
30970 -
30971 - return pmd_table;
30972 -}
30973 -
30974 -/*
30975 * Create a page table and place a pointer to it in a middle page
30976 * directory entry:
30977 */
30978 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30979 pte_t *page_table = (pte_t *)alloc_low_page();
30980
30981 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30982 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30983 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30984 +#else
30985 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30986 +#endif
30987 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30988 }
30989
30990 return pte_offset_kernel(pmd, 0);
30991 }
30992
30993 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30994 +{
30995 + pud_t *pud;
30996 + pmd_t *pmd_table;
30997 +
30998 + pud = pud_offset(pgd, 0);
30999 + pmd_table = pmd_offset(pud, 0);
31000 +
31001 + return pmd_table;
31002 +}
31003 +
31004 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31005 {
31006 int pgd_idx = pgd_index(vaddr);
31007 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31008 int pgd_idx, pmd_idx;
31009 unsigned long vaddr;
31010 pgd_t *pgd;
31011 + pud_t *pud;
31012 pmd_t *pmd;
31013 pte_t *pte = NULL;
31014 unsigned long count = page_table_range_init_count(start, end);
31015 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31016 pgd = pgd_base + pgd_idx;
31017
31018 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31019 - pmd = one_md_table_init(pgd);
31020 - pmd = pmd + pmd_index(vaddr);
31021 + pud = pud_offset(pgd, vaddr);
31022 + pmd = pmd_offset(pud, vaddr);
31023 +
31024 +#ifdef CONFIG_X86_PAE
31025 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31026 +#endif
31027 +
31028 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31029 pmd++, pmd_idx++) {
31030 pte = page_table_kmap_check(one_page_table_init(pmd),
31031 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31032 }
31033 }
31034
31035 -static inline int is_kernel_text(unsigned long addr)
31036 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31037 {
31038 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31039 - return 1;
31040 - return 0;
31041 + if ((start > ktla_ktva((unsigned long)_etext) ||
31042 + end <= ktla_ktva((unsigned long)_stext)) &&
31043 + (start > ktla_ktva((unsigned long)_einittext) ||
31044 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31045 +
31046 +#ifdef CONFIG_ACPI_SLEEP
31047 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31048 +#endif
31049 +
31050 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31051 + return 0;
31052 + return 1;
31053 }
31054
31055 /*
31056 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31057 unsigned long last_map_addr = end;
31058 unsigned long start_pfn, end_pfn;
31059 pgd_t *pgd_base = swapper_pg_dir;
31060 - int pgd_idx, pmd_idx, pte_ofs;
31061 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31062 unsigned long pfn;
31063 pgd_t *pgd;
31064 + pud_t *pud;
31065 pmd_t *pmd;
31066 pte_t *pte;
31067 unsigned pages_2m, pages_4k;
31068 @@ -291,8 +295,13 @@ repeat:
31069 pfn = start_pfn;
31070 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31071 pgd = pgd_base + pgd_idx;
31072 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31073 - pmd = one_md_table_init(pgd);
31074 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31075 + pud = pud_offset(pgd, 0);
31076 + pmd = pmd_offset(pud, 0);
31077 +
31078 +#ifdef CONFIG_X86_PAE
31079 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31080 +#endif
31081
31082 if (pfn >= end_pfn)
31083 continue;
31084 @@ -304,14 +313,13 @@ repeat:
31085 #endif
31086 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31087 pmd++, pmd_idx++) {
31088 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31089 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31090
31091 /*
31092 * Map with big pages if possible, otherwise
31093 * create normal page tables:
31094 */
31095 if (use_pse) {
31096 - unsigned int addr2;
31097 pgprot_t prot = PAGE_KERNEL_LARGE;
31098 /*
31099 * first pass will use the same initial
31100 @@ -322,11 +330,7 @@ repeat:
31101 _PAGE_PSE);
31102
31103 pfn &= PMD_MASK >> PAGE_SHIFT;
31104 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31105 - PAGE_OFFSET + PAGE_SIZE-1;
31106 -
31107 - if (is_kernel_text(addr) ||
31108 - is_kernel_text(addr2))
31109 + if (is_kernel_text(address, address + PMD_SIZE))
31110 prot = PAGE_KERNEL_LARGE_EXEC;
31111
31112 pages_2m++;
31113 @@ -343,7 +347,7 @@ repeat:
31114 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31115 pte += pte_ofs;
31116 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31117 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31118 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31119 pgprot_t prot = PAGE_KERNEL;
31120 /*
31121 * first pass will use the same initial
31122 @@ -351,7 +355,7 @@ repeat:
31123 */
31124 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31125
31126 - if (is_kernel_text(addr))
31127 + if (is_kernel_text(address, address + PAGE_SIZE))
31128 prot = PAGE_KERNEL_EXEC;
31129
31130 pages_4k++;
31131 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31132
31133 pud = pud_offset(pgd, va);
31134 pmd = pmd_offset(pud, va);
31135 - if (!pmd_present(*pmd))
31136 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31137 break;
31138
31139 /* should not be large page here */
31140 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31141
31142 static void __init pagetable_init(void)
31143 {
31144 - pgd_t *pgd_base = swapper_pg_dir;
31145 -
31146 - permanent_kmaps_init(pgd_base);
31147 + permanent_kmaps_init(swapper_pg_dir);
31148 }
31149
31150 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31151 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31152 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31153
31154 /* user-defined highmem size */
31155 @@ -787,10 +789,10 @@ void __init mem_init(void)
31156 ((unsigned long)&__init_end -
31157 (unsigned long)&__init_begin) >> 10,
31158
31159 - (unsigned long)&_etext, (unsigned long)&_edata,
31160 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31161 + (unsigned long)&_sdata, (unsigned long)&_edata,
31162 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31163
31164 - (unsigned long)&_text, (unsigned long)&_etext,
31165 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31166 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31167
31168 /*
31169 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31170 if (!kernel_set_to_readonly)
31171 return;
31172
31173 + start = ktla_ktva(start);
31174 pr_debug("Set kernel text: %lx - %lx for read write\n",
31175 start, start+size);
31176
31177 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31178 if (!kernel_set_to_readonly)
31179 return;
31180
31181 + start = ktla_ktva(start);
31182 pr_debug("Set kernel text: %lx - %lx for read only\n",
31183 start, start+size);
31184
31185 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31186 unsigned long start = PFN_ALIGN(_text);
31187 unsigned long size = PFN_ALIGN(_etext) - start;
31188
31189 + start = ktla_ktva(start);
31190 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31191 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31192 size >> 10);
31193 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31194 index 104d56a..62ba13f1 100644
31195 --- a/arch/x86/mm/init_64.c
31196 +++ b/arch/x86/mm/init_64.c
31197 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31198 * around without checking the pgd every time.
31199 */
31200
31201 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31202 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31203 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31204
31205 int force_personality32;
31206 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31207
31208 for (address = start; address <= end; address += PGDIR_SIZE) {
31209 const pgd_t *pgd_ref = pgd_offset_k(address);
31210 +
31211 +#ifdef CONFIG_PAX_PER_CPU_PGD
31212 + unsigned long cpu;
31213 +#else
31214 struct page *page;
31215 +#endif
31216
31217 if (pgd_none(*pgd_ref))
31218 continue;
31219
31220 spin_lock(&pgd_lock);
31221 +
31222 +#ifdef CONFIG_PAX_PER_CPU_PGD
31223 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31224 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31225 +
31226 + if (pgd_none(*pgd))
31227 + set_pgd(pgd, *pgd_ref);
31228 + else
31229 + BUG_ON(pgd_page_vaddr(*pgd)
31230 + != pgd_page_vaddr(*pgd_ref));
31231 + pgd = pgd_offset_cpu(cpu, kernel, address);
31232 +#else
31233 list_for_each_entry(page, &pgd_list, lru) {
31234 pgd_t *pgd;
31235 spinlock_t *pgt_lock;
31236 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31237 /* the pgt_lock only for Xen */
31238 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31239 spin_lock(pgt_lock);
31240 +#endif
31241
31242 if (pgd_none(*pgd))
31243 set_pgd(pgd, *pgd_ref);
31244 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31245 BUG_ON(pgd_page_vaddr(*pgd)
31246 != pgd_page_vaddr(*pgd_ref));
31247
31248 +#ifndef CONFIG_PAX_PER_CPU_PGD
31249 spin_unlock(pgt_lock);
31250 +#endif
31251 +
31252 }
31253 spin_unlock(&pgd_lock);
31254 }
31255 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31256 {
31257 if (pgd_none(*pgd)) {
31258 pud_t *pud = (pud_t *)spp_getpage();
31259 - pgd_populate(&init_mm, pgd, pud);
31260 + pgd_populate_kernel(&init_mm, pgd, pud);
31261 if (pud != pud_offset(pgd, 0))
31262 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31263 pud, pud_offset(pgd, 0));
31264 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31265 {
31266 if (pud_none(*pud)) {
31267 pmd_t *pmd = (pmd_t *) spp_getpage();
31268 - pud_populate(&init_mm, pud, pmd);
31269 + pud_populate_kernel(&init_mm, pud, pmd);
31270 if (pmd != pmd_offset(pud, 0))
31271 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31272 pmd, pmd_offset(pud, 0));
31273 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31274 pmd = fill_pmd(pud, vaddr);
31275 pte = fill_pte(pmd, vaddr);
31276
31277 + pax_open_kernel();
31278 set_pte(pte, new_pte);
31279 + pax_close_kernel();
31280
31281 /*
31282 * It's enough to flush this one mapping.
31283 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31284 pgd = pgd_offset_k((unsigned long)__va(phys));
31285 if (pgd_none(*pgd)) {
31286 pud = (pud_t *) spp_getpage();
31287 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31288 - _PAGE_USER));
31289 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31290 }
31291 pud = pud_offset(pgd, (unsigned long)__va(phys));
31292 if (pud_none(*pud)) {
31293 pmd = (pmd_t *) spp_getpage();
31294 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31295 - _PAGE_USER));
31296 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31297 }
31298 pmd = pmd_offset(pud, phys);
31299 BUG_ON(!pmd_none(*pmd));
31300 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31301 prot);
31302
31303 spin_lock(&init_mm.page_table_lock);
31304 - pud_populate(&init_mm, pud, pmd);
31305 + pud_populate_kernel(&init_mm, pud, pmd);
31306 spin_unlock(&init_mm.page_table_lock);
31307 }
31308 __flush_tlb_all();
31309 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31310 page_size_mask);
31311
31312 spin_lock(&init_mm.page_table_lock);
31313 - pgd_populate(&init_mm, pgd, pud);
31314 + pgd_populate_kernel(&init_mm, pgd, pud);
31315 spin_unlock(&init_mm.page_table_lock);
31316 pgd_changed = true;
31317 }
31318 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31319 static struct vm_area_struct gate_vma = {
31320 .vm_start = VSYSCALL_START,
31321 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31322 - .vm_page_prot = PAGE_READONLY_EXEC,
31323 - .vm_flags = VM_READ | VM_EXEC
31324 + .vm_page_prot = PAGE_READONLY,
31325 + .vm_flags = VM_READ
31326 };
31327
31328 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31329 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31330
31331 const char *arch_vma_name(struct vm_area_struct *vma)
31332 {
31333 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31334 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31335 return "[vdso]";
31336 if (vma == &gate_vma)
31337 return "[vsyscall]";
31338 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31339 index 7b179b4..6bd17777 100644
31340 --- a/arch/x86/mm/iomap_32.c
31341 +++ b/arch/x86/mm/iomap_32.c
31342 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31343 type = kmap_atomic_idx_push();
31344 idx = type + KM_TYPE_NR * smp_processor_id();
31345 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31346 +
31347 + pax_open_kernel();
31348 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31349 + pax_close_kernel();
31350 +
31351 arch_flush_lazy_mmu_mode();
31352
31353 return (void *)vaddr;
31354 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31355 index 799580c..72f9fe0 100644
31356 --- a/arch/x86/mm/ioremap.c
31357 +++ b/arch/x86/mm/ioremap.c
31358 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31359 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31360 int is_ram = page_is_ram(pfn);
31361
31362 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31363 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31364 return NULL;
31365 WARN_ON_ONCE(is_ram);
31366 }
31367 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31368 *
31369 * Caller must ensure there is only one unmapping for the same pointer.
31370 */
31371 -void iounmap(volatile void __iomem *addr)
31372 +void iounmap(const volatile void __iomem *addr)
31373 {
31374 struct vm_struct *p, *o;
31375
31376 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31377
31378 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31379 if (page_is_ram(start >> PAGE_SHIFT))
31380 +#ifdef CONFIG_HIGHMEM
31381 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31382 +#endif
31383 return __va(phys);
31384
31385 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31386 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31387 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31388 {
31389 if (page_is_ram(phys >> PAGE_SHIFT))
31390 +#ifdef CONFIG_HIGHMEM
31391 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31392 +#endif
31393 return;
31394
31395 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31396 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31397 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31398
31399 static __initdata int after_paging_init;
31400 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31401 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31402
31403 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31404 {
31405 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31406 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31407
31408 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31409 - memset(bm_pte, 0, sizeof(bm_pte));
31410 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31411 + pmd_populate_user(&init_mm, pmd, bm_pte);
31412
31413 /*
31414 * The boot-ioremap range spans multiple pmds, for which
31415 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31416 index d87dd6d..bf3fa66 100644
31417 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31418 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31419 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31420 * memory (e.g. tracked pages)? For now, we need this to avoid
31421 * invoking kmemcheck for PnP BIOS calls.
31422 */
31423 - if (regs->flags & X86_VM_MASK)
31424 + if (v8086_mode(regs))
31425 return false;
31426 - if (regs->cs != __KERNEL_CS)
31427 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31428 return false;
31429
31430 pte = kmemcheck_pte_lookup(address);
31431 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31432 index 25e7e13..1964579 100644
31433 --- a/arch/x86/mm/mmap.c
31434 +++ b/arch/x86/mm/mmap.c
31435 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31436 * Leave an at least ~128 MB hole with possible stack randomization.
31437 */
31438 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31439 -#define MAX_GAP (TASK_SIZE/6*5)
31440 +#define MAX_GAP (pax_task_size/6*5)
31441
31442 static int mmap_is_legacy(void)
31443 {
31444 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31445 return rnd << PAGE_SHIFT;
31446 }
31447
31448 -static unsigned long mmap_base(void)
31449 +static unsigned long mmap_base(struct mm_struct *mm)
31450 {
31451 unsigned long gap = rlimit(RLIMIT_STACK);
31452 + unsigned long pax_task_size = TASK_SIZE;
31453 +
31454 +#ifdef CONFIG_PAX_SEGMEXEC
31455 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31456 + pax_task_size = SEGMEXEC_TASK_SIZE;
31457 +#endif
31458
31459 if (gap < MIN_GAP)
31460 gap = MIN_GAP;
31461 else if (gap > MAX_GAP)
31462 gap = MAX_GAP;
31463
31464 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31465 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31466 }
31467
31468 /*
31469 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31470 * does, but not when emulating X86_32
31471 */
31472 -static unsigned long mmap_legacy_base(void)
31473 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31474 {
31475 - if (mmap_is_ia32())
31476 + if (mmap_is_ia32()) {
31477 +
31478 +#ifdef CONFIG_PAX_SEGMEXEC
31479 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31480 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31481 + else
31482 +#endif
31483 +
31484 return TASK_UNMAPPED_BASE;
31485 - else
31486 + } else
31487 return TASK_UNMAPPED_BASE + mmap_rnd();
31488 }
31489
31490 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31491 */
31492 void arch_pick_mmap_layout(struct mm_struct *mm)
31493 {
31494 - mm->mmap_legacy_base = mmap_legacy_base();
31495 - mm->mmap_base = mmap_base();
31496 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31497 + mm->mmap_base = mmap_base(mm);
31498 +
31499 +#ifdef CONFIG_PAX_RANDMMAP
31500 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31501 + mm->mmap_legacy_base += mm->delta_mmap;
31502 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31503 + }
31504 +#endif
31505
31506 if (mmap_is_legacy()) {
31507 mm->mmap_base = mm->mmap_legacy_base;
31508 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31509 index 0057a7a..95c7edd 100644
31510 --- a/arch/x86/mm/mmio-mod.c
31511 +++ b/arch/x86/mm/mmio-mod.c
31512 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31513 break;
31514 default:
31515 {
31516 - unsigned char *ip = (unsigned char *)instptr;
31517 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31518 my_trace->opcode = MMIO_UNKNOWN_OP;
31519 my_trace->width = 0;
31520 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31521 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31522 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31523 void __iomem *addr)
31524 {
31525 - static atomic_t next_id;
31526 + static atomic_unchecked_t next_id;
31527 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31528 /* These are page-unaligned. */
31529 struct mmiotrace_map map = {
31530 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31531 .private = trace
31532 },
31533 .phys = offset,
31534 - .id = atomic_inc_return(&next_id)
31535 + .id = atomic_inc_return_unchecked(&next_id)
31536 };
31537 map.map_id = trace->id;
31538
31539 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31540 ioremap_trace_core(offset, size, addr);
31541 }
31542
31543 -static void iounmap_trace_core(volatile void __iomem *addr)
31544 +static void iounmap_trace_core(const volatile void __iomem *addr)
31545 {
31546 struct mmiotrace_map map = {
31547 .phys = 0,
31548 @@ -328,7 +328,7 @@ not_enabled:
31549 }
31550 }
31551
31552 -void mmiotrace_iounmap(volatile void __iomem *addr)
31553 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31554 {
31555 might_sleep();
31556 if (is_enabled()) /* recheck and proper locking in *_core() */
31557 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31558 index 8bf93ba..dbcd670 100644
31559 --- a/arch/x86/mm/numa.c
31560 +++ b/arch/x86/mm/numa.c
31561 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31562 return true;
31563 }
31564
31565 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31566 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31567 {
31568 unsigned long uninitialized_var(pfn_align);
31569 int i, nid;
31570 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31571 index d0b1773..4c3327c 100644
31572 --- a/arch/x86/mm/pageattr-test.c
31573 +++ b/arch/x86/mm/pageattr-test.c
31574 @@ -36,7 +36,7 @@ enum {
31575
31576 static int pte_testbit(pte_t pte)
31577 {
31578 - return pte_flags(pte) & _PAGE_UNUSED1;
31579 + return pte_flags(pte) & _PAGE_CPA_TEST;
31580 }
31581
31582 struct split_state {
31583 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31584 index bb32480..75f2f5e 100644
31585 --- a/arch/x86/mm/pageattr.c
31586 +++ b/arch/x86/mm/pageattr.c
31587 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31588 */
31589 #ifdef CONFIG_PCI_BIOS
31590 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31591 - pgprot_val(forbidden) |= _PAGE_NX;
31592 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31593 #endif
31594
31595 /*
31596 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31597 * Does not cover __inittext since that is gone later on. On
31598 * 64bit we do not enforce !NX on the low mapping
31599 */
31600 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31601 - pgprot_val(forbidden) |= _PAGE_NX;
31602 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31603 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31604
31605 +#ifdef CONFIG_DEBUG_RODATA
31606 /*
31607 * The .rodata section needs to be read-only. Using the pfn
31608 * catches all aliases.
31609 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31610 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31611 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31612 pgprot_val(forbidden) |= _PAGE_RW;
31613 +#endif
31614
31615 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31616 /*
31617 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31618 }
31619 #endif
31620
31621 +#ifdef CONFIG_PAX_KERNEXEC
31622 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31623 + pgprot_val(forbidden) |= _PAGE_RW;
31624 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31625 + }
31626 +#endif
31627 +
31628 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31629
31630 return prot;
31631 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31632 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31633 {
31634 /* change init_mm */
31635 + pax_open_kernel();
31636 set_pte_atomic(kpte, pte);
31637 +
31638 #ifdef CONFIG_X86_32
31639 if (!SHARED_KERNEL_PMD) {
31640 +
31641 +#ifdef CONFIG_PAX_PER_CPU_PGD
31642 + unsigned long cpu;
31643 +#else
31644 struct page *page;
31645 +#endif
31646
31647 +#ifdef CONFIG_PAX_PER_CPU_PGD
31648 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31649 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31650 +#else
31651 list_for_each_entry(page, &pgd_list, lru) {
31652 - pgd_t *pgd;
31653 + pgd_t *pgd = (pgd_t *)page_address(page);
31654 +#endif
31655 +
31656 pud_t *pud;
31657 pmd_t *pmd;
31658
31659 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31660 + pgd += pgd_index(address);
31661 pud = pud_offset(pgd, address);
31662 pmd = pmd_offset(pud, address);
31663 set_pte_atomic((pte_t *)pmd, pte);
31664 }
31665 }
31666 #endif
31667 + pax_close_kernel();
31668 }
31669
31670 static int
31671 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31672 index 6574388..87e9bef 100644
31673 --- a/arch/x86/mm/pat.c
31674 +++ b/arch/x86/mm/pat.c
31675 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31676
31677 if (!entry) {
31678 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31679 - current->comm, current->pid, start, end - 1);
31680 + current->comm, task_pid_nr(current), start, end - 1);
31681 return -EINVAL;
31682 }
31683
31684 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31685
31686 while (cursor < to) {
31687 if (!devmem_is_allowed(pfn)) {
31688 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31689 - current->comm, from, to - 1);
31690 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31691 + current->comm, from, to - 1, cursor);
31692 return 0;
31693 }
31694 cursor += PAGE_SIZE;
31695 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31696 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31697 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31698 "for [mem %#010Lx-%#010Lx]\n",
31699 - current->comm, current->pid,
31700 + current->comm, task_pid_nr(current),
31701 cattr_name(flags),
31702 base, (unsigned long long)(base + size-1));
31703 return -EINVAL;
31704 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31705 flags = lookup_memtype(paddr);
31706 if (want_flags != flags) {
31707 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31708 - current->comm, current->pid,
31709 + current->comm, task_pid_nr(current),
31710 cattr_name(want_flags),
31711 (unsigned long long)paddr,
31712 (unsigned long long)(paddr + size - 1),
31713 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31714 free_memtype(paddr, paddr + size);
31715 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31716 " for [mem %#010Lx-%#010Lx], got %s\n",
31717 - current->comm, current->pid,
31718 + current->comm, task_pid_nr(current),
31719 cattr_name(want_flags),
31720 (unsigned long long)paddr,
31721 (unsigned long long)(paddr + size - 1),
31722 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31723 index 415f6c4..d319983 100644
31724 --- a/arch/x86/mm/pat_rbtree.c
31725 +++ b/arch/x86/mm/pat_rbtree.c
31726 @@ -160,7 +160,7 @@ success:
31727
31728 failure:
31729 printk(KERN_INFO "%s:%d conflicting memory types "
31730 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31731 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31732 end, cattr_name(found_type), cattr_name(match->type));
31733 return -EBUSY;
31734 }
31735 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31736 index 9f0614d..92ae64a 100644
31737 --- a/arch/x86/mm/pf_in.c
31738 +++ b/arch/x86/mm/pf_in.c
31739 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31740 int i;
31741 enum reason_type rv = OTHERS;
31742
31743 - p = (unsigned char *)ins_addr;
31744 + p = (unsigned char *)ktla_ktva(ins_addr);
31745 p += skip_prefix(p, &prf);
31746 p += get_opcode(p, &opcode);
31747
31748 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31749 struct prefix_bits prf;
31750 int i;
31751
31752 - p = (unsigned char *)ins_addr;
31753 + p = (unsigned char *)ktla_ktva(ins_addr);
31754 p += skip_prefix(p, &prf);
31755 p += get_opcode(p, &opcode);
31756
31757 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31758 struct prefix_bits prf;
31759 int i;
31760
31761 - p = (unsigned char *)ins_addr;
31762 + p = (unsigned char *)ktla_ktva(ins_addr);
31763 p += skip_prefix(p, &prf);
31764 p += get_opcode(p, &opcode);
31765
31766 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31767 struct prefix_bits prf;
31768 int i;
31769
31770 - p = (unsigned char *)ins_addr;
31771 + p = (unsigned char *)ktla_ktva(ins_addr);
31772 p += skip_prefix(p, &prf);
31773 p += get_opcode(p, &opcode);
31774 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31775 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31776 struct prefix_bits prf;
31777 int i;
31778
31779 - p = (unsigned char *)ins_addr;
31780 + p = (unsigned char *)ktla_ktva(ins_addr);
31781 p += skip_prefix(p, &prf);
31782 p += get_opcode(p, &opcode);
31783 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31784 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31785 index dfa537a..fd45c64 100644
31786 --- a/arch/x86/mm/pgtable.c
31787 +++ b/arch/x86/mm/pgtable.c
31788 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31789 list_del(&page->lru);
31790 }
31791
31792 -#define UNSHARED_PTRS_PER_PGD \
31793 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31795 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31796
31797 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31798 +{
31799 + unsigned int count = USER_PGD_PTRS;
31800
31801 + if (!pax_user_shadow_base)
31802 + return;
31803 +
31804 + while (count--)
31805 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31806 +}
31807 +#endif
31808 +
31809 +#ifdef CONFIG_PAX_PER_CPU_PGD
31810 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31811 +{
31812 + unsigned int count = USER_PGD_PTRS;
31813 +
31814 + while (count--) {
31815 + pgd_t pgd;
31816 +
31817 +#ifdef CONFIG_X86_64
31818 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31819 +#else
31820 + pgd = *src++;
31821 +#endif
31822 +
31823 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31824 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31825 +#endif
31826 +
31827 + *dst++ = pgd;
31828 + }
31829 +
31830 +}
31831 +#endif
31832 +
31833 +#ifdef CONFIG_X86_64
31834 +#define pxd_t pud_t
31835 +#define pyd_t pgd_t
31836 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31837 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31838 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31839 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31840 +#define PYD_SIZE PGDIR_SIZE
31841 +#else
31842 +#define pxd_t pmd_t
31843 +#define pyd_t pud_t
31844 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31845 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31846 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31847 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31848 +#define PYD_SIZE PUD_SIZE
31849 +#endif
31850 +
31851 +#ifdef CONFIG_PAX_PER_CPU_PGD
31852 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31853 +static inline void pgd_dtor(pgd_t *pgd) {}
31854 +#else
31855 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31856 {
31857 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31858 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31859 pgd_list_del(pgd);
31860 spin_unlock(&pgd_lock);
31861 }
31862 +#endif
31863
31864 /*
31865 * List of all pgd's needed for non-PAE so it can invalidate entries
31866 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31867 * -- nyc
31868 */
31869
31870 -#ifdef CONFIG_X86_PAE
31871 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31872 /*
31873 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31874 * updating the top-level pagetable entries to guarantee the
31875 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31876 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31877 * and initialize the kernel pmds here.
31878 */
31879 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31880 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31881
31882 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31883 {
31884 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31885 */
31886 flush_tlb_mm(mm);
31887 }
31888 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31889 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31890 #else /* !CONFIG_X86_PAE */
31891
31892 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31893 -#define PREALLOCATED_PMDS 0
31894 +#define PREALLOCATED_PXDS 0
31895
31896 #endif /* CONFIG_X86_PAE */
31897
31898 -static void free_pmds(pmd_t *pmds[])
31899 +static void free_pxds(pxd_t *pxds[])
31900 {
31901 int i;
31902
31903 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31904 - if (pmds[i])
31905 - free_page((unsigned long)pmds[i]);
31906 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31907 + if (pxds[i])
31908 + free_page((unsigned long)pxds[i]);
31909 }
31910
31911 -static int preallocate_pmds(pmd_t *pmds[])
31912 +static int preallocate_pxds(pxd_t *pxds[])
31913 {
31914 int i;
31915 bool failed = false;
31916
31917 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31918 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31919 - if (pmd == NULL)
31920 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31921 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31922 + if (pxd == NULL)
31923 failed = true;
31924 - pmds[i] = pmd;
31925 + pxds[i] = pxd;
31926 }
31927
31928 if (failed) {
31929 - free_pmds(pmds);
31930 + free_pxds(pxds);
31931 return -ENOMEM;
31932 }
31933
31934 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31935 * preallocate which never got a corresponding vma will need to be
31936 * freed manually.
31937 */
31938 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31939 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31940 {
31941 int i;
31942
31943 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31944 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31945 pgd_t pgd = pgdp[i];
31946
31947 if (pgd_val(pgd) != 0) {
31948 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31949 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31950
31951 - pgdp[i] = native_make_pgd(0);
31952 + set_pgd(pgdp + i, native_make_pgd(0));
31953
31954 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31955 - pmd_free(mm, pmd);
31956 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31957 + pxd_free(mm, pxd);
31958 }
31959 }
31960 }
31961
31962 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31963 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31964 {
31965 - pud_t *pud;
31966 + pyd_t *pyd;
31967 int i;
31968
31969 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31970 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31971 return;
31972
31973 - pud = pud_offset(pgd, 0);
31974 -
31975 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31976 - pmd_t *pmd = pmds[i];
31977 +#ifdef CONFIG_X86_64
31978 + pyd = pyd_offset(mm, 0L);
31979 +#else
31980 + pyd = pyd_offset(pgd, 0L);
31981 +#endif
31982
31983 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31984 + pxd_t *pxd = pxds[i];
31985 if (i >= KERNEL_PGD_BOUNDARY)
31986 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31987 - sizeof(pmd_t) * PTRS_PER_PMD);
31988 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31989 + sizeof(pxd_t) * PTRS_PER_PMD);
31990
31991 - pud_populate(mm, pud, pmd);
31992 + pyd_populate(mm, pyd, pxd);
31993 }
31994 }
31995
31996 pgd_t *pgd_alloc(struct mm_struct *mm)
31997 {
31998 pgd_t *pgd;
31999 - pmd_t *pmds[PREALLOCATED_PMDS];
32000 + pxd_t *pxds[PREALLOCATED_PXDS];
32001
32002 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32003
32004 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32005
32006 mm->pgd = pgd;
32007
32008 - if (preallocate_pmds(pmds) != 0)
32009 + if (preallocate_pxds(pxds) != 0)
32010 goto out_free_pgd;
32011
32012 if (paravirt_pgd_alloc(mm) != 0)
32013 - goto out_free_pmds;
32014 + goto out_free_pxds;
32015
32016 /*
32017 * Make sure that pre-populating the pmds is atomic with
32018 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32019 spin_lock(&pgd_lock);
32020
32021 pgd_ctor(mm, pgd);
32022 - pgd_prepopulate_pmd(mm, pgd, pmds);
32023 + pgd_prepopulate_pxd(mm, pgd, pxds);
32024
32025 spin_unlock(&pgd_lock);
32026
32027 return pgd;
32028
32029 -out_free_pmds:
32030 - free_pmds(pmds);
32031 +out_free_pxds:
32032 + free_pxds(pxds);
32033 out_free_pgd:
32034 free_page((unsigned long)pgd);
32035 out:
32036 @@ -300,7 +363,7 @@ out:
32037
32038 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32039 {
32040 - pgd_mop_up_pmds(mm, pgd);
32041 + pgd_mop_up_pxds(mm, pgd);
32042 pgd_dtor(pgd);
32043 paravirt_pgd_free(mm, pgd);
32044 free_page((unsigned long)pgd);
32045 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32046 index a69bcb8..19068ab 100644
32047 --- a/arch/x86/mm/pgtable_32.c
32048 +++ b/arch/x86/mm/pgtable_32.c
32049 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32050 return;
32051 }
32052 pte = pte_offset_kernel(pmd, vaddr);
32053 +
32054 + pax_open_kernel();
32055 if (pte_val(pteval))
32056 set_pte_at(&init_mm, vaddr, pte, pteval);
32057 else
32058 pte_clear(&init_mm, vaddr, pte);
32059 + pax_close_kernel();
32060
32061 /*
32062 * It's enough to flush this one mapping.
32063 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32064 index e666cbb..61788c45 100644
32065 --- a/arch/x86/mm/physaddr.c
32066 +++ b/arch/x86/mm/physaddr.c
32067 @@ -10,7 +10,7 @@
32068 #ifdef CONFIG_X86_64
32069
32070 #ifdef CONFIG_DEBUG_VIRTUAL
32071 -unsigned long __phys_addr(unsigned long x)
32072 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32073 {
32074 unsigned long y = x - __START_KERNEL_map;
32075
32076 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32077 #else
32078
32079 #ifdef CONFIG_DEBUG_VIRTUAL
32080 -unsigned long __phys_addr(unsigned long x)
32081 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32082 {
32083 unsigned long phys_addr = x - PAGE_OFFSET;
32084 /* VMALLOC_* aren't constants */
32085 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32086 index 90555bf..f5f1828 100644
32087 --- a/arch/x86/mm/setup_nx.c
32088 +++ b/arch/x86/mm/setup_nx.c
32089 @@ -5,8 +5,10 @@
32090 #include <asm/pgtable.h>
32091 #include <asm/proto.h>
32092
32093 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32094 static int disable_nx;
32095
32096 +#ifndef CONFIG_PAX_PAGEEXEC
32097 /*
32098 * noexec = on|off
32099 *
32100 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32101 return 0;
32102 }
32103 early_param("noexec", noexec_setup);
32104 +#endif
32105 +
32106 +#endif
32107
32108 void x86_configure_nx(void)
32109 {
32110 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32111 if (cpu_has_nx && !disable_nx)
32112 __supported_pte_mask |= _PAGE_NX;
32113 else
32114 +#endif
32115 __supported_pte_mask &= ~_PAGE_NX;
32116 }
32117
32118 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32119 index ae699b3..f1b2ad2 100644
32120 --- a/arch/x86/mm/tlb.c
32121 +++ b/arch/x86/mm/tlb.c
32122 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32123 BUG();
32124 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32125 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32126 +
32127 +#ifndef CONFIG_PAX_PER_CPU_PGD
32128 load_cr3(swapper_pg_dir);
32129 +#endif
32130 +
32131 }
32132 }
32133 EXPORT_SYMBOL_GPL(leave_mm);
32134 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32135 new file mode 100644
32136 index 0000000..dace51c
32137 --- /dev/null
32138 +++ b/arch/x86/mm/uderef_64.c
32139 @@ -0,0 +1,37 @@
32140 +#include <linux/mm.h>
32141 +#include <asm/pgtable.h>
32142 +#include <asm/uaccess.h>
32143 +
32144 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32145 +/* PaX: due to the special call convention these functions must
32146 + * - remain leaf functions under all configurations,
32147 + * - never be called directly, only dereferenced from the wrappers.
32148 + */
32149 +void __pax_open_userland(void)
32150 +{
32151 + unsigned int cpu;
32152 +
32153 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32154 + return;
32155 +
32156 + cpu = raw_get_cpu();
32157 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32158 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32159 + raw_put_cpu_no_resched();
32160 +}
32161 +EXPORT_SYMBOL(__pax_open_userland);
32162 +
32163 +void __pax_close_userland(void)
32164 +{
32165 + unsigned int cpu;
32166 +
32167 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32168 + return;
32169 +
32170 + cpu = raw_get_cpu();
32171 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32172 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32173 + raw_put_cpu_no_resched();
32174 +}
32175 +EXPORT_SYMBOL(__pax_close_userland);
32176 +#endif
32177 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32178 index 877b9a1..a8ecf42 100644
32179 --- a/arch/x86/net/bpf_jit.S
32180 +++ b/arch/x86/net/bpf_jit.S
32181 @@ -9,6 +9,7 @@
32182 */
32183 #include <linux/linkage.h>
32184 #include <asm/dwarf2.h>
32185 +#include <asm/alternative-asm.h>
32186
32187 /*
32188 * Calling convention :
32189 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32190 jle bpf_slow_path_word
32191 mov (SKBDATA,%rsi),%eax
32192 bswap %eax /* ntohl() */
32193 + pax_force_retaddr
32194 ret
32195
32196 sk_load_half:
32197 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32198 jle bpf_slow_path_half
32199 movzwl (SKBDATA,%rsi),%eax
32200 rol $8,%ax # ntohs()
32201 + pax_force_retaddr
32202 ret
32203
32204 sk_load_byte:
32205 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32206 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32207 jle bpf_slow_path_byte
32208 movzbl (SKBDATA,%rsi),%eax
32209 + pax_force_retaddr
32210 ret
32211
32212 /**
32213 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32214 movzbl (SKBDATA,%rsi),%ebx
32215 and $15,%bl
32216 shl $2,%bl
32217 + pax_force_retaddr
32218 ret
32219
32220 /* rsi contains offset and can be scratched */
32221 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32222 js bpf_error
32223 mov -12(%rbp),%eax
32224 bswap %eax
32225 + pax_force_retaddr
32226 ret
32227
32228 bpf_slow_path_half:
32229 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32230 mov -12(%rbp),%ax
32231 rol $8,%ax
32232 movzwl %ax,%eax
32233 + pax_force_retaddr
32234 ret
32235
32236 bpf_slow_path_byte:
32237 bpf_slow_path_common(1)
32238 js bpf_error
32239 movzbl -12(%rbp),%eax
32240 + pax_force_retaddr
32241 ret
32242
32243 bpf_slow_path_byte_msh:
32244 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32245 and $15,%al
32246 shl $2,%al
32247 xchg %eax,%ebx
32248 + pax_force_retaddr
32249 ret
32250
32251 #define sk_negative_common(SIZE) \
32252 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32253 sk_negative_common(4)
32254 mov (%rax), %eax
32255 bswap %eax
32256 + pax_force_retaddr
32257 ret
32258
32259 bpf_slow_path_half_neg:
32260 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32261 mov (%rax),%ax
32262 rol $8,%ax
32263 movzwl %ax,%eax
32264 + pax_force_retaddr
32265 ret
32266
32267 bpf_slow_path_byte_neg:
32268 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32269 .globl sk_load_byte_negative_offset
32270 sk_negative_common(1)
32271 movzbl (%rax), %eax
32272 + pax_force_retaddr
32273 ret
32274
32275 bpf_slow_path_byte_msh_neg:
32276 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32277 and $15,%al
32278 shl $2,%al
32279 xchg %eax,%ebx
32280 + pax_force_retaddr
32281 ret
32282
32283 bpf_error:
32284 @@ -197,4 +210,5 @@ bpf_error:
32285 xor %eax,%eax
32286 mov -8(%rbp),%rbx
32287 leaveq
32288 + pax_force_retaddr
32289 ret
32290 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32291 index 516593e..29d3c55 100644
32292 --- a/arch/x86/net/bpf_jit_comp.c
32293 +++ b/arch/x86/net/bpf_jit_comp.c
32294 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32295 return ptr + len;
32296 }
32297
32298 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32299 +#define MAX_INSTR_CODE_SIZE 96
32300 +#else
32301 +#define MAX_INSTR_CODE_SIZE 64
32302 +#endif
32303 +
32304 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32305
32306 #define EMIT1(b1) EMIT(b1, 1)
32307 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32308 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32309 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32310 +
32311 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32312 +/* original constant will appear in ecx */
32313 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32314 +do { \
32315 + /* mov ecx, randkey */ \
32316 + EMIT1(0xb9); \
32317 + EMIT(_key, 4); \
32318 + /* xor ecx, randkey ^ off */ \
32319 + EMIT2(0x81, 0xf1); \
32320 + EMIT((_key) ^ (_off), 4); \
32321 +} while (0)
32322 +
32323 +#define EMIT1_off32(b1, _off) \
32324 +do { \
32325 + switch (b1) { \
32326 + case 0x05: /* add eax, imm32 */ \
32327 + case 0x2d: /* sub eax, imm32 */ \
32328 + case 0x25: /* and eax, imm32 */ \
32329 + case 0x0d: /* or eax, imm32 */ \
32330 + case 0xb8: /* mov eax, imm32 */ \
32331 + case 0x35: /* xor eax, imm32 */ \
32332 + case 0x3d: /* cmp eax, imm32 */ \
32333 + case 0xa9: /* test eax, imm32 */ \
32334 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32335 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32336 + break; \
32337 + case 0xbb: /* mov ebx, imm32 */ \
32338 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32339 + /* mov ebx, ecx */ \
32340 + EMIT2(0x89, 0xcb); \
32341 + break; \
32342 + case 0xbe: /* mov esi, imm32 */ \
32343 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32344 + /* mov esi, ecx */ \
32345 + EMIT2(0x89, 0xce); \
32346 + break; \
32347 + case 0xe8: /* call rel imm32, always to known funcs */ \
32348 + EMIT1(b1); \
32349 + EMIT(_off, 4); \
32350 + break; \
32351 + case 0xe9: /* jmp rel imm32 */ \
32352 + EMIT1(b1); \
32353 + EMIT(_off, 4); \
32354 + /* prevent fall-through, we're not called if off = 0 */ \
32355 + EMIT(0xcccccccc, 4); \
32356 + EMIT(0xcccccccc, 4); \
32357 + break; \
32358 + default: \
32359 + BUILD_BUG(); \
32360 + } \
32361 +} while (0)
32362 +
32363 +#define EMIT2_off32(b1, b2, _off) \
32364 +do { \
32365 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32366 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32367 + EMIT(randkey, 4); \
32368 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32369 + EMIT((_off) - randkey, 4); \
32370 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32371 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32372 + /* imul eax, ecx */ \
32373 + EMIT3(0x0f, 0xaf, 0xc1); \
32374 + } else { \
32375 + BUILD_BUG(); \
32376 + } \
32377 +} while (0)
32378 +#else
32379 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32380 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32381 +#endif
32382
32383 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32384 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32385 @@ -91,6 +168,24 @@ do { \
32386 #define X86_JBE 0x76
32387 #define X86_JA 0x77
32388
32389 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32390 +#define APPEND_FLOW_VERIFY() \
32391 +do { \
32392 + /* mov ecx, randkey */ \
32393 + EMIT1(0xb9); \
32394 + EMIT(randkey, 4); \
32395 + /* cmp ecx, randkey */ \
32396 + EMIT2(0x81, 0xf9); \
32397 + EMIT(randkey, 4); \
32398 + /* jz after 8 int 3s */ \
32399 + EMIT2(0x74, 0x08); \
32400 + EMIT(0xcccccccc, 4); \
32401 + EMIT(0xcccccccc, 4); \
32402 +} while (0)
32403 +#else
32404 +#define APPEND_FLOW_VERIFY() do { } while (0)
32405 +#endif
32406 +
32407 #define EMIT_COND_JMP(op, offset) \
32408 do { \
32409 if (is_near(offset)) \
32410 @@ -98,6 +193,7 @@ do { \
32411 else { \
32412 EMIT2(0x0f, op + 0x10); \
32413 EMIT(offset, 4); /* jxx .+off32 */ \
32414 + APPEND_FLOW_VERIFY(); \
32415 } \
32416 } while (0)
32417
32418 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32419 return -1;
32420 }
32421
32422 -struct bpf_binary_header {
32423 - unsigned int pages;
32424 - /* Note : for security reasons, bpf code will follow a randomly
32425 - * sized amount of int3 instructions
32426 - */
32427 - u8 image[];
32428 -};
32429 -
32430 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32431 +/* Note : for security reasons, bpf code will follow a randomly
32432 + * sized amount of int3 instructions
32433 + */
32434 +static u8 *bpf_alloc_binary(unsigned int proglen,
32435 u8 **image_ptr)
32436 {
32437 unsigned int sz, hole;
32438 - struct bpf_binary_header *header;
32439 + u8 *header;
32440
32441 /* Most of BPF filters are really small,
32442 * but if some of them fill a page, allow at least
32443 * 128 extra bytes to insert a random section of int3
32444 */
32445 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32446 - header = module_alloc(sz);
32447 + sz = round_up(proglen + 128, PAGE_SIZE);
32448 + header = module_alloc_exec(sz);
32449 if (!header)
32450 return NULL;
32451
32452 + pax_open_kernel();
32453 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32454 + pax_close_kernel();
32455
32456 - header->pages = sz / PAGE_SIZE;
32457 - hole = sz - (proglen + sizeof(*header));
32458 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32459
32460 /* insert a random number of int3 instructions before BPF code */
32461 - *image_ptr = &header->image[prandom_u32() % hole];
32462 + *image_ptr = &header[prandom_u32() % hole];
32463 return header;
32464 }
32465
32466 void bpf_jit_compile(struct sk_filter *fp)
32467 {
32468 - u8 temp[64];
32469 + u8 temp[MAX_INSTR_CODE_SIZE];
32470 u8 *prog;
32471 unsigned int proglen, oldproglen = 0;
32472 int ilen, i;
32473 int t_offset, f_offset;
32474 u8 t_op, f_op, seen = 0, pass;
32475 u8 *image = NULL;
32476 - struct bpf_binary_header *header = NULL;
32477 + u8 *header = NULL;
32478 u8 *func;
32479 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32480 unsigned int cleanup_addr; /* epilogue code offset */
32481 unsigned int *addrs;
32482 const struct sock_filter *filter = fp->insns;
32483 int flen = fp->len;
32484 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32485 + unsigned int randkey;
32486 +#endif
32487
32488 if (!bpf_jit_enable)
32489 return;
32490 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32491 if (addrs == NULL)
32492 return;
32493
32494 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32495 + randkey = get_random_int();
32496 +#endif
32497 +
32498 /* Before first pass, make a rough estimation of addrs[]
32499 - * each bpf instruction is translated to less than 64 bytes
32500 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32501 */
32502 for (proglen = 0, i = 0; i < flen; i++) {
32503 - proglen += 64;
32504 + proglen += MAX_INSTR_CODE_SIZE;
32505 addrs[i] = proglen;
32506 }
32507 cleanup_addr = proglen; /* epilogue address */
32508 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32509 case BPF_S_ALU_MUL_K: /* A *= K */
32510 if (is_imm8(K))
32511 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32512 - else {
32513 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32514 - EMIT(K, 4);
32515 - }
32516 + else
32517 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32518 break;
32519 case BPF_S_ALU_DIV_X: /* A /= X; */
32520 seen |= SEEN_XREG;
32521 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32522 break;
32523 case BPF_S_ALU_MOD_K: /* A %= K; */
32524 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32525 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32526 + DILUTE_CONST_SEQUENCE(K, randkey);
32527 +#else
32528 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32529 +#endif
32530 EMIT2(0xf7, 0xf1); /* div %ecx */
32531 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32532 break;
32533 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32534 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32535 + DILUTE_CONST_SEQUENCE(K, randkey);
32536 + // imul rax, rcx
32537 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32538 +#else
32539 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32540 EMIT(K, 4);
32541 +#endif
32542 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32543 break;
32544 case BPF_S_ALU_AND_X:
32545 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32546 if (is_imm8(K)) {
32547 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32548 } else {
32549 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32550 - EMIT(K, 4);
32551 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32552 }
32553 } else {
32554 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32555 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32556 if (unlikely(proglen + ilen > oldproglen)) {
32557 pr_err("bpb_jit_compile fatal error\n");
32558 kfree(addrs);
32559 - module_free(NULL, header);
32560 + module_free_exec(NULL, image);
32561 return;
32562 }
32563 + pax_open_kernel();
32564 memcpy(image + proglen, temp, ilen);
32565 + pax_close_kernel();
32566 }
32567 proglen += ilen;
32568 addrs[i] = proglen;
32569 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32570
32571 if (image) {
32572 bpf_flush_icache(header, image + proglen);
32573 - set_memory_ro((unsigned long)header, header->pages);
32574 fp->bpf_func = (void *)image;
32575 }
32576 out:
32577 @@ -776,10 +883,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
32578 {
32579 struct sk_filter *fp = container_of(work, struct sk_filter, work);
32580 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32581 - struct bpf_binary_header *header = (void *)addr;
32582
32583 - set_memory_rw(addr, header->pages);
32584 - module_free(NULL, header);
32585 + set_memory_rw(addr, 1);
32586 + module_free_exec(NULL, (void *)addr);
32587 kfree(fp);
32588 }
32589
32590 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32591 index d6aa6e8..266395a 100644
32592 --- a/arch/x86/oprofile/backtrace.c
32593 +++ b/arch/x86/oprofile/backtrace.c
32594 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32595 struct stack_frame_ia32 *fp;
32596 unsigned long bytes;
32597
32598 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32599 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32600 if (bytes != sizeof(bufhead))
32601 return NULL;
32602
32603 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32604 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32605
32606 oprofile_add_trace(bufhead[0].return_address);
32607
32608 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32609 struct stack_frame bufhead[2];
32610 unsigned long bytes;
32611
32612 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32613 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32614 if (bytes != sizeof(bufhead))
32615 return NULL;
32616
32617 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32618 {
32619 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32620
32621 - if (!user_mode_vm(regs)) {
32622 + if (!user_mode(regs)) {
32623 unsigned long stack = kernel_stack_pointer(regs);
32624 if (depth)
32625 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32626 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32627 index 6890d84..1dad1f1 100644
32628 --- a/arch/x86/oprofile/nmi_int.c
32629 +++ b/arch/x86/oprofile/nmi_int.c
32630 @@ -23,6 +23,7 @@
32631 #include <asm/nmi.h>
32632 #include <asm/msr.h>
32633 #include <asm/apic.h>
32634 +#include <asm/pgtable.h>
32635
32636 #include "op_counter.h"
32637 #include "op_x86_model.h"
32638 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32639 if (ret)
32640 return ret;
32641
32642 - if (!model->num_virt_counters)
32643 - model->num_virt_counters = model->num_counters;
32644 + if (!model->num_virt_counters) {
32645 + pax_open_kernel();
32646 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32647 + pax_close_kernel();
32648 + }
32649
32650 mux_init(ops);
32651
32652 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32653 index 50d86c0..7985318 100644
32654 --- a/arch/x86/oprofile/op_model_amd.c
32655 +++ b/arch/x86/oprofile/op_model_amd.c
32656 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32657 num_counters = AMD64_NUM_COUNTERS;
32658 }
32659
32660 - op_amd_spec.num_counters = num_counters;
32661 - op_amd_spec.num_controls = num_counters;
32662 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32663 + pax_open_kernel();
32664 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32665 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32666 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32667 + pax_close_kernel();
32668
32669 return 0;
32670 }
32671 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32672 index d90528e..0127e2b 100644
32673 --- a/arch/x86/oprofile/op_model_ppro.c
32674 +++ b/arch/x86/oprofile/op_model_ppro.c
32675 @@ -19,6 +19,7 @@
32676 #include <asm/msr.h>
32677 #include <asm/apic.h>
32678 #include <asm/nmi.h>
32679 +#include <asm/pgtable.h>
32680
32681 #include "op_x86_model.h"
32682 #include "op_counter.h"
32683 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32684
32685 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32686
32687 - op_arch_perfmon_spec.num_counters = num_counters;
32688 - op_arch_perfmon_spec.num_controls = num_counters;
32689 + pax_open_kernel();
32690 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32691 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32692 + pax_close_kernel();
32693 }
32694
32695 static int arch_perfmon_init(struct oprofile_operations *ignore)
32696 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32697 index 71e8a67..6a313bb 100644
32698 --- a/arch/x86/oprofile/op_x86_model.h
32699 +++ b/arch/x86/oprofile/op_x86_model.h
32700 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32701 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32702 struct op_msrs const * const msrs);
32703 #endif
32704 -};
32705 +} __do_const;
32706
32707 struct op_counter_config;
32708
32709 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32710 index 372e9b8..e775a6c 100644
32711 --- a/arch/x86/pci/irq.c
32712 +++ b/arch/x86/pci/irq.c
32713 @@ -50,7 +50,7 @@ struct irq_router {
32714 struct irq_router_handler {
32715 u16 vendor;
32716 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32717 -};
32718 +} __do_const;
32719
32720 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32721 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32722 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32723 return 0;
32724 }
32725
32726 -static __initdata struct irq_router_handler pirq_routers[] = {
32727 +static __initconst const struct irq_router_handler pirq_routers[] = {
32728 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32729 { PCI_VENDOR_ID_AL, ali_router_probe },
32730 { PCI_VENDOR_ID_ITE, ite_router_probe },
32731 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32732 static void __init pirq_find_router(struct irq_router *r)
32733 {
32734 struct irq_routing_table *rt = pirq_table;
32735 - struct irq_router_handler *h;
32736 + const struct irq_router_handler *h;
32737
32738 #ifdef CONFIG_PCI_BIOS
32739 if (!rt->signature) {
32740 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32741 return 0;
32742 }
32743
32744 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32745 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32746 {
32747 .callback = fix_broken_hp_bios_irq9,
32748 .ident = "HP Pavilion N5400 Series Laptop",
32749 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32750 index 903fded..94b0d88 100644
32751 --- a/arch/x86/pci/mrst.c
32752 +++ b/arch/x86/pci/mrst.c
32753 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
32754 pr_info("Intel MID platform detected, using MID PCI ops\n");
32755 pci_mmcfg_late_init();
32756 pcibios_enable_irq = mrst_pci_irq_enable;
32757 - pci_root_ops = pci_mrst_ops;
32758 + pax_open_kernel();
32759 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32760 + pax_close_kernel();
32761 pci_soc_mode = 1;
32762 /* Continue with standard init */
32763 return 1;
32764 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32765 index c77b24a..c979855 100644
32766 --- a/arch/x86/pci/pcbios.c
32767 +++ b/arch/x86/pci/pcbios.c
32768 @@ -79,7 +79,7 @@ union bios32 {
32769 static struct {
32770 unsigned long address;
32771 unsigned short segment;
32772 -} bios32_indirect = { 0, __KERNEL_CS };
32773 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32774
32775 /*
32776 * Returns the entry point for the given service, NULL on error
32777 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32778 unsigned long length; /* %ecx */
32779 unsigned long entry; /* %edx */
32780 unsigned long flags;
32781 + struct desc_struct d, *gdt;
32782
32783 local_irq_save(flags);
32784 - __asm__("lcall *(%%edi); cld"
32785 +
32786 + gdt = get_cpu_gdt_table(smp_processor_id());
32787 +
32788 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32789 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32790 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32791 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32792 +
32793 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32794 : "=a" (return_code),
32795 "=b" (address),
32796 "=c" (length),
32797 "=d" (entry)
32798 : "0" (service),
32799 "1" (0),
32800 - "D" (&bios32_indirect));
32801 + "D" (&bios32_indirect),
32802 + "r"(__PCIBIOS_DS)
32803 + : "memory");
32804 +
32805 + pax_open_kernel();
32806 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32807 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32808 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32809 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32810 + pax_close_kernel();
32811 +
32812 local_irq_restore(flags);
32813
32814 switch (return_code) {
32815 - case 0:
32816 - return address + entry;
32817 - case 0x80: /* Not present */
32818 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32819 - return 0;
32820 - default: /* Shouldn't happen */
32821 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32822 - service, return_code);
32823 + case 0: {
32824 + int cpu;
32825 + unsigned char flags;
32826 +
32827 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32828 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32829 + printk(KERN_WARNING "bios32_service: not valid\n");
32830 return 0;
32831 + }
32832 + address = address + PAGE_OFFSET;
32833 + length += 16UL; /* some BIOSs underreport this... */
32834 + flags = 4;
32835 + if (length >= 64*1024*1024) {
32836 + length >>= PAGE_SHIFT;
32837 + flags |= 8;
32838 + }
32839 +
32840 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32841 + gdt = get_cpu_gdt_table(cpu);
32842 + pack_descriptor(&d, address, length, 0x9b, flags);
32843 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32844 + pack_descriptor(&d, address, length, 0x93, flags);
32845 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32846 + }
32847 + return entry;
32848 + }
32849 + case 0x80: /* Not present */
32850 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32851 + return 0;
32852 + default: /* Shouldn't happen */
32853 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32854 + service, return_code);
32855 + return 0;
32856 }
32857 }
32858
32859 static struct {
32860 unsigned long address;
32861 unsigned short segment;
32862 -} pci_indirect = { 0, __KERNEL_CS };
32863 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32864
32865 -static int pci_bios_present;
32866 +static int pci_bios_present __read_only;
32867
32868 static int check_pcibios(void)
32869 {
32870 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32871 unsigned long flags, pcibios_entry;
32872
32873 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32874 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32875 + pci_indirect.address = pcibios_entry;
32876
32877 local_irq_save(flags);
32878 - __asm__(
32879 - "lcall *(%%edi); cld\n\t"
32880 + __asm__("movw %w6, %%ds\n\t"
32881 + "lcall *%%ss:(%%edi); cld\n\t"
32882 + "push %%ss\n\t"
32883 + "pop %%ds\n\t"
32884 "jc 1f\n\t"
32885 "xor %%ah, %%ah\n"
32886 "1:"
32887 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32888 "=b" (ebx),
32889 "=c" (ecx)
32890 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32891 - "D" (&pci_indirect)
32892 + "D" (&pci_indirect),
32893 + "r" (__PCIBIOS_DS)
32894 : "memory");
32895 local_irq_restore(flags);
32896
32897 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32898
32899 switch (len) {
32900 case 1:
32901 - __asm__("lcall *(%%esi); cld\n\t"
32902 + __asm__("movw %w6, %%ds\n\t"
32903 + "lcall *%%ss:(%%esi); cld\n\t"
32904 + "push %%ss\n\t"
32905 + "pop %%ds\n\t"
32906 "jc 1f\n\t"
32907 "xor %%ah, %%ah\n"
32908 "1:"
32909 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32910 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32911 "b" (bx),
32912 "D" ((long)reg),
32913 - "S" (&pci_indirect));
32914 + "S" (&pci_indirect),
32915 + "r" (__PCIBIOS_DS));
32916 /*
32917 * Zero-extend the result beyond 8 bits, do not trust the
32918 * BIOS having done it:
32919 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32920 *value &= 0xff;
32921 break;
32922 case 2:
32923 - __asm__("lcall *(%%esi); cld\n\t"
32924 + __asm__("movw %w6, %%ds\n\t"
32925 + "lcall *%%ss:(%%esi); cld\n\t"
32926 + "push %%ss\n\t"
32927 + "pop %%ds\n\t"
32928 "jc 1f\n\t"
32929 "xor %%ah, %%ah\n"
32930 "1:"
32931 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32932 : "1" (PCIBIOS_READ_CONFIG_WORD),
32933 "b" (bx),
32934 "D" ((long)reg),
32935 - "S" (&pci_indirect));
32936 + "S" (&pci_indirect),
32937 + "r" (__PCIBIOS_DS));
32938 /*
32939 * Zero-extend the result beyond 16 bits, do not trust the
32940 * BIOS having done it:
32941 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32942 *value &= 0xffff;
32943 break;
32944 case 4:
32945 - __asm__("lcall *(%%esi); cld\n\t"
32946 + __asm__("movw %w6, %%ds\n\t"
32947 + "lcall *%%ss:(%%esi); cld\n\t"
32948 + "push %%ss\n\t"
32949 + "pop %%ds\n\t"
32950 "jc 1f\n\t"
32951 "xor %%ah, %%ah\n"
32952 "1:"
32953 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32954 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32955 "b" (bx),
32956 "D" ((long)reg),
32957 - "S" (&pci_indirect));
32958 + "S" (&pci_indirect),
32959 + "r" (__PCIBIOS_DS));
32960 break;
32961 }
32962
32963 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32964
32965 switch (len) {
32966 case 1:
32967 - __asm__("lcall *(%%esi); cld\n\t"
32968 + __asm__("movw %w6, %%ds\n\t"
32969 + "lcall *%%ss:(%%esi); cld\n\t"
32970 + "push %%ss\n\t"
32971 + "pop %%ds\n\t"
32972 "jc 1f\n\t"
32973 "xor %%ah, %%ah\n"
32974 "1:"
32975 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32976 "c" (value),
32977 "b" (bx),
32978 "D" ((long)reg),
32979 - "S" (&pci_indirect));
32980 + "S" (&pci_indirect),
32981 + "r" (__PCIBIOS_DS));
32982 break;
32983 case 2:
32984 - __asm__("lcall *(%%esi); cld\n\t"
32985 + __asm__("movw %w6, %%ds\n\t"
32986 + "lcall *%%ss:(%%esi); cld\n\t"
32987 + "push %%ss\n\t"
32988 + "pop %%ds\n\t"
32989 "jc 1f\n\t"
32990 "xor %%ah, %%ah\n"
32991 "1:"
32992 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32993 "c" (value),
32994 "b" (bx),
32995 "D" ((long)reg),
32996 - "S" (&pci_indirect));
32997 + "S" (&pci_indirect),
32998 + "r" (__PCIBIOS_DS));
32999 break;
33000 case 4:
33001 - __asm__("lcall *(%%esi); cld\n\t"
33002 + __asm__("movw %w6, %%ds\n\t"
33003 + "lcall *%%ss:(%%esi); cld\n\t"
33004 + "push %%ss\n\t"
33005 + "pop %%ds\n\t"
33006 "jc 1f\n\t"
33007 "xor %%ah, %%ah\n"
33008 "1:"
33009 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33010 "c" (value),
33011 "b" (bx),
33012 "D" ((long)reg),
33013 - "S" (&pci_indirect));
33014 + "S" (&pci_indirect),
33015 + "r" (__PCIBIOS_DS));
33016 break;
33017 }
33018
33019 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33020
33021 DBG("PCI: Fetching IRQ routing table... ");
33022 __asm__("push %%es\n\t"
33023 + "movw %w8, %%ds\n\t"
33024 "push %%ds\n\t"
33025 "pop %%es\n\t"
33026 - "lcall *(%%esi); cld\n\t"
33027 + "lcall *%%ss:(%%esi); cld\n\t"
33028 "pop %%es\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33035 "1" (0),
33036 "D" ((long) &opt),
33037 "S" (&pci_indirect),
33038 - "m" (opt)
33039 + "m" (opt),
33040 + "r" (__PCIBIOS_DS)
33041 : "memory");
33042 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33043 if (ret & 0xff00)
33044 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33045 {
33046 int ret;
33047
33048 - __asm__("lcall *(%%esi); cld\n\t"
33049 + __asm__("movw %w5, %%ds\n\t"
33050 + "lcall *%%ss:(%%esi); cld\n\t"
33051 + "push %%ss\n\t"
33052 + "pop %%ds\n"
33053 "jc 1f\n\t"
33054 "xor %%ah, %%ah\n"
33055 "1:"
33056 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33057 : "0" (PCIBIOS_SET_PCI_HW_INT),
33058 "b" ((dev->bus->number << 8) | dev->devfn),
33059 "c" ((irq << 8) | (pin + 10)),
33060 - "S" (&pci_indirect));
33061 + "S" (&pci_indirect),
33062 + "r" (__PCIBIOS_DS));
33063 return !(ret & 0xff00);
33064 }
33065 EXPORT_SYMBOL(pcibios_set_irq_routing);
33066 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33067 index 40e4469..d915bf9 100644
33068 --- a/arch/x86/platform/efi/efi_32.c
33069 +++ b/arch/x86/platform/efi/efi_32.c
33070 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33071 {
33072 struct desc_ptr gdt_descr;
33073
33074 +#ifdef CONFIG_PAX_KERNEXEC
33075 + struct desc_struct d;
33076 +#endif
33077 +
33078 local_irq_save(efi_rt_eflags);
33079
33080 load_cr3(initial_page_table);
33081 __flush_tlb_all();
33082
33083 +#ifdef CONFIG_PAX_KERNEXEC
33084 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33085 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33086 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33087 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33088 +#endif
33089 +
33090 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33091 gdt_descr.size = GDT_SIZE - 1;
33092 load_gdt(&gdt_descr);
33093 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33094 {
33095 struct desc_ptr gdt_descr;
33096
33097 +#ifdef CONFIG_PAX_KERNEXEC
33098 + struct desc_struct d;
33099 +
33100 + memset(&d, 0, sizeof d);
33101 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33102 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33103 +#endif
33104 +
33105 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33106 gdt_descr.size = GDT_SIZE - 1;
33107 load_gdt(&gdt_descr);
33108
33109 +#ifdef CONFIG_PAX_PER_CPU_PGD
33110 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33111 +#else
33112 load_cr3(swapper_pg_dir);
33113 +#endif
33114 +
33115 __flush_tlb_all();
33116
33117 local_irq_restore(efi_rt_eflags);
33118 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33119 index 39a0e7f1..872396e 100644
33120 --- a/arch/x86/platform/efi/efi_64.c
33121 +++ b/arch/x86/platform/efi/efi_64.c
33122 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33123 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33124 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33125 }
33126 +
33127 +#ifdef CONFIG_PAX_PER_CPU_PGD
33128 + load_cr3(swapper_pg_dir);
33129 +#endif
33130 +
33131 __flush_tlb_all();
33132 }
33133
33134 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33135 for (pgd = 0; pgd < n_pgds; pgd++)
33136 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33137 kfree(save_pgd);
33138 +
33139 +#ifdef CONFIG_PAX_PER_CPU_PGD
33140 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33141 +#endif
33142 +
33143 __flush_tlb_all();
33144 local_irq_restore(efi_flags);
33145 early_code_mapping_set_exec(0);
33146 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33147 index fbe66e6..eae5e38 100644
33148 --- a/arch/x86/platform/efi/efi_stub_32.S
33149 +++ b/arch/x86/platform/efi/efi_stub_32.S
33150 @@ -6,7 +6,9 @@
33151 */
33152
33153 #include <linux/linkage.h>
33154 +#include <linux/init.h>
33155 #include <asm/page_types.h>
33156 +#include <asm/segment.h>
33157
33158 /*
33159 * efi_call_phys(void *, ...) is a function with variable parameters.
33160 @@ -20,7 +22,7 @@
33161 * service functions will comply with gcc calling convention, too.
33162 */
33163
33164 -.text
33165 +__INIT
33166 ENTRY(efi_call_phys)
33167 /*
33168 * 0. The function can only be called in Linux kernel. So CS has been
33169 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33170 * The mapping of lower virtual memory has been created in prelog and
33171 * epilog.
33172 */
33173 - movl $1f, %edx
33174 - subl $__PAGE_OFFSET, %edx
33175 - jmp *%edx
33176 +#ifdef CONFIG_PAX_KERNEXEC
33177 + movl $(__KERNEXEC_EFI_DS), %edx
33178 + mov %edx, %ds
33179 + mov %edx, %es
33180 + mov %edx, %ss
33181 + addl $2f,(1f)
33182 + ljmp *(1f)
33183 +
33184 +__INITDATA
33185 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33186 +.previous
33187 +
33188 +2:
33189 + subl $2b,(1b)
33190 +#else
33191 + jmp 1f-__PAGE_OFFSET
33192 1:
33193 +#endif
33194
33195 /*
33196 * 2. Now on the top of stack is the return
33197 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33198 * parameter 2, ..., param n. To make things easy, we save the return
33199 * address of efi_call_phys in a global variable.
33200 */
33201 - popl %edx
33202 - movl %edx, saved_return_addr
33203 - /* get the function pointer into ECX*/
33204 - popl %ecx
33205 - movl %ecx, efi_rt_function_ptr
33206 - movl $2f, %edx
33207 - subl $__PAGE_OFFSET, %edx
33208 - pushl %edx
33209 + popl (saved_return_addr)
33210 + popl (efi_rt_function_ptr)
33211
33212 /*
33213 * 3. Clear PG bit in %CR0.
33214 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33215 /*
33216 * 5. Call the physical function.
33217 */
33218 - jmp *%ecx
33219 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33220
33221 -2:
33222 /*
33223 * 6. After EFI runtime service returns, control will return to
33224 * following instruction. We'd better readjust stack pointer first.
33225 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33226 movl %cr0, %edx
33227 orl $0x80000000, %edx
33228 movl %edx, %cr0
33229 - jmp 1f
33230 -1:
33231 +
33232 /*
33233 * 8. Now restore the virtual mode from flat mode by
33234 * adding EIP with PAGE_OFFSET.
33235 */
33236 - movl $1f, %edx
33237 - jmp *%edx
33238 +#ifdef CONFIG_PAX_KERNEXEC
33239 + movl $(__KERNEL_DS), %edx
33240 + mov %edx, %ds
33241 + mov %edx, %es
33242 + mov %edx, %ss
33243 + ljmp $(__KERNEL_CS),$1f
33244 +#else
33245 + jmp 1f+__PAGE_OFFSET
33246 +#endif
33247 1:
33248
33249 /*
33250 * 9. Balance the stack. And because EAX contain the return value,
33251 * we'd better not clobber it.
33252 */
33253 - leal efi_rt_function_ptr, %edx
33254 - movl (%edx), %ecx
33255 - pushl %ecx
33256 + pushl (efi_rt_function_ptr)
33257
33258 /*
33259 - * 10. Push the saved return address onto the stack and return.
33260 + * 10. Return to the saved return address.
33261 */
33262 - leal saved_return_addr, %edx
33263 - movl (%edx), %ecx
33264 - pushl %ecx
33265 - ret
33266 + jmpl *(saved_return_addr)
33267 ENDPROC(efi_call_phys)
33268 .previous
33269
33270 -.data
33271 +__INITDATA
33272 saved_return_addr:
33273 .long 0
33274 efi_rt_function_ptr:
33275 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33276 index 4c07cca..2c8427d 100644
33277 --- a/arch/x86/platform/efi/efi_stub_64.S
33278 +++ b/arch/x86/platform/efi/efi_stub_64.S
33279 @@ -7,6 +7,7 @@
33280 */
33281
33282 #include <linux/linkage.h>
33283 +#include <asm/alternative-asm.h>
33284
33285 #define SAVE_XMM \
33286 mov %rsp, %rax; \
33287 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33288 call *%rdi
33289 addq $32, %rsp
33290 RESTORE_XMM
33291 + pax_force_retaddr 0, 1
33292 ret
33293 ENDPROC(efi_call0)
33294
33295 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33296 call *%rdi
33297 addq $32, %rsp
33298 RESTORE_XMM
33299 + pax_force_retaddr 0, 1
33300 ret
33301 ENDPROC(efi_call1)
33302
33303 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33304 call *%rdi
33305 addq $32, %rsp
33306 RESTORE_XMM
33307 + pax_force_retaddr 0, 1
33308 ret
33309 ENDPROC(efi_call2)
33310
33311 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33312 call *%rdi
33313 addq $32, %rsp
33314 RESTORE_XMM
33315 + pax_force_retaddr 0, 1
33316 ret
33317 ENDPROC(efi_call3)
33318
33319 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33320 call *%rdi
33321 addq $32, %rsp
33322 RESTORE_XMM
33323 + pax_force_retaddr 0, 1
33324 ret
33325 ENDPROC(efi_call4)
33326
33327 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33328 call *%rdi
33329 addq $48, %rsp
33330 RESTORE_XMM
33331 + pax_force_retaddr 0, 1
33332 ret
33333 ENDPROC(efi_call5)
33334
33335 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33336 call *%rdi
33337 addq $48, %rsp
33338 RESTORE_XMM
33339 + pax_force_retaddr 0, 1
33340 ret
33341 ENDPROC(efi_call6)
33342 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33343 index 3ca5957..7909c18 100644
33344 --- a/arch/x86/platform/mrst/mrst.c
33345 +++ b/arch/x86/platform/mrst/mrst.c
33346 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33347 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33348 int sfi_mrtc_num;
33349
33350 -static void mrst_power_off(void)
33351 +static __noreturn void mrst_power_off(void)
33352 {
33353 + BUG();
33354 }
33355
33356 -static void mrst_reboot(void)
33357 +static __noreturn void mrst_reboot(void)
33358 {
33359 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33360 + BUG();
33361 }
33362
33363 /* parse all the mtimer info to a static mtimer array */
33364 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33365 index d6ee929..3637cb5 100644
33366 --- a/arch/x86/platform/olpc/olpc_dt.c
33367 +++ b/arch/x86/platform/olpc/olpc_dt.c
33368 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33369 return res;
33370 }
33371
33372 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33373 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33374 .nextprop = olpc_dt_nextprop,
33375 .getproplen = olpc_dt_getproplen,
33376 .getproperty = olpc_dt_getproperty,
33377 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33378 index 424f4c9..f2a2988 100644
33379 --- a/arch/x86/power/cpu.c
33380 +++ b/arch/x86/power/cpu.c
33381 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33382 static void fix_processor_context(void)
33383 {
33384 int cpu = smp_processor_id();
33385 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33386 -#ifdef CONFIG_X86_64
33387 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33388 - tss_desc tss;
33389 -#endif
33390 + struct tss_struct *t = init_tss + cpu;
33391 +
33392 set_tss_desc(cpu, t); /*
33393 * This just modifies memory; should not be
33394 * necessary. But... This is necessary, because
33395 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33396 */
33397
33398 #ifdef CONFIG_X86_64
33399 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33400 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33401 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33402 -
33403 syscall_init(); /* This sets MSR_*STAR and related */
33404 #endif
33405 load_TR_desc(); /* This does ltr */
33406 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33407 index a44f457..9140171 100644
33408 --- a/arch/x86/realmode/init.c
33409 +++ b/arch/x86/realmode/init.c
33410 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33411 __va(real_mode_header->trampoline_header);
33412
33413 #ifdef CONFIG_X86_32
33414 - trampoline_header->start = __pa_symbol(startup_32_smp);
33415 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33416 +
33417 +#ifdef CONFIG_PAX_KERNEXEC
33418 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33419 +#endif
33420 +
33421 + trampoline_header->boot_cs = __BOOT_CS;
33422 trampoline_header->gdt_limit = __BOOT_DS + 7;
33423 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33424 #else
33425 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33426 *trampoline_cr4_features = read_cr4();
33427
33428 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33429 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33430 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33431 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33432 #endif
33433 }
33434 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33435 index 8869287..d577672 100644
33436 --- a/arch/x86/realmode/rm/Makefile
33437 +++ b/arch/x86/realmode/rm/Makefile
33438 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33439 $(call cc-option, -fno-unit-at-a-time)) \
33440 $(call cc-option, -fno-stack-protector) \
33441 $(call cc-option, -mpreferred-stack-boundary=2)
33442 +ifdef CONSTIFY_PLUGIN
33443 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33444 +endif
33445 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33446 GCOV_PROFILE := n
33447 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33448 index a28221d..93c40f1 100644
33449 --- a/arch/x86/realmode/rm/header.S
33450 +++ b/arch/x86/realmode/rm/header.S
33451 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33452 #endif
33453 /* APM/BIOS reboot */
33454 .long pa_machine_real_restart_asm
33455 -#ifdef CONFIG_X86_64
33456 +#ifdef CONFIG_X86_32
33457 + .long __KERNEL_CS
33458 +#else
33459 .long __KERNEL32_CS
33460 #endif
33461 END(real_mode_header)
33462 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33463 index c1b2791..f9e31c7 100644
33464 --- a/arch/x86/realmode/rm/trampoline_32.S
33465 +++ b/arch/x86/realmode/rm/trampoline_32.S
33466 @@ -25,6 +25,12 @@
33467 #include <asm/page_types.h>
33468 #include "realmode.h"
33469
33470 +#ifdef CONFIG_PAX_KERNEXEC
33471 +#define ta(X) (X)
33472 +#else
33473 +#define ta(X) (pa_ ## X)
33474 +#endif
33475 +
33476 .text
33477 .code16
33478
33479 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33480
33481 cli # We should be safe anyway
33482
33483 - movl tr_start, %eax # where we need to go
33484 -
33485 movl $0xA5A5A5A5, trampoline_status
33486 # write marker for master knows we're running
33487
33488 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33489 movw $1, %dx # protected mode (PE) bit
33490 lmsw %dx # into protected mode
33491
33492 - ljmpl $__BOOT_CS, $pa_startup_32
33493 + ljmpl *(trampoline_header)
33494
33495 .section ".text32","ax"
33496 .code32
33497 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33498 .balign 8
33499 GLOBAL(trampoline_header)
33500 tr_start: .space 4
33501 - tr_gdt_pad: .space 2
33502 + tr_boot_cs: .space 2
33503 tr_gdt: .space 6
33504 END(trampoline_header)
33505
33506 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33507 index bb360dc..d0fd8f8 100644
33508 --- a/arch/x86/realmode/rm/trampoline_64.S
33509 +++ b/arch/x86/realmode/rm/trampoline_64.S
33510 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33511 movl %edx, %gs
33512
33513 movl pa_tr_cr4, %eax
33514 + andl $~X86_CR4_PCIDE, %eax
33515 movl %eax, %cr4 # Enable PAE mode
33516
33517 # Setup trampoline 4 level pagetables
33518 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33519 wrmsr
33520
33521 # Enable paging and in turn activate Long Mode
33522 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33523 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33524 movl %eax, %cr0
33525
33526 /*
33527 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33528 index e812034..c747134 100644
33529 --- a/arch/x86/tools/Makefile
33530 +++ b/arch/x86/tools/Makefile
33531 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33532
33533 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
33534
33535 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33536 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33537 hostprogs-y += relocs
33538 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33539 relocs: $(obj)/relocs
33540 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33541 index f7bab68..b6d9886 100644
33542 --- a/arch/x86/tools/relocs.c
33543 +++ b/arch/x86/tools/relocs.c
33544 @@ -1,5 +1,7 @@
33545 /* This is included from relocs_32/64.c */
33546
33547 +#include "../../../include/generated/autoconf.h"
33548 +
33549 #define ElfW(type) _ElfW(ELF_BITS, type)
33550 #define _ElfW(bits, type) __ElfW(bits, type)
33551 #define __ElfW(bits, type) Elf##bits##_##type
33552 @@ -11,6 +13,7 @@
33553 #define Elf_Sym ElfW(Sym)
33554
33555 static Elf_Ehdr ehdr;
33556 +static Elf_Phdr *phdr;
33557
33558 struct relocs {
33559 uint32_t *offset;
33560 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33561 }
33562 }
33563
33564 +static void read_phdrs(FILE *fp)
33565 +{
33566 + unsigned int i;
33567 +
33568 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33569 + if (!phdr) {
33570 + die("Unable to allocate %d program headers\n",
33571 + ehdr.e_phnum);
33572 + }
33573 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33574 + die("Seek to %d failed: %s\n",
33575 + ehdr.e_phoff, strerror(errno));
33576 + }
33577 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33578 + die("Cannot read ELF program headers: %s\n",
33579 + strerror(errno));
33580 + }
33581 + for(i = 0; i < ehdr.e_phnum; i++) {
33582 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33583 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33584 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33585 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33586 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33587 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33588 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33589 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33590 + }
33591 +
33592 +}
33593 +
33594 static void read_shdrs(FILE *fp)
33595 {
33596 - int i;
33597 + unsigned int i;
33598 Elf_Shdr shdr;
33599
33600 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33601 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33602
33603 static void read_strtabs(FILE *fp)
33604 {
33605 - int i;
33606 + unsigned int i;
33607 for (i = 0; i < ehdr.e_shnum; i++) {
33608 struct section *sec = &secs[i];
33609 if (sec->shdr.sh_type != SHT_STRTAB) {
33610 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33611
33612 static void read_symtabs(FILE *fp)
33613 {
33614 - int i,j;
33615 + unsigned int i,j;
33616 for (i = 0; i < ehdr.e_shnum; i++) {
33617 struct section *sec = &secs[i];
33618 if (sec->shdr.sh_type != SHT_SYMTAB) {
33619 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33620 }
33621
33622
33623 -static void read_relocs(FILE *fp)
33624 +static void read_relocs(FILE *fp, int use_real_mode)
33625 {
33626 - int i,j;
33627 + unsigned int i,j;
33628 + uint32_t base;
33629 +
33630 for (i = 0; i < ehdr.e_shnum; i++) {
33631 struct section *sec = &secs[i];
33632 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33633 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33634 die("Cannot read symbol table: %s\n",
33635 strerror(errno));
33636 }
33637 + base = 0;
33638 +
33639 +#ifdef CONFIG_X86_32
33640 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33641 + if (phdr[j].p_type != PT_LOAD )
33642 + continue;
33643 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
33644 + continue;
33645 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33646 + break;
33647 + }
33648 +#endif
33649 +
33650 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33651 Elf_Rel *rel = &sec->reltab[j];
33652 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33653 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33654 rel->r_info = elf_xword_to_cpu(rel->r_info);
33655 #if (SHT_REL_TYPE == SHT_RELA)
33656 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33657 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33658
33659 static void print_absolute_symbols(void)
33660 {
33661 - int i;
33662 + unsigned int i;
33663 const char *format;
33664
33665 if (ELF_BITS == 64)
33666 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33667 for (i = 0; i < ehdr.e_shnum; i++) {
33668 struct section *sec = &secs[i];
33669 char *sym_strtab;
33670 - int j;
33671 + unsigned int j;
33672
33673 if (sec->shdr.sh_type != SHT_SYMTAB) {
33674 continue;
33675 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33676
33677 static void print_absolute_relocs(void)
33678 {
33679 - int i, printed = 0;
33680 + unsigned int i, printed = 0;
33681 const char *format;
33682
33683 if (ELF_BITS == 64)
33684 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33685 struct section *sec_applies, *sec_symtab;
33686 char *sym_strtab;
33687 Elf_Sym *sh_symtab;
33688 - int j;
33689 + unsigned int j;
33690 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33691 continue;
33692 }
33693 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33694 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33695 Elf_Sym *sym, const char *symname))
33696 {
33697 - int i;
33698 + unsigned int i;
33699 /* Walk through the relocations */
33700 for (i = 0; i < ehdr.e_shnum; i++) {
33701 char *sym_strtab;
33702 Elf_Sym *sh_symtab;
33703 struct section *sec_applies, *sec_symtab;
33704 - int j;
33705 + unsigned int j;
33706 struct section *sec = &secs[i];
33707
33708 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33709 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33710 {
33711 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33712 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33713 + char *sym_strtab = sec->link->link->strtab;
33714 +
33715 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33716 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33717 + return 0;
33718 +
33719 +#ifdef CONFIG_PAX_KERNEXEC
33720 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33721 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33722 + return 0;
33723 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33724 + return 0;
33725 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33726 + return 0;
33727 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33728 + return 0;
33729 +#endif
33730
33731 switch (r_type) {
33732 case R_386_NONE:
33733 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33734
33735 static void emit_relocs(int as_text, int use_real_mode)
33736 {
33737 - int i;
33738 + unsigned int i;
33739 int (*write_reloc)(uint32_t, FILE *) = write32;
33740 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33741 const char *symname);
33742 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33743 {
33744 regex_init(use_real_mode);
33745 read_ehdr(fp);
33746 + read_phdrs(fp);
33747 read_shdrs(fp);
33748 read_strtabs(fp);
33749 read_symtabs(fp);
33750 - read_relocs(fp);
33751 + read_relocs(fp, use_real_mode);
33752 if (ELF_BITS == 64)
33753 percpu_init();
33754 if (show_absolute_syms) {
33755 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33756 index 80ffa5b..a33bd15 100644
33757 --- a/arch/x86/um/tls_32.c
33758 +++ b/arch/x86/um/tls_32.c
33759 @@ -260,7 +260,7 @@ out:
33760 if (unlikely(task == current &&
33761 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33762 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33763 - "without flushed TLS.", current->pid);
33764 + "without flushed TLS.", task_pid_nr(current));
33765 }
33766
33767 return 0;
33768 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33769 index fd14be1..e3c79c0 100644
33770 --- a/arch/x86/vdso/Makefile
33771 +++ b/arch/x86/vdso/Makefile
33772 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33773 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33774 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33775
33776 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33777 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33778 GCOV_PROFILE := n
33779
33780 #
33781 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33782 index d6bfb87..876ee18 100644
33783 --- a/arch/x86/vdso/vdso32-setup.c
33784 +++ b/arch/x86/vdso/vdso32-setup.c
33785 @@ -25,6 +25,7 @@
33786 #include <asm/tlbflush.h>
33787 #include <asm/vdso.h>
33788 #include <asm/proto.h>
33789 +#include <asm/mman.h>
33790
33791 enum {
33792 VDSO_DISABLED = 0,
33793 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33794 void enable_sep_cpu(void)
33795 {
33796 int cpu = get_cpu();
33797 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33798 + struct tss_struct *tss = init_tss + cpu;
33799
33800 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33801 put_cpu();
33802 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33803 gate_vma.vm_start = FIXADDR_USER_START;
33804 gate_vma.vm_end = FIXADDR_USER_END;
33805 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33806 - gate_vma.vm_page_prot = __P101;
33807 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33808
33809 return 0;
33810 }
33811 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33812 if (compat)
33813 addr = VDSO_HIGH_BASE;
33814 else {
33815 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33816 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33817 if (IS_ERR_VALUE(addr)) {
33818 ret = addr;
33819 goto up_fail;
33820 }
33821 }
33822
33823 - current->mm->context.vdso = (void *)addr;
33824 + current->mm->context.vdso = addr;
33825
33826 if (compat_uses_vma || !compat) {
33827 /*
33828 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33829 }
33830
33831 current_thread_info()->sysenter_return =
33832 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33833 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33834
33835 up_fail:
33836 if (ret)
33837 - current->mm->context.vdso = NULL;
33838 + current->mm->context.vdso = 0;
33839
33840 up_write(&mm->mmap_sem);
33841
33842 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33843
33844 const char *arch_vma_name(struct vm_area_struct *vma)
33845 {
33846 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33847 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33848 return "[vdso]";
33849 +
33850 +#ifdef CONFIG_PAX_SEGMEXEC
33851 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33852 + return "[vdso]";
33853 +#endif
33854 +
33855 return NULL;
33856 }
33857
33858 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33859 * Check to see if the corresponding task was created in compat vdso
33860 * mode.
33861 */
33862 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33863 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33864 return &gate_vma;
33865 return NULL;
33866 }
33867 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33868 index 431e875..cbb23f3 100644
33869 --- a/arch/x86/vdso/vma.c
33870 +++ b/arch/x86/vdso/vma.c
33871 @@ -16,8 +16,6 @@
33872 #include <asm/vdso.h>
33873 #include <asm/page.h>
33874
33875 -unsigned int __read_mostly vdso_enabled = 1;
33876 -
33877 extern char vdso_start[], vdso_end[];
33878 extern unsigned short vdso_sync_cpuid;
33879
33880 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33881 * unaligned here as a result of stack start randomization.
33882 */
33883 addr = PAGE_ALIGN(addr);
33884 - addr = align_vdso_addr(addr);
33885
33886 return addr;
33887 }
33888 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33889 unsigned size)
33890 {
33891 struct mm_struct *mm = current->mm;
33892 - unsigned long addr;
33893 + unsigned long addr = 0;
33894 int ret;
33895
33896 - if (!vdso_enabled)
33897 - return 0;
33898 -
33899 down_write(&mm->mmap_sem);
33900 +
33901 +#ifdef CONFIG_PAX_RANDMMAP
33902 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33903 +#endif
33904 +
33905 addr = vdso_addr(mm->start_stack, size);
33906 + addr = align_vdso_addr(addr);
33907 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33908 if (IS_ERR_VALUE(addr)) {
33909 ret = addr;
33910 goto up_fail;
33911 }
33912
33913 - current->mm->context.vdso = (void *)addr;
33914 + mm->context.vdso = addr;
33915
33916 ret = install_special_mapping(mm, addr, size,
33917 VM_READ|VM_EXEC|
33918 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33919 pages);
33920 - if (ret) {
33921 - current->mm->context.vdso = NULL;
33922 - goto up_fail;
33923 - }
33924 + if (ret)
33925 + mm->context.vdso = 0;
33926
33927 up_fail:
33928 up_write(&mm->mmap_sem);
33929 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33930 vdsox32_size);
33931 }
33932 #endif
33933 -
33934 -static __init int vdso_setup(char *s)
33935 -{
33936 - vdso_enabled = simple_strtoul(s, NULL, 0);
33937 - return 0;
33938 -}
33939 -__setup("vdso=", vdso_setup);
33940 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33941 index fa6ade7..73da73a5 100644
33942 --- a/arch/x86/xen/enlighten.c
33943 +++ b/arch/x86/xen/enlighten.c
33944 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33945
33946 struct shared_info xen_dummy_shared_info;
33947
33948 -void *xen_initial_gdt;
33949 -
33950 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33951 __read_mostly int xen_have_vector_callback;
33952 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33953 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33954 {
33955 unsigned long va = dtr->address;
33956 unsigned int size = dtr->size + 1;
33957 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33958 - unsigned long frames[pages];
33959 + unsigned long frames[65536 / PAGE_SIZE];
33960 int f;
33961
33962 /*
33963 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33964 {
33965 unsigned long va = dtr->address;
33966 unsigned int size = dtr->size + 1;
33967 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33968 - unsigned long frames[pages];
33969 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33970 int f;
33971
33972 /*
33973 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33974 * 8-byte entries, or 16 4k pages..
33975 */
33976
33977 - BUG_ON(size > 65536);
33978 + BUG_ON(size > GDT_SIZE);
33979 BUG_ON(va & ~PAGE_MASK);
33980
33981 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33982 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33983 return 0;
33984 }
33985
33986 -static void set_xen_basic_apic_ops(void)
33987 +static void __init set_xen_basic_apic_ops(void)
33988 {
33989 apic->read = xen_apic_read;
33990 apic->write = xen_apic_write;
33991 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33992 #endif
33993 };
33994
33995 -static void xen_reboot(int reason)
33996 +static __noreturn void xen_reboot(int reason)
33997 {
33998 struct sched_shutdown r = { .reason = reason };
33999
34000 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34001 - BUG();
34002 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34003 + BUG();
34004 }
34005
34006 -static void xen_restart(char *msg)
34007 +static __noreturn void xen_restart(char *msg)
34008 {
34009 xen_reboot(SHUTDOWN_reboot);
34010 }
34011
34012 -static void xen_emergency_restart(void)
34013 +static __noreturn void xen_emergency_restart(void)
34014 {
34015 xen_reboot(SHUTDOWN_reboot);
34016 }
34017
34018 -static void xen_machine_halt(void)
34019 +static __noreturn void xen_machine_halt(void)
34020 {
34021 xen_reboot(SHUTDOWN_poweroff);
34022 }
34023
34024 -static void xen_machine_power_off(void)
34025 +static __noreturn void xen_machine_power_off(void)
34026 {
34027 if (pm_power_off)
34028 pm_power_off();
34029 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34030 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34031
34032 /* Work out if we support NX */
34033 - x86_configure_nx();
34034 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34035 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34036 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34037 + unsigned l, h;
34038 +
34039 + __supported_pte_mask |= _PAGE_NX;
34040 + rdmsr(MSR_EFER, l, h);
34041 + l |= EFER_NX;
34042 + wrmsr(MSR_EFER, l, h);
34043 + }
34044 +#endif
34045
34046 xen_setup_features();
34047
34048 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34049
34050 machine_ops = xen_machine_ops;
34051
34052 - /*
34053 - * The only reliable way to retain the initial address of the
34054 - * percpu gdt_page is to remember it here, so we can go and
34055 - * mark it RW later, when the initial percpu area is freed.
34056 - */
34057 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34058 -
34059 xen_smp_init();
34060
34061 #ifdef CONFIG_ACPI_NUMA
34062 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34063 index fdc3ba2..23cae00 100644
34064 --- a/arch/x86/xen/mmu.c
34065 +++ b/arch/x86/xen/mmu.c
34066 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34067 return val;
34068 }
34069
34070 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34071 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34072 {
34073 if (val & _PAGE_PRESENT) {
34074 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34075 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34076 /* L3_k[510] -> level2_kernel_pgt
34077 * L3_i[511] -> level2_fixmap_pgt */
34078 convert_pfn_mfn(level3_kernel_pgt);
34079 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34080 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34081 + convert_pfn_mfn(level3_vmemmap_pgt);
34082
34083 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34084 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34085 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34086 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34087 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34088 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34089 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34090 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34091 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34092 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34093 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34094 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34095 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34096 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34097
34098 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34099 pv_mmu_ops.set_pud = xen_set_pud;
34100 #if PAGETABLE_LEVELS == 4
34101 pv_mmu_ops.set_pgd = xen_set_pgd;
34102 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34103 #endif
34104
34105 /* This will work as long as patching hasn't happened yet
34106 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34107 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34108 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34109 .set_pgd = xen_set_pgd_hyper,
34110 + .set_pgd_batched = xen_set_pgd_hyper,
34111
34112 .alloc_pud = xen_alloc_pmd_init,
34113 .release_pud = xen_release_pmd_init,
34114 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34115 index 31d0475..51af671 100644
34116 --- a/arch/x86/xen/smp.c
34117 +++ b/arch/x86/xen/smp.c
34118 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34119 native_smp_prepare_boot_cpu();
34120
34121 if (xen_pv_domain()) {
34122 - /* We've switched to the "real" per-cpu gdt, so make sure the
34123 - old memory can be recycled */
34124 - make_lowmem_page_readwrite(xen_initial_gdt);
34125 -
34126 #ifdef CONFIG_X86_32
34127 /*
34128 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34129 * expects __USER_DS
34130 */
34131 - loadsegment(ds, __USER_DS);
34132 - loadsegment(es, __USER_DS);
34133 + loadsegment(ds, __KERNEL_DS);
34134 + loadsegment(es, __KERNEL_DS);
34135 #endif
34136
34137 xen_filter_cpu_maps();
34138 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34139 ctxt->user_regs.ss = __KERNEL_DS;
34140 #ifdef CONFIG_X86_32
34141 ctxt->user_regs.fs = __KERNEL_PERCPU;
34142 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34143 + savesegment(gs, ctxt->user_regs.gs);
34144 #else
34145 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34146 #endif
34147 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34148
34149 {
34150 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34151 - ctxt->user_regs.ds = __USER_DS;
34152 - ctxt->user_regs.es = __USER_DS;
34153 + ctxt->user_regs.ds = __KERNEL_DS;
34154 + ctxt->user_regs.es = __KERNEL_DS;
34155
34156 xen_copy_trap_info(ctxt->trap_ctxt);
34157
34158 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34159 int rc;
34160
34161 per_cpu(current_task, cpu) = idle;
34162 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34163 #ifdef CONFIG_X86_32
34164 irq_ctx_init(cpu);
34165 #else
34166 clear_tsk_thread_flag(idle, TIF_FORK);
34167 - per_cpu(kernel_stack, cpu) =
34168 - (unsigned long)task_stack_page(idle) -
34169 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34170 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34171 #endif
34172 xen_setup_runstate_info(cpu);
34173 xen_setup_timer(cpu);
34174 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34175
34176 void __init xen_smp_init(void)
34177 {
34178 - smp_ops = xen_smp_ops;
34179 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34180 xen_fill_possible_map();
34181 }
34182
34183 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34184 index 33ca6e4..0ded929 100644
34185 --- a/arch/x86/xen/xen-asm_32.S
34186 +++ b/arch/x86/xen/xen-asm_32.S
34187 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34188 ESP_OFFSET=4 # bytes pushed onto stack
34189
34190 /*
34191 - * Store vcpu_info pointer for easy access. Do it this way to
34192 - * avoid having to reload %fs
34193 + * Store vcpu_info pointer for easy access.
34194 */
34195 #ifdef CONFIG_SMP
34196 - GET_THREAD_INFO(%eax)
34197 - movl %ss:TI_cpu(%eax), %eax
34198 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34199 - mov %ss:xen_vcpu(%eax), %eax
34200 + push %fs
34201 + mov $(__KERNEL_PERCPU), %eax
34202 + mov %eax, %fs
34203 + mov PER_CPU_VAR(xen_vcpu), %eax
34204 + pop %fs
34205 #else
34206 movl %ss:xen_vcpu, %eax
34207 #endif
34208 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34209 index 7faed58..ba4427c 100644
34210 --- a/arch/x86/xen/xen-head.S
34211 +++ b/arch/x86/xen/xen-head.S
34212 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34213 #ifdef CONFIG_X86_32
34214 mov %esi,xen_start_info
34215 mov $init_thread_union+THREAD_SIZE,%esp
34216 +#ifdef CONFIG_SMP
34217 + movl $cpu_gdt_table,%edi
34218 + movl $__per_cpu_load,%eax
34219 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34220 + rorl $16,%eax
34221 + movb %al,__KERNEL_PERCPU + 4(%edi)
34222 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34223 + movl $__per_cpu_end - 1,%eax
34224 + subl $__per_cpu_start,%eax
34225 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34226 +#endif
34227 #else
34228 mov %rsi,xen_start_info
34229 mov $init_thread_union+THREAD_SIZE,%rsp
34230 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34231 index 95f8c61..611d6e8 100644
34232 --- a/arch/x86/xen/xen-ops.h
34233 +++ b/arch/x86/xen/xen-ops.h
34234 @@ -10,8 +10,6 @@
34235 extern const char xen_hypervisor_callback[];
34236 extern const char xen_failsafe_callback[];
34237
34238 -extern void *xen_initial_gdt;
34239 -
34240 struct trap_info;
34241 void xen_copy_trap_info(struct trap_info *traps);
34242
34243 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34244 index 525bd3d..ef888b1 100644
34245 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34246 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34247 @@ -119,9 +119,9 @@
34248 ----------------------------------------------------------------------*/
34249
34250 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34251 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34252 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34253 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34254 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34255
34256 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34257 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34258 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34259 index 2f33760..835e50a 100644
34260 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34261 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34262 @@ -11,6 +11,7 @@
34263 #ifndef _XTENSA_CORE_H
34264 #define _XTENSA_CORE_H
34265
34266 +#include <linux/const.h>
34267
34268 /****************************************************************************
34269 Parameters Useful for Any Code, USER or PRIVILEGED
34270 @@ -112,9 +113,9 @@
34271 ----------------------------------------------------------------------*/
34272
34273 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34274 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34275 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34276 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34277 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34278
34279 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34280 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34281 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34282 index af00795..2bb8105 100644
34283 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34284 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34285 @@ -11,6 +11,7 @@
34286 #ifndef _XTENSA_CORE_CONFIGURATION_H
34287 #define _XTENSA_CORE_CONFIGURATION_H
34288
34289 +#include <linux/const.h>
34290
34291 /****************************************************************************
34292 Parameters Useful for Any Code, USER or PRIVILEGED
34293 @@ -118,9 +119,9 @@
34294 ----------------------------------------------------------------------*/
34295
34296 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34297 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34298 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34299 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34300 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34301
34302 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34303 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34304 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34305 index 4e491d9..c8e18e4 100644
34306 --- a/block/blk-cgroup.c
34307 +++ b/block/blk-cgroup.c
34308 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
34309 static struct cgroup_subsys_state *
34310 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34311 {
34312 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34313 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34314 struct blkcg *blkcg;
34315
34316 if (!parent_css) {
34317 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34318
34319 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34320 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34321 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34322 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34323 done:
34324 spin_lock_init(&blkcg->lock);
34325 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34326 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34327 index 4b8d9b54..a7178c0 100644
34328 --- a/block/blk-iopoll.c
34329 +++ b/block/blk-iopoll.c
34330 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34331 }
34332 EXPORT_SYMBOL(blk_iopoll_complete);
34333
34334 -static void blk_iopoll_softirq(struct softirq_action *h)
34335 +static __latent_entropy void blk_iopoll_softirq(void)
34336 {
34337 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34338 int rearm = 0, budget = blk_iopoll_budget;
34339 diff --git a/block/blk-map.c b/block/blk-map.c
34340 index 623e1cd..ca1e109 100644
34341 --- a/block/blk-map.c
34342 +++ b/block/blk-map.c
34343 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34344 if (!len || !kbuf)
34345 return -EINVAL;
34346
34347 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34348 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34349 if (do_copy)
34350 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34351 else
34352 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34353 index ec9e606..3f38839 100644
34354 --- a/block/blk-softirq.c
34355 +++ b/block/blk-softirq.c
34356 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34357 * Softirq action handler - move entries to local list and loop over them
34358 * while passing them to the queue registered handler.
34359 */
34360 -static void blk_done_softirq(struct softirq_action *h)
34361 +static __latent_entropy void blk_done_softirq(void)
34362 {
34363 struct list_head *cpu_list, local_list;
34364
34365 diff --git a/block/bsg.c b/block/bsg.c
34366 index 420a5a9..23834aa 100644
34367 --- a/block/bsg.c
34368 +++ b/block/bsg.c
34369 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34370 struct sg_io_v4 *hdr, struct bsg_device *bd,
34371 fmode_t has_write_perm)
34372 {
34373 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34374 + unsigned char *cmdptr;
34375 +
34376 if (hdr->request_len > BLK_MAX_CDB) {
34377 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34378 if (!rq->cmd)
34379 return -ENOMEM;
34380 - }
34381 + cmdptr = rq->cmd;
34382 + } else
34383 + cmdptr = tmpcmd;
34384
34385 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34386 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34387 hdr->request_len))
34388 return -EFAULT;
34389
34390 + if (cmdptr != rq->cmd)
34391 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34392 +
34393 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34394 if (blk_verify_command(rq->cmd, has_write_perm))
34395 return -EPERM;
34396 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34397 index fbd5a67..5d631b5 100644
34398 --- a/block/compat_ioctl.c
34399 +++ b/block/compat_ioctl.c
34400 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34401 err |= __get_user(f->spec1, &uf->spec1);
34402 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34403 err |= __get_user(name, &uf->name);
34404 - f->name = compat_ptr(name);
34405 + f->name = (void __force_kernel *)compat_ptr(name);
34406 if (err) {
34407 err = -EFAULT;
34408 goto out;
34409 diff --git a/block/genhd.c b/block/genhd.c
34410 index 791f419..89f21c4 100644
34411 --- a/block/genhd.c
34412 +++ b/block/genhd.c
34413 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34414
34415 /*
34416 * Register device numbers dev..(dev+range-1)
34417 - * range must be nonzero
34418 + * Noop if @range is zero.
34419 * The hash chain is sorted on range, so that subranges can override.
34420 */
34421 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34422 struct kobject *(*probe)(dev_t, int *, void *),
34423 int (*lock)(dev_t, void *), void *data)
34424 {
34425 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34426 + if (range)
34427 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34428 }
34429
34430 EXPORT_SYMBOL(blk_register_region);
34431
34432 +/* undo blk_register_region(), noop if @range is zero */
34433 void blk_unregister_region(dev_t devt, unsigned long range)
34434 {
34435 - kobj_unmap(bdev_map, devt, range);
34436 + if (range)
34437 + kobj_unmap(bdev_map, devt, range);
34438 }
34439
34440 EXPORT_SYMBOL(blk_unregister_region);
34441 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34442 index a8287b4..241a48e 100644
34443 --- a/block/partitions/efi.c
34444 +++ b/block/partitions/efi.c
34445 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34446 if (!gpt)
34447 return NULL;
34448
34449 + if (!le32_to_cpu(gpt->num_partition_entries))
34450 + return NULL;
34451 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34452 + if (!pte)
34453 + return NULL;
34454 +
34455 count = le32_to_cpu(gpt->num_partition_entries) *
34456 le32_to_cpu(gpt->sizeof_partition_entry);
34457 - if (!count)
34458 - return NULL;
34459 - pte = kmalloc(count, GFP_KERNEL);
34460 - if (!pte)
34461 - return NULL;
34462 -
34463 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34464 (u8 *) pte, count) < count) {
34465 kfree(pte);
34466 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34467 index a5ffcc9..e057498 100644
34468 --- a/block/scsi_ioctl.c
34469 +++ b/block/scsi_ioctl.c
34470 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
34471 return put_user(0, p);
34472 }
34473
34474 -static int sg_get_timeout(struct request_queue *q)
34475 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
34476 {
34477 return jiffies_to_clock_t(q->sg_timeout);
34478 }
34479 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34480 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34481 struct sg_io_hdr *hdr, fmode_t mode)
34482 {
34483 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34484 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34485 + unsigned char *cmdptr;
34486 +
34487 + if (rq->cmd != rq->__cmd)
34488 + cmdptr = rq->cmd;
34489 + else
34490 + cmdptr = tmpcmd;
34491 +
34492 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34493 return -EFAULT;
34494 +
34495 + if (cmdptr != rq->cmd)
34496 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34497 +
34498 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34499 return -EPERM;
34500
34501 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34502 int err;
34503 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34504 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34505 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34506 + unsigned char *cmdptr;
34507
34508 if (!sic)
34509 return -EINVAL;
34510 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34511 */
34512 err = -EFAULT;
34513 rq->cmd_len = cmdlen;
34514 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34515 +
34516 + if (rq->cmd != rq->__cmd)
34517 + cmdptr = rq->cmd;
34518 + else
34519 + cmdptr = tmpcmd;
34520 +
34521 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34522 goto error;
34523
34524 + if (rq->cmd != cmdptr)
34525 + memcpy(rq->cmd, cmdptr, cmdlen);
34526 +
34527 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34528 goto error;
34529
34530 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34531 index 7bdd61b..afec999 100644
34532 --- a/crypto/cryptd.c
34533 +++ b/crypto/cryptd.c
34534 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34535
34536 struct cryptd_blkcipher_request_ctx {
34537 crypto_completion_t complete;
34538 -};
34539 +} __no_const;
34540
34541 struct cryptd_hash_ctx {
34542 struct crypto_shash *child;
34543 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34544
34545 struct cryptd_aead_request_ctx {
34546 crypto_completion_t complete;
34547 -};
34548 +} __no_const;
34549
34550 static void cryptd_queue_worker(struct work_struct *work);
34551
34552 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34553 index f8c920c..ab2cb5a 100644
34554 --- a/crypto/pcrypt.c
34555 +++ b/crypto/pcrypt.c
34556 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34557 int ret;
34558
34559 pinst->kobj.kset = pcrypt_kset;
34560 - ret = kobject_add(&pinst->kobj, NULL, name);
34561 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34562 if (!ret)
34563 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34564
34565 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34566 index f220d64..d359ad6 100644
34567 --- a/drivers/acpi/apei/apei-internal.h
34568 +++ b/drivers/acpi/apei/apei-internal.h
34569 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34570 struct apei_exec_ins_type {
34571 u32 flags;
34572 apei_exec_ins_func_t run;
34573 -};
34574 +} __do_const;
34575
34576 struct apei_exec_context {
34577 u32 ip;
34578 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34579 index 33dc6a0..4b24b47 100644
34580 --- a/drivers/acpi/apei/cper.c
34581 +++ b/drivers/acpi/apei/cper.c
34582 @@ -39,12 +39,12 @@
34583 */
34584 u64 cper_next_record_id(void)
34585 {
34586 - static atomic64_t seq;
34587 + static atomic64_unchecked_t seq;
34588
34589 - if (!atomic64_read(&seq))
34590 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34591 + if (!atomic64_read_unchecked(&seq))
34592 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34593
34594 - return atomic64_inc_return(&seq);
34595 + return atomic64_inc_return_unchecked(&seq);
34596 }
34597 EXPORT_SYMBOL_GPL(cper_next_record_id);
34598
34599 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34600 index 8ec37bb..b0716e5 100644
34601 --- a/drivers/acpi/apei/ghes.c
34602 +++ b/drivers/acpi/apei/ghes.c
34603 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
34604 const struct acpi_hest_generic *generic,
34605 const struct acpi_hest_generic_status *estatus)
34606 {
34607 - static atomic_t seqno;
34608 + static atomic_unchecked_t seqno;
34609 unsigned int curr_seqno;
34610 char pfx_seq[64];
34611
34612 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
34613 else
34614 pfx = KERN_ERR;
34615 }
34616 - curr_seqno = atomic_inc_return(&seqno);
34617 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34618 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34619 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34620 pfx_seq, generic->header.source_id);
34621 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34622 index a83e3c6..c3d617f 100644
34623 --- a/drivers/acpi/bgrt.c
34624 +++ b/drivers/acpi/bgrt.c
34625 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
34626 if (!bgrt_image)
34627 return -ENODEV;
34628
34629 - bin_attr_image.private = bgrt_image;
34630 - bin_attr_image.size = bgrt_image_size;
34631 + pax_open_kernel();
34632 + *(void **)&bin_attr_image.private = bgrt_image;
34633 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
34634 + pax_close_kernel();
34635
34636 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34637 if (!bgrt_kobj)
34638 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34639 index 9515f18..4b149c9 100644
34640 --- a/drivers/acpi/blacklist.c
34641 +++ b/drivers/acpi/blacklist.c
34642 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34643 u32 is_critical_error;
34644 };
34645
34646 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34647 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34648
34649 /*
34650 * POLICY: If *anything* doesn't work, put it on the blacklist.
34651 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
34652 return 0;
34653 }
34654
34655 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34656 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34657 {
34658 .callback = dmi_disable_osi_vista,
34659 .ident = "Fujitsu Siemens",
34660 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34661 index f98dd00..7b69865 100644
34662 --- a/drivers/acpi/processor_idle.c
34663 +++ b/drivers/acpi/processor_idle.c
34664 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34665 {
34666 int i, count = CPUIDLE_DRIVER_STATE_START;
34667 struct acpi_processor_cx *cx;
34668 - struct cpuidle_state *state;
34669 + cpuidle_state_no_const *state;
34670 struct cpuidle_driver *drv = &acpi_idle_driver;
34671
34672 if (!pr->flags.power_setup_done)
34673 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34674 index 05306a5..733d1f0 100644
34675 --- a/drivers/acpi/sysfs.c
34676 +++ b/drivers/acpi/sysfs.c
34677 @@ -423,11 +423,11 @@ static u32 num_counters;
34678 static struct attribute **all_attrs;
34679 static u32 acpi_gpe_count;
34680
34681 -static struct attribute_group interrupt_stats_attr_group = {
34682 +static attribute_group_no_const interrupt_stats_attr_group = {
34683 .name = "interrupts",
34684 };
34685
34686 -static struct kobj_attribute *counter_attrs;
34687 +static kobj_attribute_no_const *counter_attrs;
34688
34689 static void delete_gpe_attr_array(void)
34690 {
34691 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34692 index aaac4fb..e325c00 100644
34693 --- a/drivers/ata/libahci.c
34694 +++ b/drivers/ata/libahci.c
34695 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
34696 }
34697 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34698
34699 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34700 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34701 struct ata_taskfile *tf, int is_cmd, u16 flags,
34702 unsigned long timeout_msec)
34703 {
34704 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34705 index 83b1a9f..005b1ec 100644
34706 --- a/drivers/ata/libata-core.c
34707 +++ b/drivers/ata/libata-core.c
34708 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34709 static void ata_dev_xfermask(struct ata_device *dev);
34710 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34711
34712 -atomic_t ata_print_id = ATOMIC_INIT(0);
34713 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34714
34715 struct ata_force_param {
34716 const char *name;
34717 @@ -4808,7 +4808,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34718 struct ata_port *ap;
34719 unsigned int tag;
34720
34721 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34722 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34723 ap = qc->ap;
34724
34725 qc->flags = 0;
34726 @@ -4824,7 +4824,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34727 struct ata_port *ap;
34728 struct ata_link *link;
34729
34730 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34731 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34732 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34733 ap = qc->ap;
34734 link = qc->dev->link;
34735 @@ -5943,6 +5943,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34736 return;
34737
34738 spin_lock(&lock);
34739 + pax_open_kernel();
34740
34741 for (cur = ops->inherits; cur; cur = cur->inherits) {
34742 void **inherit = (void **)cur;
34743 @@ -5956,8 +5957,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34744 if (IS_ERR(*pp))
34745 *pp = NULL;
34746
34747 - ops->inherits = NULL;
34748 + *(struct ata_port_operations **)&ops->inherits = NULL;
34749
34750 + pax_close_kernel();
34751 spin_unlock(&lock);
34752 }
34753
34754 @@ -6150,7 +6152,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34755
34756 /* give ports names and add SCSI hosts */
34757 for (i = 0; i < host->n_ports; i++) {
34758 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34759 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34760 host->ports[i]->local_port_no = i + 1;
34761 }
34762
34763 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34764 index db6dfcf..770d1f0 100644
34765 --- a/drivers/ata/libata-scsi.c
34766 +++ b/drivers/ata/libata-scsi.c
34767 @@ -4113,7 +4113,7 @@ int ata_sas_port_init(struct ata_port *ap)
34768
34769 if (rc)
34770 return rc;
34771 - ap->print_id = atomic_inc_return(&ata_print_id);
34772 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34773 return 0;
34774 }
34775 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34776 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34777 index 45b5ab3..98446b8 100644
34778 --- a/drivers/ata/libata.h
34779 +++ b/drivers/ata/libata.h
34780 @@ -53,7 +53,7 @@ enum {
34781 ATA_DNXFER_QUIET = (1 << 31),
34782 };
34783
34784 -extern atomic_t ata_print_id;
34785 +extern atomic_unchecked_t ata_print_id;
34786 extern int atapi_passthru16;
34787 extern int libata_fua;
34788 extern int libata_noacpi;
34789 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34790 index 853f610..97d24da 100644
34791 --- a/drivers/ata/pata_arasan_cf.c
34792 +++ b/drivers/ata/pata_arasan_cf.c
34793 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34794 /* Handle platform specific quirks */
34795 if (quirk) {
34796 if (quirk & CF_BROKEN_PIO) {
34797 - ap->ops->set_piomode = NULL;
34798 + pax_open_kernel();
34799 + *(void **)&ap->ops->set_piomode = NULL;
34800 + pax_close_kernel();
34801 ap->pio_mask = 0;
34802 }
34803 if (quirk & CF_BROKEN_MWDMA)
34804 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34805 index f9b983a..887b9d8 100644
34806 --- a/drivers/atm/adummy.c
34807 +++ b/drivers/atm/adummy.c
34808 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34809 vcc->pop(vcc, skb);
34810 else
34811 dev_kfree_skb_any(skb);
34812 - atomic_inc(&vcc->stats->tx);
34813 + atomic_inc_unchecked(&vcc->stats->tx);
34814
34815 return 0;
34816 }
34817 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34818 index 62a7607..cc4be104 100644
34819 --- a/drivers/atm/ambassador.c
34820 +++ b/drivers/atm/ambassador.c
34821 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34822 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34823
34824 // VC layer stats
34825 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34826 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34827
34828 // free the descriptor
34829 kfree (tx_descr);
34830 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34831 dump_skb ("<<<", vc, skb);
34832
34833 // VC layer stats
34834 - atomic_inc(&atm_vcc->stats->rx);
34835 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34836 __net_timestamp(skb);
34837 // end of our responsibility
34838 atm_vcc->push (atm_vcc, skb);
34839 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34840 } else {
34841 PRINTK (KERN_INFO, "dropped over-size frame");
34842 // should we count this?
34843 - atomic_inc(&atm_vcc->stats->rx_drop);
34844 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34845 }
34846
34847 } else {
34848 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34849 }
34850
34851 if (check_area (skb->data, skb->len)) {
34852 - atomic_inc(&atm_vcc->stats->tx_err);
34853 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34854 return -ENOMEM; // ?
34855 }
34856
34857 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34858 index 0e3f8f9..765a7a5 100644
34859 --- a/drivers/atm/atmtcp.c
34860 +++ b/drivers/atm/atmtcp.c
34861 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34862 if (vcc->pop) vcc->pop(vcc,skb);
34863 else dev_kfree_skb(skb);
34864 if (dev_data) return 0;
34865 - atomic_inc(&vcc->stats->tx_err);
34866 + atomic_inc_unchecked(&vcc->stats->tx_err);
34867 return -ENOLINK;
34868 }
34869 size = skb->len+sizeof(struct atmtcp_hdr);
34870 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34871 if (!new_skb) {
34872 if (vcc->pop) vcc->pop(vcc,skb);
34873 else dev_kfree_skb(skb);
34874 - atomic_inc(&vcc->stats->tx_err);
34875 + atomic_inc_unchecked(&vcc->stats->tx_err);
34876 return -ENOBUFS;
34877 }
34878 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34879 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34880 if (vcc->pop) vcc->pop(vcc,skb);
34881 else dev_kfree_skb(skb);
34882 out_vcc->push(out_vcc,new_skb);
34883 - atomic_inc(&vcc->stats->tx);
34884 - atomic_inc(&out_vcc->stats->rx);
34885 + atomic_inc_unchecked(&vcc->stats->tx);
34886 + atomic_inc_unchecked(&out_vcc->stats->rx);
34887 return 0;
34888 }
34889
34890 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34891 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34892 read_unlock(&vcc_sklist_lock);
34893 if (!out_vcc) {
34894 - atomic_inc(&vcc->stats->tx_err);
34895 + atomic_inc_unchecked(&vcc->stats->tx_err);
34896 goto done;
34897 }
34898 skb_pull(skb,sizeof(struct atmtcp_hdr));
34899 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34900 __net_timestamp(new_skb);
34901 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34902 out_vcc->push(out_vcc,new_skb);
34903 - atomic_inc(&vcc->stats->tx);
34904 - atomic_inc(&out_vcc->stats->rx);
34905 + atomic_inc_unchecked(&vcc->stats->tx);
34906 + atomic_inc_unchecked(&out_vcc->stats->rx);
34907 done:
34908 if (vcc->pop) vcc->pop(vcc,skb);
34909 else dev_kfree_skb(skb);
34910 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34911 index b1955ba..b179940 100644
34912 --- a/drivers/atm/eni.c
34913 +++ b/drivers/atm/eni.c
34914 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34915 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34916 vcc->dev->number);
34917 length = 0;
34918 - atomic_inc(&vcc->stats->rx_err);
34919 + atomic_inc_unchecked(&vcc->stats->rx_err);
34920 }
34921 else {
34922 length = ATM_CELL_SIZE-1; /* no HEC */
34923 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34924 size);
34925 }
34926 eff = length = 0;
34927 - atomic_inc(&vcc->stats->rx_err);
34928 + atomic_inc_unchecked(&vcc->stats->rx_err);
34929 }
34930 else {
34931 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34932 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34933 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34934 vcc->dev->number,vcc->vci,length,size << 2,descr);
34935 length = eff = 0;
34936 - atomic_inc(&vcc->stats->rx_err);
34937 + atomic_inc_unchecked(&vcc->stats->rx_err);
34938 }
34939 }
34940 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34941 @@ -767,7 +767,7 @@ rx_dequeued++;
34942 vcc->push(vcc,skb);
34943 pushed++;
34944 }
34945 - atomic_inc(&vcc->stats->rx);
34946 + atomic_inc_unchecked(&vcc->stats->rx);
34947 }
34948 wake_up(&eni_dev->rx_wait);
34949 }
34950 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34951 PCI_DMA_TODEVICE);
34952 if (vcc->pop) vcc->pop(vcc,skb);
34953 else dev_kfree_skb_irq(skb);
34954 - atomic_inc(&vcc->stats->tx);
34955 + atomic_inc_unchecked(&vcc->stats->tx);
34956 wake_up(&eni_dev->tx_wait);
34957 dma_complete++;
34958 }
34959 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34960 index b41c948..a002b17 100644
34961 --- a/drivers/atm/firestream.c
34962 +++ b/drivers/atm/firestream.c
34963 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34964 }
34965 }
34966
34967 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34968 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34969
34970 fs_dprintk (FS_DEBUG_TXMEM, "i");
34971 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34972 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34973 #endif
34974 skb_put (skb, qe->p1 & 0xffff);
34975 ATM_SKB(skb)->vcc = atm_vcc;
34976 - atomic_inc(&atm_vcc->stats->rx);
34977 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34978 __net_timestamp(skb);
34979 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34980 atm_vcc->push (atm_vcc, skb);
34981 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34982 kfree (pe);
34983 }
34984 if (atm_vcc)
34985 - atomic_inc(&atm_vcc->stats->rx_drop);
34986 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34987 break;
34988 case 0x1f: /* Reassembly abort: no buffers. */
34989 /* Silently increment error counter. */
34990 if (atm_vcc)
34991 - atomic_inc(&atm_vcc->stats->rx_drop);
34992 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34993 break;
34994 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34995 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34996 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34997 index 204814e..cede831 100644
34998 --- a/drivers/atm/fore200e.c
34999 +++ b/drivers/atm/fore200e.c
35000 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35001 #endif
35002 /* check error condition */
35003 if (*entry->status & STATUS_ERROR)
35004 - atomic_inc(&vcc->stats->tx_err);
35005 + atomic_inc_unchecked(&vcc->stats->tx_err);
35006 else
35007 - atomic_inc(&vcc->stats->tx);
35008 + atomic_inc_unchecked(&vcc->stats->tx);
35009 }
35010 }
35011
35012 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35013 if (skb == NULL) {
35014 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35015
35016 - atomic_inc(&vcc->stats->rx_drop);
35017 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35018 return -ENOMEM;
35019 }
35020
35021 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35022
35023 dev_kfree_skb_any(skb);
35024
35025 - atomic_inc(&vcc->stats->rx_drop);
35026 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35027 return -ENOMEM;
35028 }
35029
35030 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35031
35032 vcc->push(vcc, skb);
35033 - atomic_inc(&vcc->stats->rx);
35034 + atomic_inc_unchecked(&vcc->stats->rx);
35035
35036 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35037
35038 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35039 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35040 fore200e->atm_dev->number,
35041 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35042 - atomic_inc(&vcc->stats->rx_err);
35043 + atomic_inc_unchecked(&vcc->stats->rx_err);
35044 }
35045 }
35046
35047 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35048 goto retry_here;
35049 }
35050
35051 - atomic_inc(&vcc->stats->tx_err);
35052 + atomic_inc_unchecked(&vcc->stats->tx_err);
35053
35054 fore200e->tx_sat++;
35055 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35056 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35057 index 8557adc..3fb5d55 100644
35058 --- a/drivers/atm/he.c
35059 +++ b/drivers/atm/he.c
35060 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35061
35062 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35063 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35064 - atomic_inc(&vcc->stats->rx_drop);
35065 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35066 goto return_host_buffers;
35067 }
35068
35069 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35070 RBRQ_LEN_ERR(he_dev->rbrq_head)
35071 ? "LEN_ERR" : "",
35072 vcc->vpi, vcc->vci);
35073 - atomic_inc(&vcc->stats->rx_err);
35074 + atomic_inc_unchecked(&vcc->stats->rx_err);
35075 goto return_host_buffers;
35076 }
35077
35078 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35079 vcc->push(vcc, skb);
35080 spin_lock(&he_dev->global_lock);
35081
35082 - atomic_inc(&vcc->stats->rx);
35083 + atomic_inc_unchecked(&vcc->stats->rx);
35084
35085 return_host_buffers:
35086 ++pdus_assembled;
35087 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35088 tpd->vcc->pop(tpd->vcc, tpd->skb);
35089 else
35090 dev_kfree_skb_any(tpd->skb);
35091 - atomic_inc(&tpd->vcc->stats->tx_err);
35092 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35093 }
35094 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35095 return;
35096 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35097 vcc->pop(vcc, skb);
35098 else
35099 dev_kfree_skb_any(skb);
35100 - atomic_inc(&vcc->stats->tx_err);
35101 + atomic_inc_unchecked(&vcc->stats->tx_err);
35102 return -EINVAL;
35103 }
35104
35105 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35106 vcc->pop(vcc, skb);
35107 else
35108 dev_kfree_skb_any(skb);
35109 - atomic_inc(&vcc->stats->tx_err);
35110 + atomic_inc_unchecked(&vcc->stats->tx_err);
35111 return -EINVAL;
35112 }
35113 #endif
35114 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35115 vcc->pop(vcc, skb);
35116 else
35117 dev_kfree_skb_any(skb);
35118 - atomic_inc(&vcc->stats->tx_err);
35119 + atomic_inc_unchecked(&vcc->stats->tx_err);
35120 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35121 return -ENOMEM;
35122 }
35123 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35124 vcc->pop(vcc, skb);
35125 else
35126 dev_kfree_skb_any(skb);
35127 - atomic_inc(&vcc->stats->tx_err);
35128 + atomic_inc_unchecked(&vcc->stats->tx_err);
35129 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35130 return -ENOMEM;
35131 }
35132 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35133 __enqueue_tpd(he_dev, tpd, cid);
35134 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35135
35136 - atomic_inc(&vcc->stats->tx);
35137 + atomic_inc_unchecked(&vcc->stats->tx);
35138
35139 return 0;
35140 }
35141 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35142 index 1dc0519..1aadaf7 100644
35143 --- a/drivers/atm/horizon.c
35144 +++ b/drivers/atm/horizon.c
35145 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35146 {
35147 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35148 // VC layer stats
35149 - atomic_inc(&vcc->stats->rx);
35150 + atomic_inc_unchecked(&vcc->stats->rx);
35151 __net_timestamp(skb);
35152 // end of our responsibility
35153 vcc->push (vcc, skb);
35154 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35155 dev->tx_iovec = NULL;
35156
35157 // VC layer stats
35158 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35159 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35160
35161 // free the skb
35162 hrz_kfree_skb (skb);
35163 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35164 index 272f009..a18ba55 100644
35165 --- a/drivers/atm/idt77252.c
35166 +++ b/drivers/atm/idt77252.c
35167 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35168 else
35169 dev_kfree_skb(skb);
35170
35171 - atomic_inc(&vcc->stats->tx);
35172 + atomic_inc_unchecked(&vcc->stats->tx);
35173 }
35174
35175 atomic_dec(&scq->used);
35176 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35177 if ((sb = dev_alloc_skb(64)) == NULL) {
35178 printk("%s: Can't allocate buffers for aal0.\n",
35179 card->name);
35180 - atomic_add(i, &vcc->stats->rx_drop);
35181 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35182 break;
35183 }
35184 if (!atm_charge(vcc, sb->truesize)) {
35185 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35186 card->name);
35187 - atomic_add(i - 1, &vcc->stats->rx_drop);
35188 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35189 dev_kfree_skb(sb);
35190 break;
35191 }
35192 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35193 ATM_SKB(sb)->vcc = vcc;
35194 __net_timestamp(sb);
35195 vcc->push(vcc, sb);
35196 - atomic_inc(&vcc->stats->rx);
35197 + atomic_inc_unchecked(&vcc->stats->rx);
35198
35199 cell += ATM_CELL_PAYLOAD;
35200 }
35201 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35202 "(CDC: %08x)\n",
35203 card->name, len, rpp->len, readl(SAR_REG_CDC));
35204 recycle_rx_pool_skb(card, rpp);
35205 - atomic_inc(&vcc->stats->rx_err);
35206 + atomic_inc_unchecked(&vcc->stats->rx_err);
35207 return;
35208 }
35209 if (stat & SAR_RSQE_CRC) {
35210 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35211 recycle_rx_pool_skb(card, rpp);
35212 - atomic_inc(&vcc->stats->rx_err);
35213 + atomic_inc_unchecked(&vcc->stats->rx_err);
35214 return;
35215 }
35216 if (skb_queue_len(&rpp->queue) > 1) {
35217 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35218 RXPRINTK("%s: Can't alloc RX skb.\n",
35219 card->name);
35220 recycle_rx_pool_skb(card, rpp);
35221 - atomic_inc(&vcc->stats->rx_err);
35222 + atomic_inc_unchecked(&vcc->stats->rx_err);
35223 return;
35224 }
35225 if (!atm_charge(vcc, skb->truesize)) {
35226 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35227 __net_timestamp(skb);
35228
35229 vcc->push(vcc, skb);
35230 - atomic_inc(&vcc->stats->rx);
35231 + atomic_inc_unchecked(&vcc->stats->rx);
35232
35233 return;
35234 }
35235 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35236 __net_timestamp(skb);
35237
35238 vcc->push(vcc, skb);
35239 - atomic_inc(&vcc->stats->rx);
35240 + atomic_inc_unchecked(&vcc->stats->rx);
35241
35242 if (skb->truesize > SAR_FB_SIZE_3)
35243 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35244 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35245 if (vcc->qos.aal != ATM_AAL0) {
35246 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35247 card->name, vpi, vci);
35248 - atomic_inc(&vcc->stats->rx_drop);
35249 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35250 goto drop;
35251 }
35252
35253 if ((sb = dev_alloc_skb(64)) == NULL) {
35254 printk("%s: Can't allocate buffers for AAL0.\n",
35255 card->name);
35256 - atomic_inc(&vcc->stats->rx_err);
35257 + atomic_inc_unchecked(&vcc->stats->rx_err);
35258 goto drop;
35259 }
35260
35261 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35262 ATM_SKB(sb)->vcc = vcc;
35263 __net_timestamp(sb);
35264 vcc->push(vcc, sb);
35265 - atomic_inc(&vcc->stats->rx);
35266 + atomic_inc_unchecked(&vcc->stats->rx);
35267
35268 drop:
35269 skb_pull(queue, 64);
35270 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35271
35272 if (vc == NULL) {
35273 printk("%s: NULL connection in send().\n", card->name);
35274 - atomic_inc(&vcc->stats->tx_err);
35275 + atomic_inc_unchecked(&vcc->stats->tx_err);
35276 dev_kfree_skb(skb);
35277 return -EINVAL;
35278 }
35279 if (!test_bit(VCF_TX, &vc->flags)) {
35280 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35281 - atomic_inc(&vcc->stats->tx_err);
35282 + atomic_inc_unchecked(&vcc->stats->tx_err);
35283 dev_kfree_skb(skb);
35284 return -EINVAL;
35285 }
35286 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35287 break;
35288 default:
35289 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35290 - atomic_inc(&vcc->stats->tx_err);
35291 + atomic_inc_unchecked(&vcc->stats->tx_err);
35292 dev_kfree_skb(skb);
35293 return -EINVAL;
35294 }
35295
35296 if (skb_shinfo(skb)->nr_frags != 0) {
35297 printk("%s: No scatter-gather yet.\n", card->name);
35298 - atomic_inc(&vcc->stats->tx_err);
35299 + atomic_inc_unchecked(&vcc->stats->tx_err);
35300 dev_kfree_skb(skb);
35301 return -EINVAL;
35302 }
35303 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35304
35305 err = queue_skb(card, vc, skb, oam);
35306 if (err) {
35307 - atomic_inc(&vcc->stats->tx_err);
35308 + atomic_inc_unchecked(&vcc->stats->tx_err);
35309 dev_kfree_skb(skb);
35310 return err;
35311 }
35312 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35313 skb = dev_alloc_skb(64);
35314 if (!skb) {
35315 printk("%s: Out of memory in send_oam().\n", card->name);
35316 - atomic_inc(&vcc->stats->tx_err);
35317 + atomic_inc_unchecked(&vcc->stats->tx_err);
35318 return -ENOMEM;
35319 }
35320 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35321 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35322 index 4217f29..88f547a 100644
35323 --- a/drivers/atm/iphase.c
35324 +++ b/drivers/atm/iphase.c
35325 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35326 status = (u_short) (buf_desc_ptr->desc_mode);
35327 if (status & (RX_CER | RX_PTE | RX_OFL))
35328 {
35329 - atomic_inc(&vcc->stats->rx_err);
35330 + atomic_inc_unchecked(&vcc->stats->rx_err);
35331 IF_ERR(printk("IA: bad packet, dropping it");)
35332 if (status & RX_CER) {
35333 IF_ERR(printk(" cause: packet CRC error\n");)
35334 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35335 len = dma_addr - buf_addr;
35336 if (len > iadev->rx_buf_sz) {
35337 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35338 - atomic_inc(&vcc->stats->rx_err);
35339 + atomic_inc_unchecked(&vcc->stats->rx_err);
35340 goto out_free_desc;
35341 }
35342
35343 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35344 ia_vcc = INPH_IA_VCC(vcc);
35345 if (ia_vcc == NULL)
35346 {
35347 - atomic_inc(&vcc->stats->rx_err);
35348 + atomic_inc_unchecked(&vcc->stats->rx_err);
35349 atm_return(vcc, skb->truesize);
35350 dev_kfree_skb_any(skb);
35351 goto INCR_DLE;
35352 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35353 if ((length > iadev->rx_buf_sz) || (length >
35354 (skb->len - sizeof(struct cpcs_trailer))))
35355 {
35356 - atomic_inc(&vcc->stats->rx_err);
35357 + atomic_inc_unchecked(&vcc->stats->rx_err);
35358 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35359 length, skb->len);)
35360 atm_return(vcc, skb->truesize);
35361 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35362
35363 IF_RX(printk("rx_dle_intr: skb push");)
35364 vcc->push(vcc,skb);
35365 - atomic_inc(&vcc->stats->rx);
35366 + atomic_inc_unchecked(&vcc->stats->rx);
35367 iadev->rx_pkt_cnt++;
35368 }
35369 INCR_DLE:
35370 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35371 {
35372 struct k_sonet_stats *stats;
35373 stats = &PRIV(_ia_dev[board])->sonet_stats;
35374 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35375 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35376 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35377 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35378 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35379 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35380 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35381 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35382 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35383 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35384 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35385 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35386 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35387 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35388 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35389 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35390 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35391 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35392 }
35393 ia_cmds.status = 0;
35394 break;
35395 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35396 if ((desc == 0) || (desc > iadev->num_tx_desc))
35397 {
35398 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35399 - atomic_inc(&vcc->stats->tx);
35400 + atomic_inc_unchecked(&vcc->stats->tx);
35401 if (vcc->pop)
35402 vcc->pop(vcc, skb);
35403 else
35404 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35405 ATM_DESC(skb) = vcc->vci;
35406 skb_queue_tail(&iadev->tx_dma_q, skb);
35407
35408 - atomic_inc(&vcc->stats->tx);
35409 + atomic_inc_unchecked(&vcc->stats->tx);
35410 iadev->tx_pkt_cnt++;
35411 /* Increment transaction counter */
35412 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35413
35414 #if 0
35415 /* add flow control logic */
35416 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35417 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35418 if (iavcc->vc_desc_cnt > 10) {
35419 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35420 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35421 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35422 index fa7d701..1e404c7 100644
35423 --- a/drivers/atm/lanai.c
35424 +++ b/drivers/atm/lanai.c
35425 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35426 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35427 lanai_endtx(lanai, lvcc);
35428 lanai_free_skb(lvcc->tx.atmvcc, skb);
35429 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35430 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35431 }
35432
35433 /* Try to fill the buffer - don't call unless there is backlog */
35434 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35435 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35436 __net_timestamp(skb);
35437 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35438 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35439 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35440 out:
35441 lvcc->rx.buf.ptr = end;
35442 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35443 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35444 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35445 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35446 lanai->stats.service_rxnotaal5++;
35447 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35448 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35449 return 0;
35450 }
35451 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35452 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35453 int bytes;
35454 read_unlock(&vcc_sklist_lock);
35455 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35456 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35457 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35458 lvcc->stats.x.aal5.service_trash++;
35459 bytes = (SERVICE_GET_END(s) * 16) -
35460 (((unsigned long) lvcc->rx.buf.ptr) -
35461 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35462 }
35463 if (s & SERVICE_STREAM) {
35464 read_unlock(&vcc_sklist_lock);
35465 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35466 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35467 lvcc->stats.x.aal5.service_stream++;
35468 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35469 "PDU on VCI %d!\n", lanai->number, vci);
35470 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35471 return 0;
35472 }
35473 DPRINTK("got rx crc error on vci %d\n", vci);
35474 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35475 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35476 lvcc->stats.x.aal5.service_rxcrc++;
35477 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35478 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35479 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35480 index 5aca5f4..ce3a6b0 100644
35481 --- a/drivers/atm/nicstar.c
35482 +++ b/drivers/atm/nicstar.c
35483 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35484 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35485 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35486 card->index);
35487 - atomic_inc(&vcc->stats->tx_err);
35488 + atomic_inc_unchecked(&vcc->stats->tx_err);
35489 dev_kfree_skb_any(skb);
35490 return -EINVAL;
35491 }
35492 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35493 if (!vc->tx) {
35494 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35495 card->index);
35496 - atomic_inc(&vcc->stats->tx_err);
35497 + atomic_inc_unchecked(&vcc->stats->tx_err);
35498 dev_kfree_skb_any(skb);
35499 return -EINVAL;
35500 }
35501 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35502 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35503 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35504 card->index);
35505 - atomic_inc(&vcc->stats->tx_err);
35506 + atomic_inc_unchecked(&vcc->stats->tx_err);
35507 dev_kfree_skb_any(skb);
35508 return -EINVAL;
35509 }
35510
35511 if (skb_shinfo(skb)->nr_frags != 0) {
35512 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35513 - atomic_inc(&vcc->stats->tx_err);
35514 + atomic_inc_unchecked(&vcc->stats->tx_err);
35515 dev_kfree_skb_any(skb);
35516 return -EINVAL;
35517 }
35518 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35519 }
35520
35521 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35522 - atomic_inc(&vcc->stats->tx_err);
35523 + atomic_inc_unchecked(&vcc->stats->tx_err);
35524 dev_kfree_skb_any(skb);
35525 return -EIO;
35526 }
35527 - atomic_inc(&vcc->stats->tx);
35528 + atomic_inc_unchecked(&vcc->stats->tx);
35529
35530 return 0;
35531 }
35532 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35533 printk
35534 ("nicstar%d: Can't allocate buffers for aal0.\n",
35535 card->index);
35536 - atomic_add(i, &vcc->stats->rx_drop);
35537 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35538 break;
35539 }
35540 if (!atm_charge(vcc, sb->truesize)) {
35541 RXPRINTK
35542 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35543 card->index);
35544 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35545 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35546 dev_kfree_skb_any(sb);
35547 break;
35548 }
35549 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35550 ATM_SKB(sb)->vcc = vcc;
35551 __net_timestamp(sb);
35552 vcc->push(vcc, sb);
35553 - atomic_inc(&vcc->stats->rx);
35554 + atomic_inc_unchecked(&vcc->stats->rx);
35555 cell += ATM_CELL_PAYLOAD;
35556 }
35557
35558 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35559 if (iovb == NULL) {
35560 printk("nicstar%d: Out of iovec buffers.\n",
35561 card->index);
35562 - atomic_inc(&vcc->stats->rx_drop);
35563 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35564 recycle_rx_buf(card, skb);
35565 return;
35566 }
35567 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35568 small or large buffer itself. */
35569 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35570 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35571 - atomic_inc(&vcc->stats->rx_err);
35572 + atomic_inc_unchecked(&vcc->stats->rx_err);
35573 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35574 NS_MAX_IOVECS);
35575 NS_PRV_IOVCNT(iovb) = 0;
35576 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35577 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35578 card->index);
35579 which_list(card, skb);
35580 - atomic_inc(&vcc->stats->rx_err);
35581 + atomic_inc_unchecked(&vcc->stats->rx_err);
35582 recycle_rx_buf(card, skb);
35583 vc->rx_iov = NULL;
35584 recycle_iov_buf(card, iovb);
35585 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35586 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35587 card->index);
35588 which_list(card, skb);
35589 - atomic_inc(&vcc->stats->rx_err);
35590 + atomic_inc_unchecked(&vcc->stats->rx_err);
35591 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35592 NS_PRV_IOVCNT(iovb));
35593 vc->rx_iov = NULL;
35594 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35595 printk(" - PDU size mismatch.\n");
35596 else
35597 printk(".\n");
35598 - atomic_inc(&vcc->stats->rx_err);
35599 + atomic_inc_unchecked(&vcc->stats->rx_err);
35600 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35601 NS_PRV_IOVCNT(iovb));
35602 vc->rx_iov = NULL;
35603 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35604 /* skb points to a small buffer */
35605 if (!atm_charge(vcc, skb->truesize)) {
35606 push_rxbufs(card, skb);
35607 - atomic_inc(&vcc->stats->rx_drop);
35608 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35609 } else {
35610 skb_put(skb, len);
35611 dequeue_sm_buf(card, skb);
35612 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35613 ATM_SKB(skb)->vcc = vcc;
35614 __net_timestamp(skb);
35615 vcc->push(vcc, skb);
35616 - atomic_inc(&vcc->stats->rx);
35617 + atomic_inc_unchecked(&vcc->stats->rx);
35618 }
35619 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35620 struct sk_buff *sb;
35621 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35622 if (len <= NS_SMBUFSIZE) {
35623 if (!atm_charge(vcc, sb->truesize)) {
35624 push_rxbufs(card, sb);
35625 - atomic_inc(&vcc->stats->rx_drop);
35626 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35627 } else {
35628 skb_put(sb, len);
35629 dequeue_sm_buf(card, sb);
35630 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35631 ATM_SKB(sb)->vcc = vcc;
35632 __net_timestamp(sb);
35633 vcc->push(vcc, sb);
35634 - atomic_inc(&vcc->stats->rx);
35635 + atomic_inc_unchecked(&vcc->stats->rx);
35636 }
35637
35638 push_rxbufs(card, skb);
35639 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35640
35641 if (!atm_charge(vcc, skb->truesize)) {
35642 push_rxbufs(card, skb);
35643 - atomic_inc(&vcc->stats->rx_drop);
35644 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35645 } else {
35646 dequeue_lg_buf(card, skb);
35647 #ifdef NS_USE_DESTRUCTORS
35648 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35649 ATM_SKB(skb)->vcc = vcc;
35650 __net_timestamp(skb);
35651 vcc->push(vcc, skb);
35652 - atomic_inc(&vcc->stats->rx);
35653 + atomic_inc_unchecked(&vcc->stats->rx);
35654 }
35655
35656 push_rxbufs(card, sb);
35657 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35658 printk
35659 ("nicstar%d: Out of huge buffers.\n",
35660 card->index);
35661 - atomic_inc(&vcc->stats->rx_drop);
35662 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35663 recycle_iovec_rx_bufs(card,
35664 (struct iovec *)
35665 iovb->data,
35666 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35667 card->hbpool.count++;
35668 } else
35669 dev_kfree_skb_any(hb);
35670 - atomic_inc(&vcc->stats->rx_drop);
35671 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35672 } else {
35673 /* Copy the small buffer to the huge buffer */
35674 sb = (struct sk_buff *)iov->iov_base;
35675 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35676 #endif /* NS_USE_DESTRUCTORS */
35677 __net_timestamp(hb);
35678 vcc->push(vcc, hb);
35679 - atomic_inc(&vcc->stats->rx);
35680 + atomic_inc_unchecked(&vcc->stats->rx);
35681 }
35682 }
35683
35684 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35685 index 32784d1..4a8434a 100644
35686 --- a/drivers/atm/solos-pci.c
35687 +++ b/drivers/atm/solos-pci.c
35688 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35689 }
35690 atm_charge(vcc, skb->truesize);
35691 vcc->push(vcc, skb);
35692 - atomic_inc(&vcc->stats->rx);
35693 + atomic_inc_unchecked(&vcc->stats->rx);
35694 break;
35695
35696 case PKT_STATUS:
35697 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35698 vcc = SKB_CB(oldskb)->vcc;
35699
35700 if (vcc) {
35701 - atomic_inc(&vcc->stats->tx);
35702 + atomic_inc_unchecked(&vcc->stats->tx);
35703 solos_pop(vcc, oldskb);
35704 } else {
35705 dev_kfree_skb_irq(oldskb);
35706 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35707 index 0215934..ce9f5b1 100644
35708 --- a/drivers/atm/suni.c
35709 +++ b/drivers/atm/suni.c
35710 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35711
35712
35713 #define ADD_LIMITED(s,v) \
35714 - atomic_add((v),&stats->s); \
35715 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35716 + atomic_add_unchecked((v),&stats->s); \
35717 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35718
35719
35720 static void suni_hz(unsigned long from_timer)
35721 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35722 index 5120a96..e2572bd 100644
35723 --- a/drivers/atm/uPD98402.c
35724 +++ b/drivers/atm/uPD98402.c
35725 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35726 struct sonet_stats tmp;
35727 int error = 0;
35728
35729 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35730 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35731 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35732 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35733 if (zero && !error) {
35734 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35735
35736
35737 #define ADD_LIMITED(s,v) \
35738 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35739 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35740 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35741 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35742 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35743 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35744
35745
35746 static void stat_event(struct atm_dev *dev)
35747 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35748 if (reason & uPD98402_INT_PFM) stat_event(dev);
35749 if (reason & uPD98402_INT_PCO) {
35750 (void) GET(PCOCR); /* clear interrupt cause */
35751 - atomic_add(GET(HECCT),
35752 + atomic_add_unchecked(GET(HECCT),
35753 &PRIV(dev)->sonet_stats.uncorr_hcs);
35754 }
35755 if ((reason & uPD98402_INT_RFO) &&
35756 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35757 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35758 uPD98402_INT_LOS),PIMR); /* enable them */
35759 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35760 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35761 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35762 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35763 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35764 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35765 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35766 return 0;
35767 }
35768
35769 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35770 index 969c3c2..9b72956 100644
35771 --- a/drivers/atm/zatm.c
35772 +++ b/drivers/atm/zatm.c
35773 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35774 }
35775 if (!size) {
35776 dev_kfree_skb_irq(skb);
35777 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35778 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35779 continue;
35780 }
35781 if (!atm_charge(vcc,skb->truesize)) {
35782 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35783 skb->len = size;
35784 ATM_SKB(skb)->vcc = vcc;
35785 vcc->push(vcc,skb);
35786 - atomic_inc(&vcc->stats->rx);
35787 + atomic_inc_unchecked(&vcc->stats->rx);
35788 }
35789 zout(pos & 0xffff,MTA(mbx));
35790 #if 0 /* probably a stupid idea */
35791 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35792 skb_queue_head(&zatm_vcc->backlog,skb);
35793 break;
35794 }
35795 - atomic_inc(&vcc->stats->tx);
35796 + atomic_inc_unchecked(&vcc->stats->tx);
35797 wake_up(&zatm_vcc->tx_wait);
35798 }
35799
35800 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35801 index 4c289ab..de1c333 100644
35802 --- a/drivers/base/bus.c
35803 +++ b/drivers/base/bus.c
35804 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35805 return -EINVAL;
35806
35807 mutex_lock(&subsys->p->mutex);
35808 - list_add_tail(&sif->node, &subsys->p->interfaces);
35809 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35810 if (sif->add_dev) {
35811 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35812 while ((dev = subsys_dev_iter_next(&iter)))
35813 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35814 subsys = sif->subsys;
35815
35816 mutex_lock(&subsys->p->mutex);
35817 - list_del_init(&sif->node);
35818 + pax_list_del_init((struct list_head *)&sif->node);
35819 if (sif->remove_dev) {
35820 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35821 while ((dev = subsys_dev_iter_next(&iter)))
35822 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35823 index 7413d06..79155fa 100644
35824 --- a/drivers/base/devtmpfs.c
35825 +++ b/drivers/base/devtmpfs.c
35826 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35827 if (!thread)
35828 return 0;
35829
35830 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35831 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35832 if (err)
35833 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35834 else
35835 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35836 *err = sys_unshare(CLONE_NEWNS);
35837 if (*err)
35838 goto out;
35839 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35840 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35841 if (*err)
35842 goto out;
35843 - sys_chdir("/.."); /* will traverse into overmounted root */
35844 - sys_chroot(".");
35845 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35846 + sys_chroot((char __force_user *)".");
35847 complete(&setup_done);
35848 while (1) {
35849 spin_lock(&req_lock);
35850 diff --git a/drivers/base/node.c b/drivers/base/node.c
35851 index bc9f43b..29703b8 100644
35852 --- a/drivers/base/node.c
35853 +++ b/drivers/base/node.c
35854 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35855 struct node_attr {
35856 struct device_attribute attr;
35857 enum node_states state;
35858 -};
35859 +} __do_const;
35860
35861 static ssize_t show_node_state(struct device *dev,
35862 struct device_attribute *attr, char *buf)
35863 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35864 index bfb8955..42c9b9a 100644
35865 --- a/drivers/base/power/domain.c
35866 +++ b/drivers/base/power/domain.c
35867 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35868 {
35869 struct cpuidle_driver *cpuidle_drv;
35870 struct gpd_cpu_data *cpu_data;
35871 - struct cpuidle_state *idle_state;
35872 + cpuidle_state_no_const *idle_state;
35873 int ret = 0;
35874
35875 if (IS_ERR_OR_NULL(genpd) || state < 0)
35876 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35877 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35878 {
35879 struct gpd_cpu_data *cpu_data;
35880 - struct cpuidle_state *idle_state;
35881 + cpuidle_state_no_const *idle_state;
35882 int ret = 0;
35883
35884 if (IS_ERR_OR_NULL(genpd))
35885 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35886 index 03e089a..0e9560c 100644
35887 --- a/drivers/base/power/sysfs.c
35888 +++ b/drivers/base/power/sysfs.c
35889 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35890 return -EIO;
35891 }
35892 }
35893 - return sprintf(buf, p);
35894 + return sprintf(buf, "%s", p);
35895 }
35896
35897 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35898 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35899 index 2d56f41..8830f19 100644
35900 --- a/drivers/base/power/wakeup.c
35901 +++ b/drivers/base/power/wakeup.c
35902 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35903 * They need to be modified together atomically, so it's better to use one
35904 * atomic variable to hold them both.
35905 */
35906 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35907 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35908
35909 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35910 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35911
35912 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35913 {
35914 - unsigned int comb = atomic_read(&combined_event_count);
35915 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35916
35917 *cnt = (comb >> IN_PROGRESS_BITS);
35918 *inpr = comb & MAX_IN_PROGRESS;
35919 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35920 ws->start_prevent_time = ws->last_time;
35921
35922 /* Increment the counter of events in progress. */
35923 - cec = atomic_inc_return(&combined_event_count);
35924 + cec = atomic_inc_return_unchecked(&combined_event_count);
35925
35926 trace_wakeup_source_activate(ws->name, cec);
35927 }
35928 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35929 * Increment the counter of registered wakeup events and decrement the
35930 * couter of wakeup events in progress simultaneously.
35931 */
35932 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35933 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35934 trace_wakeup_source_deactivate(ws->name, cec);
35935
35936 split_counters(&cnt, &inpr);
35937 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35938 index e8d11b6..7b1b36f 100644
35939 --- a/drivers/base/syscore.c
35940 +++ b/drivers/base/syscore.c
35941 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35942 void register_syscore_ops(struct syscore_ops *ops)
35943 {
35944 mutex_lock(&syscore_ops_lock);
35945 - list_add_tail(&ops->node, &syscore_ops_list);
35946 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35947 mutex_unlock(&syscore_ops_lock);
35948 }
35949 EXPORT_SYMBOL_GPL(register_syscore_ops);
35950 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35951 void unregister_syscore_ops(struct syscore_ops *ops)
35952 {
35953 mutex_lock(&syscore_ops_lock);
35954 - list_del(&ops->node);
35955 + pax_list_del((struct list_head *)&ops->node);
35956 mutex_unlock(&syscore_ops_lock);
35957 }
35958 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35959 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35960 index edfa251..1734d4d 100644
35961 --- a/drivers/block/cciss.c
35962 +++ b/drivers/block/cciss.c
35963 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35964 while (!list_empty(&h->reqQ)) {
35965 c = list_entry(h->reqQ.next, CommandList_struct, list);
35966 /* can't do anything if fifo is full */
35967 - if ((h->access.fifo_full(h))) {
35968 + if ((h->access->fifo_full(h))) {
35969 dev_warn(&h->pdev->dev, "fifo full\n");
35970 break;
35971 }
35972 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35973 h->Qdepth--;
35974
35975 /* Tell the controller execute command */
35976 - h->access.submit_command(h, c);
35977 + h->access->submit_command(h, c);
35978
35979 /* Put job onto the completed Q */
35980 addQ(&h->cmpQ, c);
35981 @@ -3447,17 +3447,17 @@ startio:
35982
35983 static inline unsigned long get_next_completion(ctlr_info_t *h)
35984 {
35985 - return h->access.command_completed(h);
35986 + return h->access->command_completed(h);
35987 }
35988
35989 static inline int interrupt_pending(ctlr_info_t *h)
35990 {
35991 - return h->access.intr_pending(h);
35992 + return h->access->intr_pending(h);
35993 }
35994
35995 static inline long interrupt_not_for_us(ctlr_info_t *h)
35996 {
35997 - return ((h->access.intr_pending(h) == 0) ||
35998 + return ((h->access->intr_pending(h) == 0) ||
35999 (h->interrupts_enabled == 0));
36000 }
36001
36002 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36003 u32 a;
36004
36005 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36006 - return h->access.command_completed(h);
36007 + return h->access->command_completed(h);
36008
36009 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36010 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36011 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36012 trans_support & CFGTBL_Trans_use_short_tags);
36013
36014 /* Change the access methods to the performant access methods */
36015 - h->access = SA5_performant_access;
36016 + h->access = &SA5_performant_access;
36017 h->transMethod = CFGTBL_Trans_Performant;
36018
36019 return;
36020 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36021 if (prod_index < 0)
36022 return -ENODEV;
36023 h->product_name = products[prod_index].product_name;
36024 - h->access = *(products[prod_index].access);
36025 + h->access = products[prod_index].access;
36026
36027 if (cciss_board_disabled(h)) {
36028 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36029 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36030 }
36031
36032 /* make sure the board interrupts are off */
36033 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36034 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36035 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36036 if (rc)
36037 goto clean2;
36038 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36039 * fake ones to scoop up any residual completions.
36040 */
36041 spin_lock_irqsave(&h->lock, flags);
36042 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36043 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36044 spin_unlock_irqrestore(&h->lock, flags);
36045 free_irq(h->intr[h->intr_mode], h);
36046 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36047 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36048 dev_info(&h->pdev->dev, "Board READY.\n");
36049 dev_info(&h->pdev->dev,
36050 "Waiting for stale completions to drain.\n");
36051 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36052 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36053 msleep(10000);
36054 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36055 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36056
36057 rc = controller_reset_failed(h->cfgtable);
36058 if (rc)
36059 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36060 cciss_scsi_setup(h);
36061
36062 /* Turn the interrupts on so we can service requests */
36063 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36064 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36065
36066 /* Get the firmware version */
36067 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36068 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36069 kfree(flush_buf);
36070 if (return_code != IO_OK)
36071 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36072 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36073 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36074 free_irq(h->intr[h->intr_mode], h);
36075 }
36076
36077 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36078 index 7fda30e..eb5dfe0 100644
36079 --- a/drivers/block/cciss.h
36080 +++ b/drivers/block/cciss.h
36081 @@ -101,7 +101,7 @@ struct ctlr_info
36082 /* information about each logical volume */
36083 drive_info_struct *drv[CISS_MAX_LUN];
36084
36085 - struct access_method access;
36086 + struct access_method *access;
36087
36088 /* queue and queue Info */
36089 struct list_head reqQ;
36090 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36091 index 2b94403..fd6ad1f 100644
36092 --- a/drivers/block/cpqarray.c
36093 +++ b/drivers/block/cpqarray.c
36094 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36095 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36096 goto Enomem4;
36097 }
36098 - hba[i]->access.set_intr_mask(hba[i], 0);
36099 + hba[i]->access->set_intr_mask(hba[i], 0);
36100 if (request_irq(hba[i]->intr, do_ida_intr,
36101 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36102 {
36103 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36104 add_timer(&hba[i]->timer);
36105
36106 /* Enable IRQ now that spinlock and rate limit timer are set up */
36107 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36108 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36109
36110 for(j=0; j<NWD; j++) {
36111 struct gendisk *disk = ida_gendisk[i][j];
36112 @@ -694,7 +694,7 @@ DBGINFO(
36113 for(i=0; i<NR_PRODUCTS; i++) {
36114 if (board_id == products[i].board_id) {
36115 c->product_name = products[i].product_name;
36116 - c->access = *(products[i].access);
36117 + c->access = products[i].access;
36118 break;
36119 }
36120 }
36121 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36122 hba[ctlr]->intr = intr;
36123 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36124 hba[ctlr]->product_name = products[j].product_name;
36125 - hba[ctlr]->access = *(products[j].access);
36126 + hba[ctlr]->access = products[j].access;
36127 hba[ctlr]->ctlr = ctlr;
36128 hba[ctlr]->board_id = board_id;
36129 hba[ctlr]->pci_dev = NULL; /* not PCI */
36130 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36131
36132 while((c = h->reqQ) != NULL) {
36133 /* Can't do anything if we're busy */
36134 - if (h->access.fifo_full(h) == 0)
36135 + if (h->access->fifo_full(h) == 0)
36136 return;
36137
36138 /* Get the first entry from the request Q */
36139 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36140 h->Qdepth--;
36141
36142 /* Tell the controller to do our bidding */
36143 - h->access.submit_command(h, c);
36144 + h->access->submit_command(h, c);
36145
36146 /* Get onto the completion Q */
36147 addQ(&h->cmpQ, c);
36148 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36149 unsigned long flags;
36150 __u32 a,a1;
36151
36152 - istat = h->access.intr_pending(h);
36153 + istat = h->access->intr_pending(h);
36154 /* Is this interrupt for us? */
36155 if (istat == 0)
36156 return IRQ_NONE;
36157 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36158 */
36159 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36160 if (istat & FIFO_NOT_EMPTY) {
36161 - while((a = h->access.command_completed(h))) {
36162 + while((a = h->access->command_completed(h))) {
36163 a1 = a; a &= ~3;
36164 if ((c = h->cmpQ) == NULL)
36165 {
36166 @@ -1448,11 +1448,11 @@ static int sendcmd(
36167 /*
36168 * Disable interrupt
36169 */
36170 - info_p->access.set_intr_mask(info_p, 0);
36171 + info_p->access->set_intr_mask(info_p, 0);
36172 /* Make sure there is room in the command FIFO */
36173 /* Actually it should be completely empty at this time. */
36174 for (i = 200000; i > 0; i--) {
36175 - temp = info_p->access.fifo_full(info_p);
36176 + temp = info_p->access->fifo_full(info_p);
36177 if (temp != 0) {
36178 break;
36179 }
36180 @@ -1465,7 +1465,7 @@ DBG(
36181 /*
36182 * Send the cmd
36183 */
36184 - info_p->access.submit_command(info_p, c);
36185 + info_p->access->submit_command(info_p, c);
36186 complete = pollcomplete(ctlr);
36187
36188 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36189 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36190 * we check the new geometry. Then turn interrupts back on when
36191 * we're done.
36192 */
36193 - host->access.set_intr_mask(host, 0);
36194 + host->access->set_intr_mask(host, 0);
36195 getgeometry(ctlr);
36196 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36197 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36198
36199 for(i=0; i<NWD; i++) {
36200 struct gendisk *disk = ida_gendisk[ctlr][i];
36201 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36202 /* Wait (up to 2 seconds) for a command to complete */
36203
36204 for (i = 200000; i > 0; i--) {
36205 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36206 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36207 if (done == 0) {
36208 udelay(10); /* a short fixed delay */
36209 } else
36210 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36211 index be73e9d..7fbf140 100644
36212 --- a/drivers/block/cpqarray.h
36213 +++ b/drivers/block/cpqarray.h
36214 @@ -99,7 +99,7 @@ struct ctlr_info {
36215 drv_info_t drv[NWD];
36216 struct proc_dir_entry *proc;
36217
36218 - struct access_method access;
36219 + struct access_method *access;
36220
36221 cmdlist_t *reqQ;
36222 cmdlist_t *cmpQ;
36223 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36224 index 2d7f608..11245fe 100644
36225 --- a/drivers/block/drbd/drbd_int.h
36226 +++ b/drivers/block/drbd/drbd_int.h
36227 @@ -582,7 +582,7 @@ struct drbd_epoch {
36228 struct drbd_tconn *tconn;
36229 struct list_head list;
36230 unsigned int barrier_nr;
36231 - atomic_t epoch_size; /* increased on every request added. */
36232 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36233 atomic_t active; /* increased on every req. added, and dec on every finished. */
36234 unsigned long flags;
36235 };
36236 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36237 unsigned int al_tr_number;
36238 int al_tr_cycle;
36239 wait_queue_head_t seq_wait;
36240 - atomic_t packet_seq;
36241 + atomic_unchecked_t packet_seq;
36242 unsigned int peer_seq;
36243 spinlock_t peer_seq_lock;
36244 unsigned int minor;
36245 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36246 char __user *uoptval;
36247 int err;
36248
36249 - uoptval = (char __user __force *)optval;
36250 + uoptval = (char __force_user *)optval;
36251
36252 set_fs(KERNEL_DS);
36253 if (level == SOL_SOCKET)
36254 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36255 index 55635ed..40e837c 100644
36256 --- a/drivers/block/drbd/drbd_main.c
36257 +++ b/drivers/block/drbd/drbd_main.c
36258 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36259 p->sector = sector;
36260 p->block_id = block_id;
36261 p->blksize = blksize;
36262 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36263 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36264 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36265 }
36266
36267 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36268 return -EIO;
36269 p->sector = cpu_to_be64(req->i.sector);
36270 p->block_id = (unsigned long)req;
36271 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36272 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36273 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36274 if (mdev->state.conn >= C_SYNC_SOURCE &&
36275 mdev->state.conn <= C_PAUSED_SYNC_T)
36276 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36277 {
36278 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36279
36280 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36281 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36282 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36283 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36284 kfree(tconn->current_epoch);
36285
36286 idr_destroy(&tconn->volumes);
36287 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36288 index 8cc1e64..ba7ffa9 100644
36289 --- a/drivers/block/drbd/drbd_nl.c
36290 +++ b/drivers/block/drbd/drbd_nl.c
36291 @@ -3440,7 +3440,7 @@ out:
36292
36293 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36294 {
36295 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36296 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36297 struct sk_buff *msg;
36298 struct drbd_genlmsghdr *d_out;
36299 unsigned seq;
36300 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36301 return;
36302 }
36303
36304 - seq = atomic_inc_return(&drbd_genl_seq);
36305 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36306 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36307 if (!msg)
36308 goto failed;
36309 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36310 index cc29cd3..d4b058b 100644
36311 --- a/drivers/block/drbd/drbd_receiver.c
36312 +++ b/drivers/block/drbd/drbd_receiver.c
36313 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36314 {
36315 int err;
36316
36317 - atomic_set(&mdev->packet_seq, 0);
36318 + atomic_set_unchecked(&mdev->packet_seq, 0);
36319 mdev->peer_seq = 0;
36320
36321 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36322 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36323 do {
36324 next_epoch = NULL;
36325
36326 - epoch_size = atomic_read(&epoch->epoch_size);
36327 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36328
36329 switch (ev & ~EV_CLEANUP) {
36330 case EV_PUT:
36331 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36332 rv = FE_DESTROYED;
36333 } else {
36334 epoch->flags = 0;
36335 - atomic_set(&epoch->epoch_size, 0);
36336 + atomic_set_unchecked(&epoch->epoch_size, 0);
36337 /* atomic_set(&epoch->active, 0); is already zero */
36338 if (rv == FE_STILL_LIVE)
36339 rv = FE_RECYCLED;
36340 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36341 conn_wait_active_ee_empty(tconn);
36342 drbd_flush(tconn);
36343
36344 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36345 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36346 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36347 if (epoch)
36348 break;
36349 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36350 }
36351
36352 epoch->flags = 0;
36353 - atomic_set(&epoch->epoch_size, 0);
36354 + atomic_set_unchecked(&epoch->epoch_size, 0);
36355 atomic_set(&epoch->active, 0);
36356
36357 spin_lock(&tconn->epoch_lock);
36358 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36359 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36360 list_add(&epoch->list, &tconn->current_epoch->list);
36361 tconn->current_epoch = epoch;
36362 tconn->epochs++;
36363 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36364
36365 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36366 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36367 - atomic_inc(&tconn->current_epoch->epoch_size);
36368 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36369 err2 = drbd_drain_block(mdev, pi->size);
36370 if (!err)
36371 err = err2;
36372 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36373
36374 spin_lock(&tconn->epoch_lock);
36375 peer_req->epoch = tconn->current_epoch;
36376 - atomic_inc(&peer_req->epoch->epoch_size);
36377 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36378 atomic_inc(&peer_req->epoch->active);
36379 spin_unlock(&tconn->epoch_lock);
36380
36381 @@ -4347,7 +4347,7 @@ struct data_cmd {
36382 int expect_payload;
36383 size_t pkt_size;
36384 int (*fn)(struct drbd_tconn *, struct packet_info *);
36385 -};
36386 +} __do_const;
36387
36388 static struct data_cmd drbd_cmd_handler[] = {
36389 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36390 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36391 if (!list_empty(&tconn->current_epoch->list))
36392 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36393 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36394 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36395 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36396 tconn->send.seen_any_write_yet = false;
36397
36398 conn_info(tconn, "Connection closed\n");
36399 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36400 struct asender_cmd {
36401 size_t pkt_size;
36402 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36403 -};
36404 +} __do_const;
36405
36406 static struct asender_cmd asender_tbl[] = {
36407 [P_PING] = { 0, got_Ping },
36408 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36409 index 40e7155..df5c79a 100644
36410 --- a/drivers/block/loop.c
36411 +++ b/drivers/block/loop.c
36412 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36413
36414 file_start_write(file);
36415 set_fs(get_ds());
36416 - bw = file->f_op->write(file, buf, len, &pos);
36417 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36418 set_fs(old_fs);
36419 file_end_write(file);
36420 if (likely(bw == len))
36421 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36422 index 5618847..5a46f3b 100644
36423 --- a/drivers/block/pktcdvd.c
36424 +++ b/drivers/block/pktcdvd.c
36425 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
36426
36427 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
36428 {
36429 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
36430 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
36431 }
36432
36433 /*
36434 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
36435 return -EROFS;
36436 }
36437 pd->settings.fp = ti.fp;
36438 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
36439 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
36440
36441 if (ti.nwa_v) {
36442 pd->nwa = be32_to_cpu(ti.next_writable);
36443 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36444 index 60abf59..80789e1 100644
36445 --- a/drivers/bluetooth/btwilink.c
36446 +++ b/drivers/bluetooth/btwilink.c
36447 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36448
36449 static int bt_ti_probe(struct platform_device *pdev)
36450 {
36451 - static struct ti_st *hst;
36452 + struct ti_st *hst;
36453 struct hci_dev *hdev;
36454 int err;
36455
36456 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36457 index 2009266..7be9ca2 100644
36458 --- a/drivers/bus/arm-cci.c
36459 +++ b/drivers/bus/arm-cci.c
36460 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
36461
36462 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36463
36464 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36465 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36466 if (!ports)
36467 return -ENOMEM;
36468
36469 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36470 index 8a3aff7..d7538c2 100644
36471 --- a/drivers/cdrom/cdrom.c
36472 +++ b/drivers/cdrom/cdrom.c
36473 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36474 ENSURE(reset, CDC_RESET);
36475 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36476 cdi->mc_flags = 0;
36477 - cdo->n_minors = 0;
36478 cdi->options = CDO_USE_FFLAGS;
36479
36480 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36481 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36482 else
36483 cdi->cdda_method = CDDA_OLD;
36484
36485 - if (!cdo->generic_packet)
36486 - cdo->generic_packet = cdrom_dummy_generic_packet;
36487 + if (!cdo->generic_packet) {
36488 + pax_open_kernel();
36489 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36490 + pax_close_kernel();
36491 + }
36492
36493 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36494 mutex_lock(&cdrom_mutex);
36495 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36496 if (cdi->exit)
36497 cdi->exit(cdi);
36498
36499 - cdi->ops->n_minors--;
36500 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36501 }
36502
36503 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36504 */
36505 nr = nframes;
36506 do {
36507 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36508 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36509 if (cgc.buffer)
36510 break;
36511
36512 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36513 struct cdrom_device_info *cdi;
36514 int ret;
36515
36516 - ret = scnprintf(info + *pos, max_size - *pos, header);
36517 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36518 if (!ret)
36519 return 1;
36520
36521 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36522 index 5980cb9..6d7bd7e 100644
36523 --- a/drivers/cdrom/gdrom.c
36524 +++ b/drivers/cdrom/gdrom.c
36525 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36526 .audio_ioctl = gdrom_audio_ioctl,
36527 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36528 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36529 - .n_minors = 1,
36530 };
36531
36532 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36533 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36534 index 1421997..33f5d6d 100644
36535 --- a/drivers/char/Kconfig
36536 +++ b/drivers/char/Kconfig
36537 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36538
36539 config DEVKMEM
36540 bool "/dev/kmem virtual device support"
36541 - default y
36542 + default n
36543 + depends on !GRKERNSEC_KMEM
36544 help
36545 Say Y here if you want to support the /dev/kmem device. The
36546 /dev/kmem device is rarely used, but can be used for certain
36547 @@ -570,6 +571,7 @@ config DEVPORT
36548 bool
36549 depends on !M68K
36550 depends on ISA || PCI
36551 + depends on !GRKERNSEC_KMEM
36552 default y
36553
36554 source "drivers/s390/char/Kconfig"
36555 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36556 index a48e05b..6bac831 100644
36557 --- a/drivers/char/agp/compat_ioctl.c
36558 +++ b/drivers/char/agp/compat_ioctl.c
36559 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36560 return -ENOMEM;
36561 }
36562
36563 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36564 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36565 sizeof(*usegment) * ureserve.seg_count)) {
36566 kfree(usegment);
36567 kfree(ksegment);
36568 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36569 index 1b19239..b87b143 100644
36570 --- a/drivers/char/agp/frontend.c
36571 +++ b/drivers/char/agp/frontend.c
36572 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36573 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36574 return -EFAULT;
36575
36576 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36577 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36578 return -EFAULT;
36579
36580 client = agp_find_client_by_pid(reserve.pid);
36581 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36582 if (segment == NULL)
36583 return -ENOMEM;
36584
36585 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36586 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36587 sizeof(struct agp_segment) * reserve.seg_count)) {
36588 kfree(segment);
36589 return -EFAULT;
36590 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36591 index 4f94375..413694e 100644
36592 --- a/drivers/char/genrtc.c
36593 +++ b/drivers/char/genrtc.c
36594 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36595 switch (cmd) {
36596
36597 case RTC_PLL_GET:
36598 + memset(&pll, 0, sizeof(pll));
36599 if (get_rtc_pll(&pll))
36600 return -EINVAL;
36601 else
36602 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36603 index 448ce5e..3a76625 100644
36604 --- a/drivers/char/hpet.c
36605 +++ b/drivers/char/hpet.c
36606 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36607 }
36608
36609 static int
36610 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36611 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36612 struct hpet_info *info)
36613 {
36614 struct hpet_timer __iomem *timer;
36615 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36616 index 86fe45c..c0ea948 100644
36617 --- a/drivers/char/hw_random/intel-rng.c
36618 +++ b/drivers/char/hw_random/intel-rng.c
36619 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36620
36621 if (no_fwh_detect)
36622 return -ENODEV;
36623 - printk(warning);
36624 + printk("%s", warning);
36625 return -EBUSY;
36626 }
36627
36628 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36629 index ec4e10f..f2a763b 100644
36630 --- a/drivers/char/ipmi/ipmi_msghandler.c
36631 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36632 @@ -420,7 +420,7 @@ struct ipmi_smi {
36633 struct proc_dir_entry *proc_dir;
36634 char proc_dir_name[10];
36635
36636 - atomic_t stats[IPMI_NUM_STATS];
36637 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36638
36639 /*
36640 * run_to_completion duplicate of smb_info, smi_info
36641 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36642
36643
36644 #define ipmi_inc_stat(intf, stat) \
36645 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36646 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36647 #define ipmi_get_stat(intf, stat) \
36648 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36649 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36650
36651 static int is_lan_addr(struct ipmi_addr *addr)
36652 {
36653 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36654 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36655 init_waitqueue_head(&intf->waitq);
36656 for (i = 0; i < IPMI_NUM_STATS; i++)
36657 - atomic_set(&intf->stats[i], 0);
36658 + atomic_set_unchecked(&intf->stats[i], 0);
36659
36660 intf->proc_dir = NULL;
36661
36662 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36663 index 15e4a60..b046093 100644
36664 --- a/drivers/char/ipmi/ipmi_si_intf.c
36665 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36666 @@ -280,7 +280,7 @@ struct smi_info {
36667 unsigned char slave_addr;
36668
36669 /* Counters and things for the proc filesystem. */
36670 - atomic_t stats[SI_NUM_STATS];
36671 + atomic_unchecked_t stats[SI_NUM_STATS];
36672
36673 struct task_struct *thread;
36674
36675 @@ -289,9 +289,9 @@ struct smi_info {
36676 };
36677
36678 #define smi_inc_stat(smi, stat) \
36679 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36680 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36681 #define smi_get_stat(smi, stat) \
36682 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36683 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36684
36685 #define SI_MAX_PARMS 4
36686
36687 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
36688 atomic_set(&new_smi->req_events, 0);
36689 new_smi->run_to_completion = 0;
36690 for (i = 0; i < SI_NUM_STATS; i++)
36691 - atomic_set(&new_smi->stats[i], 0);
36692 + atomic_set_unchecked(&new_smi->stats[i], 0);
36693
36694 new_smi->interrupt_disabled = 1;
36695 atomic_set(&new_smi->stop_operation, 0);
36696 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36697 index f895a8c..2bc9147 100644
36698 --- a/drivers/char/mem.c
36699 +++ b/drivers/char/mem.c
36700 @@ -18,6 +18,7 @@
36701 #include <linux/raw.h>
36702 #include <linux/tty.h>
36703 #include <linux/capability.h>
36704 +#include <linux/security.h>
36705 #include <linux/ptrace.h>
36706 #include <linux/device.h>
36707 #include <linux/highmem.h>
36708 @@ -37,6 +38,10 @@
36709
36710 #define DEVPORT_MINOR 4
36711
36712 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36713 +extern const struct file_operations grsec_fops;
36714 +#endif
36715 +
36716 static inline unsigned long size_inside_page(unsigned long start,
36717 unsigned long size)
36718 {
36719 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36720
36721 while (cursor < to) {
36722 if (!devmem_is_allowed(pfn)) {
36723 +#ifdef CONFIG_GRKERNSEC_KMEM
36724 + gr_handle_mem_readwrite(from, to);
36725 +#else
36726 printk(KERN_INFO
36727 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36728 current->comm, from, to);
36729 +#endif
36730 return 0;
36731 }
36732 cursor += PAGE_SIZE;
36733 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36734 }
36735 return 1;
36736 }
36737 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36738 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36739 +{
36740 + return 0;
36741 +}
36742 #else
36743 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36744 {
36745 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36746
36747 while (count > 0) {
36748 unsigned long remaining;
36749 + char *temp;
36750
36751 sz = size_inside_page(p, count);
36752
36753 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36754 if (!ptr)
36755 return -EFAULT;
36756
36757 - remaining = copy_to_user(buf, ptr, sz);
36758 +#ifdef CONFIG_PAX_USERCOPY
36759 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36760 + if (!temp) {
36761 + unxlate_dev_mem_ptr(p, ptr);
36762 + return -ENOMEM;
36763 + }
36764 + memcpy(temp, ptr, sz);
36765 +#else
36766 + temp = ptr;
36767 +#endif
36768 +
36769 + remaining = copy_to_user(buf, temp, sz);
36770 +
36771 +#ifdef CONFIG_PAX_USERCOPY
36772 + kfree(temp);
36773 +#endif
36774 +
36775 unxlate_dev_mem_ptr(p, ptr);
36776 if (remaining)
36777 return -EFAULT;
36778 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36779 size_t count, loff_t *ppos)
36780 {
36781 unsigned long p = *ppos;
36782 - ssize_t low_count, read, sz;
36783 + ssize_t low_count, read, sz, err = 0;
36784 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36785 - int err = 0;
36786
36787 read = 0;
36788 if (p < (unsigned long) high_memory) {
36789 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36790 }
36791 #endif
36792 while (low_count > 0) {
36793 + char *temp;
36794 +
36795 sz = size_inside_page(p, low_count);
36796
36797 /*
36798 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36799 */
36800 kbuf = xlate_dev_kmem_ptr((char *)p);
36801
36802 - if (copy_to_user(buf, kbuf, sz))
36803 +#ifdef CONFIG_PAX_USERCOPY
36804 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36805 + if (!temp)
36806 + return -ENOMEM;
36807 + memcpy(temp, kbuf, sz);
36808 +#else
36809 + temp = kbuf;
36810 +#endif
36811 +
36812 + err = copy_to_user(buf, temp, sz);
36813 +
36814 +#ifdef CONFIG_PAX_USERCOPY
36815 + kfree(temp);
36816 +#endif
36817 +
36818 + if (err)
36819 return -EFAULT;
36820 buf += sz;
36821 p += sz;
36822 @@ -822,6 +869,9 @@ static const struct memdev {
36823 #ifdef CONFIG_PRINTK
36824 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36825 #endif
36826 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36827 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36828 +#endif
36829 };
36830
36831 static int memory_open(struct inode *inode, struct file *filp)
36832 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36833 continue;
36834
36835 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36836 - NULL, devlist[minor].name);
36837 + NULL, "%s", devlist[minor].name);
36838 }
36839
36840 return tty_init();
36841 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36842 index 9df78e2..01ba9ae 100644
36843 --- a/drivers/char/nvram.c
36844 +++ b/drivers/char/nvram.c
36845 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36846
36847 spin_unlock_irq(&rtc_lock);
36848
36849 - if (copy_to_user(buf, contents, tmp - contents))
36850 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36851 return -EFAULT;
36852
36853 *ppos = i;
36854 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36855 index d39cca6..8c1e269 100644
36856 --- a/drivers/char/pcmcia/synclink_cs.c
36857 +++ b/drivers/char/pcmcia/synclink_cs.c
36858 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36859
36860 if (debug_level >= DEBUG_LEVEL_INFO)
36861 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36862 - __FILE__, __LINE__, info->device_name, port->count);
36863 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36864
36865 - WARN_ON(!port->count);
36866 + WARN_ON(!atomic_read(&port->count));
36867
36868 if (tty_port_close_start(port, tty, filp) == 0)
36869 goto cleanup;
36870 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36871 cleanup:
36872 if (debug_level >= DEBUG_LEVEL_INFO)
36873 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36874 - tty->driver->name, port->count);
36875 + tty->driver->name, atomic_read(&port->count));
36876 }
36877
36878 /* Wait until the transmitter is empty.
36879 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36880
36881 if (debug_level >= DEBUG_LEVEL_INFO)
36882 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36883 - __FILE__, __LINE__, tty->driver->name, port->count);
36884 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36885
36886 /* If port is closing, signal caller to try again */
36887 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36888 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36889 goto cleanup;
36890 }
36891 spin_lock(&port->lock);
36892 - port->count++;
36893 + atomic_inc(&port->count);
36894 spin_unlock(&port->lock);
36895 spin_unlock_irqrestore(&info->netlock, flags);
36896
36897 - if (port->count == 1) {
36898 + if (atomic_read(&port->count) == 1) {
36899 /* 1st open on this device, init hardware */
36900 retval = startup(info, tty);
36901 if (retval < 0)
36902 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36903 unsigned short new_crctype;
36904
36905 /* return error if TTY interface open */
36906 - if (info->port.count)
36907 + if (atomic_read(&info->port.count))
36908 return -EBUSY;
36909
36910 switch (encoding)
36911 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36912
36913 /* arbitrate between network and tty opens */
36914 spin_lock_irqsave(&info->netlock, flags);
36915 - if (info->port.count != 0 || info->netcount != 0) {
36916 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36917 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36918 spin_unlock_irqrestore(&info->netlock, flags);
36919 return -EBUSY;
36920 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36921 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36922
36923 /* return error if TTY interface open */
36924 - if (info->port.count)
36925 + if (atomic_read(&info->port.count))
36926 return -EBUSY;
36927
36928 if (cmd != SIOCWANDEV)
36929 diff --git a/drivers/char/random.c b/drivers/char/random.c
36930 index 7a744d3..35a177ee 100644
36931 --- a/drivers/char/random.c
36932 +++ b/drivers/char/random.c
36933 @@ -269,8 +269,13 @@
36934 /*
36935 * Configuration information
36936 */
36937 +#ifdef CONFIG_GRKERNSEC_RANDNET
36938 +#define INPUT_POOL_WORDS 512
36939 +#define OUTPUT_POOL_WORDS 128
36940 +#else
36941 #define INPUT_POOL_WORDS 128
36942 #define OUTPUT_POOL_WORDS 32
36943 +#endif
36944 #define SEC_XFER_SIZE 512
36945 #define EXTRACT_SIZE 10
36946
36947 @@ -310,10 +315,17 @@ static struct poolinfo {
36948 int poolwords;
36949 int tap1, tap2, tap3, tap4, tap5;
36950 } poolinfo_table[] = {
36951 +#ifdef CONFIG_GRKERNSEC_RANDNET
36952 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36953 + { 512, 411, 308, 208, 104, 1 },
36954 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36955 + { 128, 103, 76, 51, 25, 1 },
36956 +#else
36957 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36958 { 128, 103, 76, 51, 25, 1 },
36959 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36960 { 32, 26, 20, 14, 7, 1 },
36961 +#endif
36962 #if 0
36963 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36964 { 2048, 1638, 1231, 819, 411, 1 },
36965 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36966 input_rotate += i ? 7 : 14;
36967 }
36968
36969 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36970 - ACCESS_ONCE(r->add_ptr) = i;
36971 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36972 + ACCESS_ONCE_RW(r->add_ptr) = i;
36973 smp_wmb();
36974
36975 if (out)
36976 @@ -1029,7 +1041,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36977
36978 extract_buf(r, tmp);
36979 i = min_t(int, nbytes, EXTRACT_SIZE);
36980 - if (copy_to_user(buf, tmp, i)) {
36981 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36982 ret = -EFAULT;
36983 break;
36984 }
36985 @@ -1365,7 +1377,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36986 #include <linux/sysctl.h>
36987
36988 static int min_read_thresh = 8, min_write_thresh;
36989 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36990 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36991 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36992 static char sysctl_bootid[16];
36993
36994 @@ -1381,7 +1393,7 @@ static char sysctl_bootid[16];
36995 static int proc_do_uuid(struct ctl_table *table, int write,
36996 void __user *buffer, size_t *lenp, loff_t *ppos)
36997 {
36998 - struct ctl_table fake_table;
36999 + ctl_table_no_const fake_table;
37000 unsigned char buf[64], tmp_uuid[16], *uuid;
37001
37002 uuid = table->data;
37003 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37004 index 7cc1fe22..b602d6b 100644
37005 --- a/drivers/char/sonypi.c
37006 +++ b/drivers/char/sonypi.c
37007 @@ -54,6 +54,7 @@
37008
37009 #include <asm/uaccess.h>
37010 #include <asm/io.h>
37011 +#include <asm/local.h>
37012
37013 #include <linux/sonypi.h>
37014
37015 @@ -490,7 +491,7 @@ static struct sonypi_device {
37016 spinlock_t fifo_lock;
37017 wait_queue_head_t fifo_proc_list;
37018 struct fasync_struct *fifo_async;
37019 - int open_count;
37020 + local_t open_count;
37021 int model;
37022 struct input_dev *input_jog_dev;
37023 struct input_dev *input_key_dev;
37024 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37025 static int sonypi_misc_release(struct inode *inode, struct file *file)
37026 {
37027 mutex_lock(&sonypi_device.lock);
37028 - sonypi_device.open_count--;
37029 + local_dec(&sonypi_device.open_count);
37030 mutex_unlock(&sonypi_device.lock);
37031 return 0;
37032 }
37033 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37034 {
37035 mutex_lock(&sonypi_device.lock);
37036 /* Flush input queue on first open */
37037 - if (!sonypi_device.open_count)
37038 + if (!local_read(&sonypi_device.open_count))
37039 kfifo_reset(&sonypi_device.fifo);
37040 - sonypi_device.open_count++;
37041 + local_inc(&sonypi_device.open_count);
37042 mutex_unlock(&sonypi_device.lock);
37043
37044 return 0;
37045 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37046 index 64420b3..5c40b56 100644
37047 --- a/drivers/char/tpm/tpm_acpi.c
37048 +++ b/drivers/char/tpm/tpm_acpi.c
37049 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37050 virt = acpi_os_map_memory(start, len);
37051 if (!virt) {
37052 kfree(log->bios_event_log);
37053 + log->bios_event_log = NULL;
37054 printk("%s: ERROR - Unable to map memory\n", __func__);
37055 return -EIO;
37056 }
37057
37058 - memcpy_fromio(log->bios_event_log, virt, len);
37059 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37060
37061 acpi_os_unmap_memory(virt, len);
37062 return 0;
37063 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37064 index 84ddc55..1d32f1e 100644
37065 --- a/drivers/char/tpm/tpm_eventlog.c
37066 +++ b/drivers/char/tpm/tpm_eventlog.c
37067 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37068 event = addr;
37069
37070 if ((event->event_type == 0 && event->event_size == 0) ||
37071 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37072 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37073 return NULL;
37074
37075 return addr;
37076 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37077 return NULL;
37078
37079 if ((event->event_type == 0 && event->event_size == 0) ||
37080 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37081 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37082 return NULL;
37083
37084 (*pos)++;
37085 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37086 int i;
37087
37088 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37089 - seq_putc(m, data[i]);
37090 + if (!seq_putc(m, data[i]))
37091 + return -EFAULT;
37092
37093 return 0;
37094 }
37095 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37096 index b79cf3e..de172d64f 100644
37097 --- a/drivers/char/virtio_console.c
37098 +++ b/drivers/char/virtio_console.c
37099 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37100 if (to_user) {
37101 ssize_t ret;
37102
37103 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37104 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37105 if (ret)
37106 return -EFAULT;
37107 } else {
37108 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37109 if (!port_has_data(port) && !port->host_connected)
37110 return 0;
37111
37112 - return fill_readbuf(port, ubuf, count, true);
37113 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37114 }
37115
37116 static int wait_port_writable(struct port *port, bool nonblock)
37117 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37118 index a33f46f..a720eed 100644
37119 --- a/drivers/clk/clk-composite.c
37120 +++ b/drivers/clk/clk-composite.c
37121 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37122 struct clk *clk;
37123 struct clk_init_data init;
37124 struct clk_composite *composite;
37125 - struct clk_ops *clk_composite_ops;
37126 + clk_ops_no_const *clk_composite_ops;
37127
37128 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37129 if (!composite) {
37130 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37131 index 81dd31a..ef5c542 100644
37132 --- a/drivers/clk/socfpga/clk.c
37133 +++ b/drivers/clk/socfpga/clk.c
37134 @@ -22,6 +22,7 @@
37135 #include <linux/clk-provider.h>
37136 #include <linux/io.h>
37137 #include <linux/of.h>
37138 +#include <asm/pgtable.h>
37139
37140 /* Clock Manager offsets */
37141 #define CLKMGR_CTRL 0x0
37142 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37143 streq(clk_name, "periph_pll") ||
37144 streq(clk_name, "sdram_pll")) {
37145 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37146 - clk_pll_ops.enable = clk_gate_ops.enable;
37147 - clk_pll_ops.disable = clk_gate_ops.disable;
37148 + pax_open_kernel();
37149 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37150 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37151 + pax_close_kernel();
37152 }
37153
37154 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37155 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37156 return parent_rate / div;
37157 }
37158
37159 -static struct clk_ops gateclk_ops = {
37160 +static clk_ops_no_const gateclk_ops __read_only = {
37161 .recalc_rate = socfpga_clk_recalc_rate,
37162 .get_parent = socfpga_clk_get_parent,
37163 .set_parent = socfpga_clk_set_parent,
37164 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37165 index 506fd23..01a593f 100644
37166 --- a/drivers/cpufreq/acpi-cpufreq.c
37167 +++ b/drivers/cpufreq/acpi-cpufreq.c
37168 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37169 return sprintf(buf, "%u\n", boost_enabled);
37170 }
37171
37172 -static struct global_attr global_boost = __ATTR(boost, 0644,
37173 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37174 show_global_boost,
37175 store_global_boost);
37176
37177 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37178 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37179 per_cpu(acfreq_data, cpu) = data;
37180
37181 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37182 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37183 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37184 + pax_open_kernel();
37185 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37186 + pax_close_kernel();
37187 + }
37188
37189 result = acpi_processor_register_performance(data->acpi_data, cpu);
37190 if (result)
37191 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37192 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37193 break;
37194 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37195 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37196 + pax_open_kernel();
37197 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37198 + pax_close_kernel();
37199 policy->cur = get_cur_freq_on_cpu(cpu);
37200 break;
37201 default:
37202 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37203 index 04548f7..457a342 100644
37204 --- a/drivers/cpufreq/cpufreq.c
37205 +++ b/drivers/cpufreq/cpufreq.c
37206 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37207 return NOTIFY_OK;
37208 }
37209
37210 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37211 +static struct notifier_block cpufreq_cpu_notifier = {
37212 .notifier_call = cpufreq_cpu_callback,
37213 };
37214
37215 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37216
37217 pr_debug("trying to register driver %s\n", driver_data->name);
37218
37219 - if (driver_data->setpolicy)
37220 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37221 + if (driver_data->setpolicy) {
37222 + pax_open_kernel();
37223 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37224 + pax_close_kernel();
37225 + }
37226
37227 write_lock_irqsave(&cpufreq_driver_lock, flags);
37228 if (cpufreq_driver) {
37229 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37230 index 0806c31..6a73276 100644
37231 --- a/drivers/cpufreq/cpufreq_governor.c
37232 +++ b/drivers/cpufreq/cpufreq_governor.c
37233 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37234 struct dbs_data *dbs_data;
37235 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37236 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37237 - struct od_ops *od_ops = NULL;
37238 + const struct od_ops *od_ops = NULL;
37239 struct od_dbs_tuners *od_tuners = NULL;
37240 struct cs_dbs_tuners *cs_tuners = NULL;
37241 struct cpu_dbs_common_info *cpu_cdbs;
37242 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37243
37244 if ((cdata->governor == GOV_CONSERVATIVE) &&
37245 (!policy->governor->initialized)) {
37246 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37247 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37248
37249 cpufreq_register_notifier(cs_ops->notifier_block,
37250 CPUFREQ_TRANSITION_NOTIFIER);
37251 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37252
37253 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37254 (policy->governor->initialized == 1)) {
37255 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37256 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37257
37258 cpufreq_unregister_notifier(cs_ops->notifier_block,
37259 CPUFREQ_TRANSITION_NOTIFIER);
37260 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37261 index 88cd39f..87f0393 100644
37262 --- a/drivers/cpufreq/cpufreq_governor.h
37263 +++ b/drivers/cpufreq/cpufreq_governor.h
37264 @@ -202,7 +202,7 @@ struct common_dbs_data {
37265 void (*exit)(struct dbs_data *dbs_data);
37266
37267 /* Governor specific ops, see below */
37268 - void *gov_ops;
37269 + const void *gov_ops;
37270 };
37271
37272 /* Governor Per policy data */
37273 @@ -222,7 +222,7 @@ struct od_ops {
37274 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37275 unsigned int freq_next, unsigned int relation);
37276 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
37277 -};
37278 +} __no_const;
37279
37280 struct cs_ops {
37281 struct notifier_block *notifier_block;
37282 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37283 index 32f26f6..feb657b 100644
37284 --- a/drivers/cpufreq/cpufreq_ondemand.c
37285 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37286 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
37287
37288 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37289
37290 -static struct od_ops od_ops = {
37291 +static struct od_ops od_ops __read_only = {
37292 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37293 .powersave_bias_target = generic_powersave_bias_target,
37294 .freq_increase = dbs_freq_increase,
37295 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37296 (struct cpufreq_policy *, unsigned int, unsigned int),
37297 unsigned int powersave_bias)
37298 {
37299 - od_ops.powersave_bias_target = f;
37300 + pax_open_kernel();
37301 + *(void **)&od_ops.powersave_bias_target = f;
37302 + pax_close_kernel();
37303 od_set_powersave_bias(powersave_bias);
37304 }
37305 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37306
37307 void od_unregister_powersave_bias_handler(void)
37308 {
37309 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37310 + pax_open_kernel();
37311 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37312 + pax_close_kernel();
37313 od_set_powersave_bias(0);
37314 }
37315 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37316 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37317 index 4cf0d28..5830372 100644
37318 --- a/drivers/cpufreq/cpufreq_stats.c
37319 +++ b/drivers/cpufreq/cpufreq_stats.c
37320 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37321 }
37322
37323 /* priority=1 so this will get called before cpufreq_remove_dev */
37324 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37325 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37326 .notifier_call = cpufreq_stat_cpu_callback,
37327 .priority = 1,
37328 };
37329 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37330 index 2f0a2a6..93d728e 100644
37331 --- a/drivers/cpufreq/p4-clockmod.c
37332 +++ b/drivers/cpufreq/p4-clockmod.c
37333 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37334 case 0x0F: /* Core Duo */
37335 case 0x16: /* Celeron Core */
37336 case 0x1C: /* Atom */
37337 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37338 + pax_open_kernel();
37339 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37340 + pax_close_kernel();
37341 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37342 case 0x0D: /* Pentium M (Dothan) */
37343 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37344 + pax_open_kernel();
37345 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37346 + pax_close_kernel();
37347 /* fall through */
37348 case 0x09: /* Pentium M (Banias) */
37349 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37350 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37351
37352 /* on P-4s, the TSC runs with constant frequency independent whether
37353 * throttling is active or not. */
37354 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37355 + pax_open_kernel();
37356 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37357 + pax_close_kernel();
37358
37359 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37360 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37361 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37362 index ac76b48..2445bc6 100644
37363 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37364 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37365 @@ -18,14 +18,12 @@
37366 #include <asm/head.h>
37367 #include <asm/timer.h>
37368
37369 -static struct cpufreq_driver *cpufreq_us3_driver;
37370 -
37371 struct us3_freq_percpu_info {
37372 struct cpufreq_frequency_table table[4];
37373 };
37374
37375 /* Indexed by cpu number. */
37376 -static struct us3_freq_percpu_info *us3_freq_table;
37377 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37378
37379 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37380 * in the Safari config register.
37381 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37382
37383 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37384 {
37385 - if (cpufreq_us3_driver)
37386 - us3_set_cpu_divider_index(policy, 0);
37387 + us3_set_cpu_divider_index(policy->cpu, 0);
37388
37389 return 0;
37390 }
37391
37392 +static int __init us3_freq_init(void);
37393 +static void __exit us3_freq_exit(void);
37394 +
37395 +static struct cpufreq_driver cpufreq_us3_driver = {
37396 + .init = us3_freq_cpu_init,
37397 + .verify = us3_freq_verify,
37398 + .target = us3_freq_target,
37399 + .get = us3_freq_get,
37400 + .exit = us3_freq_cpu_exit,
37401 + .owner = THIS_MODULE,
37402 + .name = "UltraSPARC-III",
37403 +
37404 +};
37405 +
37406 static int __init us3_freq_init(void)
37407 {
37408 unsigned long manuf, impl, ver;
37409 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
37410 (impl == CHEETAH_IMPL ||
37411 impl == CHEETAH_PLUS_IMPL ||
37412 impl == JAGUAR_IMPL ||
37413 - impl == PANTHER_IMPL)) {
37414 - struct cpufreq_driver *driver;
37415 -
37416 - ret = -ENOMEM;
37417 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
37418 - if (!driver)
37419 - goto err_out;
37420 -
37421 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
37422 - GFP_KERNEL);
37423 - if (!us3_freq_table)
37424 - goto err_out;
37425 -
37426 - driver->init = us3_freq_cpu_init;
37427 - driver->verify = us3_freq_verify;
37428 - driver->target = us3_freq_target;
37429 - driver->get = us3_freq_get;
37430 - driver->exit = us3_freq_cpu_exit;
37431 - strcpy(driver->name, "UltraSPARC-III");
37432 -
37433 - cpufreq_us3_driver = driver;
37434 - ret = cpufreq_register_driver(driver);
37435 - if (ret)
37436 - goto err_out;
37437 -
37438 - return 0;
37439 -
37440 -err_out:
37441 - if (driver) {
37442 - kfree(driver);
37443 - cpufreq_us3_driver = NULL;
37444 - }
37445 - kfree(us3_freq_table);
37446 - us3_freq_table = NULL;
37447 - return ret;
37448 - }
37449 + impl == PANTHER_IMPL))
37450 + return cpufreq_register_driver(&cpufreq_us3_driver);
37451
37452 return -ENODEV;
37453 }
37454
37455 static void __exit us3_freq_exit(void)
37456 {
37457 - if (cpufreq_us3_driver) {
37458 - cpufreq_unregister_driver(cpufreq_us3_driver);
37459 - kfree(cpufreq_us3_driver);
37460 - cpufreq_us3_driver = NULL;
37461 - kfree(us3_freq_table);
37462 - us3_freq_table = NULL;
37463 - }
37464 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37465 }
37466
37467 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37468 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37469 index f897d51..15da295 100644
37470 --- a/drivers/cpufreq/speedstep-centrino.c
37471 +++ b/drivers/cpufreq/speedstep-centrino.c
37472 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37473 !cpu_has(cpu, X86_FEATURE_EST))
37474 return -ENODEV;
37475
37476 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37477 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37478 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37479 + pax_open_kernel();
37480 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37481 + pax_close_kernel();
37482 + }
37483
37484 if (policy->cpu != 0)
37485 return -ENODEV;
37486 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37487 index d75040d..4738ca5 100644
37488 --- a/drivers/cpuidle/cpuidle.c
37489 +++ b/drivers/cpuidle/cpuidle.c
37490 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
37491
37492 static void poll_idle_init(struct cpuidle_driver *drv)
37493 {
37494 - struct cpuidle_state *state = &drv->states[0];
37495 + cpuidle_state_no_const *state = &drv->states[0];
37496
37497 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37498 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37499 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37500 index ea2f8e7..70ac501 100644
37501 --- a/drivers/cpuidle/governor.c
37502 +++ b/drivers/cpuidle/governor.c
37503 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37504 mutex_lock(&cpuidle_lock);
37505 if (__cpuidle_find_governor(gov->name) == NULL) {
37506 ret = 0;
37507 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37508 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37509 if (!cpuidle_curr_governor ||
37510 cpuidle_curr_governor->rating < gov->rating)
37511 cpuidle_switch_governor(gov);
37512 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37513 new_gov = cpuidle_replace_governor(gov->rating);
37514 cpuidle_switch_governor(new_gov);
37515 }
37516 - list_del(&gov->governor_list);
37517 + pax_list_del((struct list_head *)&gov->governor_list);
37518 mutex_unlock(&cpuidle_lock);
37519 }
37520
37521 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37522 index 8739cc0..dc859d0 100644
37523 --- a/drivers/cpuidle/sysfs.c
37524 +++ b/drivers/cpuidle/sysfs.c
37525 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37526 NULL
37527 };
37528
37529 -static struct attribute_group cpuidle_attr_group = {
37530 +static attribute_group_no_const cpuidle_attr_group = {
37531 .attrs = cpuidle_default_attrs,
37532 .name = "cpuidle",
37533 };
37534 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37535 index 12fea3e..1e28f47 100644
37536 --- a/drivers/crypto/hifn_795x.c
37537 +++ b/drivers/crypto/hifn_795x.c
37538 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37539 MODULE_PARM_DESC(hifn_pll_ref,
37540 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37541
37542 -static atomic_t hifn_dev_number;
37543 +static atomic_unchecked_t hifn_dev_number;
37544
37545 #define ACRYPTO_OP_DECRYPT 0
37546 #define ACRYPTO_OP_ENCRYPT 1
37547 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37548 goto err_out_disable_pci_device;
37549
37550 snprintf(name, sizeof(name), "hifn%d",
37551 - atomic_inc_return(&hifn_dev_number)-1);
37552 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37553
37554 err = pci_request_regions(pdev, name);
37555 if (err)
37556 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37557 index c99c00d..990a4b2 100644
37558 --- a/drivers/devfreq/devfreq.c
37559 +++ b/drivers/devfreq/devfreq.c
37560 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37561 goto err_out;
37562 }
37563
37564 - list_add(&governor->node, &devfreq_governor_list);
37565 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37566
37567 list_for_each_entry(devfreq, &devfreq_list, node) {
37568 int ret = 0;
37569 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37570 }
37571 }
37572
37573 - list_del(&governor->node);
37574 + pax_list_del((struct list_head *)&governor->node);
37575 err_out:
37576 mutex_unlock(&devfreq_list_lock);
37577
37578 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
37579 index 1069e88..dfcd642 100644
37580 --- a/drivers/dma/sh/shdmac.c
37581 +++ b/drivers/dma/sh/shdmac.c
37582 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37583 return ret;
37584 }
37585
37586 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37587 +static struct notifier_block sh_dmae_nmi_notifier = {
37588 .notifier_call = sh_dmae_nmi_handler,
37589
37590 /* Run before NMI debug handler and KGDB */
37591 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37592 index 211021d..201d47f 100644
37593 --- a/drivers/edac/edac_device.c
37594 +++ b/drivers/edac/edac_device.c
37595 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37596 */
37597 int edac_device_alloc_index(void)
37598 {
37599 - static atomic_t device_indexes = ATOMIC_INIT(0);
37600 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37601
37602 - return atomic_inc_return(&device_indexes) - 1;
37603 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37604 }
37605 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37606
37607 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37608 index 9f7e0e60..348c875 100644
37609 --- a/drivers/edac/edac_mc_sysfs.c
37610 +++ b/drivers/edac/edac_mc_sysfs.c
37611 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
37612 struct dev_ch_attribute {
37613 struct device_attribute attr;
37614 int channel;
37615 -};
37616 +} __do_const;
37617
37618 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37619 struct dev_ch_attribute dev_attr_legacy_##_name = \
37620 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37621 }
37622
37623 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37624 + pax_open_kernel();
37625 if (mci->get_sdram_scrub_rate) {
37626 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37627 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37628 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37629 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37630 }
37631 if (mci->set_sdram_scrub_rate) {
37632 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37633 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37634 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37635 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37636 }
37637 + pax_close_kernel();
37638 err = device_create_file(&mci->dev,
37639 &dev_attr_sdram_scrub_rate);
37640 if (err) {
37641 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37642 index dd370f9..0281629 100644
37643 --- a/drivers/edac/edac_pci.c
37644 +++ b/drivers/edac/edac_pci.c
37645 @@ -29,7 +29,7 @@
37646
37647 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37648 static LIST_HEAD(edac_pci_list);
37649 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37650 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37651
37652 /*
37653 * edac_pci_alloc_ctl_info
37654 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37655 */
37656 int edac_pci_alloc_index(void)
37657 {
37658 - return atomic_inc_return(&pci_indexes) - 1;
37659 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37660 }
37661 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37662
37663 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37664 index e8658e4..22746d6 100644
37665 --- a/drivers/edac/edac_pci_sysfs.c
37666 +++ b/drivers/edac/edac_pci_sysfs.c
37667 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37668 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37669 static int edac_pci_poll_msec = 1000; /* one second workq period */
37670
37671 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37672 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37673 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37674 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37675
37676 static struct kobject *edac_pci_top_main_kobj;
37677 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37678 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37679 void *value;
37680 ssize_t(*show) (void *, char *);
37681 ssize_t(*store) (void *, const char *, size_t);
37682 -};
37683 +} __do_const;
37684
37685 /* Set of show/store abstract level functions for PCI Parity object */
37686 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37687 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37688 edac_printk(KERN_CRIT, EDAC_PCI,
37689 "Signaled System Error on %s\n",
37690 pci_name(dev));
37691 - atomic_inc(&pci_nonparity_count);
37692 + atomic_inc_unchecked(&pci_nonparity_count);
37693 }
37694
37695 if (status & (PCI_STATUS_PARITY)) {
37696 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37697 "Master Data Parity Error on %s\n",
37698 pci_name(dev));
37699
37700 - atomic_inc(&pci_parity_count);
37701 + atomic_inc_unchecked(&pci_parity_count);
37702 }
37703
37704 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37705 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37706 "Detected Parity Error on %s\n",
37707 pci_name(dev));
37708
37709 - atomic_inc(&pci_parity_count);
37710 + atomic_inc_unchecked(&pci_parity_count);
37711 }
37712 }
37713
37714 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37715 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37716 "Signaled System Error on %s\n",
37717 pci_name(dev));
37718 - atomic_inc(&pci_nonparity_count);
37719 + atomic_inc_unchecked(&pci_nonparity_count);
37720 }
37721
37722 if (status & (PCI_STATUS_PARITY)) {
37723 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37724 "Master Data Parity Error on "
37725 "%s\n", pci_name(dev));
37726
37727 - atomic_inc(&pci_parity_count);
37728 + atomic_inc_unchecked(&pci_parity_count);
37729 }
37730
37731 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37732 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37733 "Detected Parity Error on %s\n",
37734 pci_name(dev));
37735
37736 - atomic_inc(&pci_parity_count);
37737 + atomic_inc_unchecked(&pci_parity_count);
37738 }
37739 }
37740 }
37741 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37742 if (!check_pci_errors)
37743 return;
37744
37745 - before_count = atomic_read(&pci_parity_count);
37746 + before_count = atomic_read_unchecked(&pci_parity_count);
37747
37748 /* scan all PCI devices looking for a Parity Error on devices and
37749 * bridges.
37750 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37751 /* Only if operator has selected panic on PCI Error */
37752 if (edac_pci_get_panic_on_pe()) {
37753 /* If the count is different 'after' from 'before' */
37754 - if (before_count != atomic_read(&pci_parity_count))
37755 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37756 panic("EDAC: PCI Parity Error");
37757 }
37758 }
37759 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37760 index 51b7e3a..aa8a3e8 100644
37761 --- a/drivers/edac/mce_amd.h
37762 +++ b/drivers/edac/mce_amd.h
37763 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37764 bool (*mc0_mce)(u16, u8);
37765 bool (*mc1_mce)(u16, u8);
37766 bool (*mc2_mce)(u16, u8);
37767 -};
37768 +} __no_const;
37769
37770 void amd_report_gart_errors(bool);
37771 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37772 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37773 index 57ea7f4..af06b76 100644
37774 --- a/drivers/firewire/core-card.c
37775 +++ b/drivers/firewire/core-card.c
37776 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37777 const struct fw_card_driver *driver,
37778 struct device *device)
37779 {
37780 - static atomic_t index = ATOMIC_INIT(-1);
37781 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37782
37783 - card->index = atomic_inc_return(&index);
37784 + card->index = atomic_inc_return_unchecked(&index);
37785 card->driver = driver;
37786 card->device = device;
37787 card->current_tlabel = 0;
37788 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37789
37790 void fw_core_remove_card(struct fw_card *card)
37791 {
37792 - struct fw_card_driver dummy_driver = dummy_driver_template;
37793 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37794
37795 card->driver->update_phy_reg(card, 4,
37796 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37797 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37798 index de4aa40..49ab1f2 100644
37799 --- a/drivers/firewire/core-device.c
37800 +++ b/drivers/firewire/core-device.c
37801 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37802 struct config_rom_attribute {
37803 struct device_attribute attr;
37804 u32 key;
37805 -};
37806 +} __do_const;
37807
37808 static ssize_t show_immediate(struct device *dev,
37809 struct device_attribute *dattr, char *buf)
37810 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37811 index e5af0e3..d318058 100644
37812 --- a/drivers/firewire/core-transaction.c
37813 +++ b/drivers/firewire/core-transaction.c
37814 @@ -38,6 +38,7 @@
37815 #include <linux/timer.h>
37816 #include <linux/types.h>
37817 #include <linux/workqueue.h>
37818 +#include <linux/sched.h>
37819
37820 #include <asm/byteorder.h>
37821
37822 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37823 index 515a42c..5ecf3ba 100644
37824 --- a/drivers/firewire/core.h
37825 +++ b/drivers/firewire/core.h
37826 @@ -111,6 +111,7 @@ struct fw_card_driver {
37827
37828 int (*stop_iso)(struct fw_iso_context *ctx);
37829 };
37830 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37831
37832 void fw_card_initialize(struct fw_card *card,
37833 const struct fw_card_driver *driver, struct device *device);
37834 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37835 index 94a58a0..f5eba42 100644
37836 --- a/drivers/firmware/dmi-id.c
37837 +++ b/drivers/firmware/dmi-id.c
37838 @@ -16,7 +16,7 @@
37839 struct dmi_device_attribute{
37840 struct device_attribute dev_attr;
37841 int field;
37842 -};
37843 +} __do_const;
37844 #define to_dmi_dev_attr(_dev_attr) \
37845 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37846
37847 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37848 index fa0affb..aa448eb 100644
37849 --- a/drivers/firmware/dmi_scan.c
37850 +++ b/drivers/firmware/dmi_scan.c
37851 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37852 if (buf == NULL)
37853 return -1;
37854
37855 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37856 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37857
37858 iounmap(buf);
37859 return 0;
37860 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37861 index 5145fa3..0d3babd 100644
37862 --- a/drivers/firmware/efi/efi.c
37863 +++ b/drivers/firmware/efi/efi.c
37864 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37865 };
37866
37867 static struct efivars generic_efivars;
37868 -static struct efivar_operations generic_ops;
37869 +static efivar_operations_no_const generic_ops __read_only;
37870
37871 static int generic_ops_register(void)
37872 {
37873 - generic_ops.get_variable = efi.get_variable;
37874 - generic_ops.set_variable = efi.set_variable;
37875 - generic_ops.get_next_variable = efi.get_next_variable;
37876 - generic_ops.query_variable_store = efi_query_variable_store;
37877 + pax_open_kernel();
37878 + *(void **)&generic_ops.get_variable = efi.get_variable;
37879 + *(void **)&generic_ops.set_variable = efi.set_variable;
37880 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37881 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37882 + pax_close_kernel();
37883
37884 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37885 }
37886 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37887 index 8a7432a..28fb839 100644
37888 --- a/drivers/firmware/efi/efivars.c
37889 +++ b/drivers/firmware/efi/efivars.c
37890 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37891 static int
37892 create_efivars_bin_attributes(void)
37893 {
37894 - struct bin_attribute *attr;
37895 + bin_attribute_no_const *attr;
37896 int error;
37897
37898 /* new_var */
37899 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37900 index 2a90ba6..07f3733 100644
37901 --- a/drivers/firmware/google/memconsole.c
37902 +++ b/drivers/firmware/google/memconsole.c
37903 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37904 if (!found_memconsole())
37905 return -ENODEV;
37906
37907 - memconsole_bin_attr.size = memconsole_length;
37908 + pax_open_kernel();
37909 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37910 + pax_close_kernel();
37911
37912 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37913
37914 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37915 index 814addb..0937d7f 100644
37916 --- a/drivers/gpio/gpio-ich.c
37917 +++ b/drivers/gpio/gpio-ich.c
37918 @@ -71,7 +71,7 @@ struct ichx_desc {
37919 /* Some chipsets have quirks, let these use their own request/get */
37920 int (*request)(struct gpio_chip *chip, unsigned offset);
37921 int (*get)(struct gpio_chip *chip, unsigned offset);
37922 -};
37923 +} __do_const;
37924
37925 static struct {
37926 spinlock_t lock;
37927 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37928 index 9902732..64b62dd 100644
37929 --- a/drivers/gpio/gpio-vr41xx.c
37930 +++ b/drivers/gpio/gpio-vr41xx.c
37931 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37932 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37933 maskl, pendl, maskh, pendh);
37934
37935 - atomic_inc(&irq_err_count);
37936 + atomic_inc_unchecked(&irq_err_count);
37937
37938 return -EINVAL;
37939 }
37940 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37941 index c722c3b..2ec6040 100644
37942 --- a/drivers/gpu/drm/drm_crtc_helper.c
37943 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37944 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37945 struct drm_crtc *tmp;
37946 int crtc_mask = 1;
37947
37948 - WARN(!crtc, "checking null crtc?\n");
37949 + BUG_ON(!crtc);
37950
37951 dev = crtc->dev;
37952
37953 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37954 index fe58d08..07bc38e 100644
37955 --- a/drivers/gpu/drm/drm_drv.c
37956 +++ b/drivers/gpu/drm/drm_drv.c
37957 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
37958 atomic_set(&dev->vma_count, 0);
37959
37960 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37961 - atomic_set(&dev->counts[i], 0);
37962 + atomic_set_unchecked(&dev->counts[i], 0);
37963
37964 dev->sigdata.lock = NULL;
37965
37966 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
37967 /**
37968 * Copy and IOCTL return string to user space
37969 */
37970 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37971 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37972 {
37973 int len;
37974
37975 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
37976 struct drm_file *file_priv = filp->private_data;
37977 struct drm_device *dev;
37978 const struct drm_ioctl_desc *ioctl = NULL;
37979 - drm_ioctl_t *func;
37980 + drm_ioctl_no_const_t func;
37981 unsigned int nr = DRM_IOCTL_NR(cmd);
37982 int retcode = -EINVAL;
37983 char stack_kdata[128];
37984 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
37985 return -ENODEV;
37986
37987 atomic_inc(&dev->ioctl_count);
37988 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37989 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37990 ++file_priv->ioctl_count;
37991
37992 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37993 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37994 index 3f84277..c627c54 100644
37995 --- a/drivers/gpu/drm/drm_fops.c
37996 +++ b/drivers/gpu/drm/drm_fops.c
37997 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
37998 if (drm_device_is_unplugged(dev))
37999 return -ENODEV;
38000
38001 - if (!dev->open_count++)
38002 + if (local_inc_return(&dev->open_count) == 1)
38003 need_setup = 1;
38004 mutex_lock(&dev->struct_mutex);
38005 old_imapping = inode->i_mapping;
38006 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38007 retcode = drm_open_helper(inode, filp, dev);
38008 if (retcode)
38009 goto err_undo;
38010 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38011 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38012 if (need_setup) {
38013 retcode = drm_setup(dev);
38014 if (retcode)
38015 @@ -128,7 +128,7 @@ err_undo:
38016 iput(container_of(dev->dev_mapping, struct inode, i_data));
38017 dev->dev_mapping = old_mapping;
38018 mutex_unlock(&dev->struct_mutex);
38019 - dev->open_count--;
38020 + local_dec(&dev->open_count);
38021 return retcode;
38022 }
38023 EXPORT_SYMBOL(drm_open);
38024 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38025
38026 mutex_lock(&drm_global_mutex);
38027
38028 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38029 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38030
38031 if (dev->driver->preclose)
38032 dev->driver->preclose(dev, file_priv);
38033 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38034 * Begin inline drm_release
38035 */
38036
38037 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38038 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38039 task_pid_nr(current),
38040 (long)old_encode_dev(file_priv->minor->device),
38041 - dev->open_count);
38042 + local_read(&dev->open_count));
38043
38044 /* Release any auth tokens that might point to this file_priv,
38045 (do that under the drm_global_mutex) */
38046 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38047 * End inline drm_release
38048 */
38049
38050 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38051 - if (!--dev->open_count) {
38052 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38053 + if (local_dec_and_test(&dev->open_count)) {
38054 if (atomic_read(&dev->ioctl_count)) {
38055 DRM_ERROR("Device busy: %d\n",
38056 atomic_read(&dev->ioctl_count));
38057 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38058 index f731116..629842c 100644
38059 --- a/drivers/gpu/drm/drm_global.c
38060 +++ b/drivers/gpu/drm/drm_global.c
38061 @@ -36,7 +36,7 @@
38062 struct drm_global_item {
38063 struct mutex mutex;
38064 void *object;
38065 - int refcount;
38066 + atomic_t refcount;
38067 };
38068
38069 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38070 @@ -49,7 +49,7 @@ void drm_global_init(void)
38071 struct drm_global_item *item = &glob[i];
38072 mutex_init(&item->mutex);
38073 item->object = NULL;
38074 - item->refcount = 0;
38075 + atomic_set(&item->refcount, 0);
38076 }
38077 }
38078
38079 @@ -59,7 +59,7 @@ void drm_global_release(void)
38080 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38081 struct drm_global_item *item = &glob[i];
38082 BUG_ON(item->object != NULL);
38083 - BUG_ON(item->refcount != 0);
38084 + BUG_ON(atomic_read(&item->refcount) != 0);
38085 }
38086 }
38087
38088 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38089 void *object;
38090
38091 mutex_lock(&item->mutex);
38092 - if (item->refcount == 0) {
38093 + if (atomic_read(&item->refcount) == 0) {
38094 item->object = kzalloc(ref->size, GFP_KERNEL);
38095 if (unlikely(item->object == NULL)) {
38096 ret = -ENOMEM;
38097 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38098 goto out_err;
38099
38100 }
38101 - ++item->refcount;
38102 + atomic_inc(&item->refcount);
38103 ref->object = item->object;
38104 object = item->object;
38105 mutex_unlock(&item->mutex);
38106 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38107 struct drm_global_item *item = &glob[ref->global_type];
38108
38109 mutex_lock(&item->mutex);
38110 - BUG_ON(item->refcount == 0);
38111 + BUG_ON(atomic_read(&item->refcount) == 0);
38112 BUG_ON(ref->object != item->object);
38113 - if (--item->refcount == 0) {
38114 + if (atomic_dec_and_test(&item->refcount)) {
38115 ref->release(ref);
38116 item->object = NULL;
38117 }
38118 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38119 index 5329832..b503f49 100644
38120 --- a/drivers/gpu/drm/drm_info.c
38121 +++ b/drivers/gpu/drm/drm_info.c
38122 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38123 struct drm_local_map *map;
38124 struct drm_map_list *r_list;
38125
38126 - /* Hardcoded from _DRM_FRAME_BUFFER,
38127 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38128 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38129 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38130 + static const char * const types[] = {
38131 + [_DRM_FRAME_BUFFER] = "FB",
38132 + [_DRM_REGISTERS] = "REG",
38133 + [_DRM_SHM] = "SHM",
38134 + [_DRM_AGP] = "AGP",
38135 + [_DRM_SCATTER_GATHER] = "SG",
38136 + [_DRM_CONSISTENT] = "PCI",
38137 + [_DRM_GEM] = "GEM" };
38138 const char *type;
38139 int i;
38140
38141 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38142 map = r_list->map;
38143 if (!map)
38144 continue;
38145 - if (map->type < 0 || map->type > 5)
38146 + if (map->type >= ARRAY_SIZE(types))
38147 type = "??";
38148 else
38149 type = types[map->type];
38150 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38151 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38152 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38153 vma->vm_flags & VM_IO ? 'i' : '-',
38154 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38155 + 0);
38156 +#else
38157 vma->vm_pgoff);
38158 +#endif
38159
38160 #if defined(__i386__)
38161 pgprot = pgprot_val(vma->vm_page_prot);
38162 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38163 index 2f4c434..dd12cd2 100644
38164 --- a/drivers/gpu/drm/drm_ioc32.c
38165 +++ b/drivers/gpu/drm/drm_ioc32.c
38166 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38167 request = compat_alloc_user_space(nbytes);
38168 if (!access_ok(VERIFY_WRITE, request, nbytes))
38169 return -EFAULT;
38170 - list = (struct drm_buf_desc *) (request + 1);
38171 + list = (struct drm_buf_desc __user *) (request + 1);
38172
38173 if (__put_user(count, &request->count)
38174 || __put_user(list, &request->list))
38175 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38176 request = compat_alloc_user_space(nbytes);
38177 if (!access_ok(VERIFY_WRITE, request, nbytes))
38178 return -EFAULT;
38179 - list = (struct drm_buf_pub *) (request + 1);
38180 + list = (struct drm_buf_pub __user *) (request + 1);
38181
38182 if (__put_user(count, &request->count)
38183 || __put_user(list, &request->list))
38184 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38185 return 0;
38186 }
38187
38188 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38189 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38190 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38191 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38192 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38193 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38194 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38195 {
38196 unsigned int nr = DRM_IOCTL_NR(cmd);
38197 - drm_ioctl_compat_t *fn;
38198 int ret;
38199
38200 /* Assume that ioctls without an explicit compat routine will just
38201 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38202 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38203 return drm_ioctl(filp, cmd, arg);
38204
38205 - fn = drm_compat_ioctls[nr];
38206 -
38207 - if (fn != NULL)
38208 - ret = (*fn) (filp, cmd, arg);
38209 + if (drm_compat_ioctls[nr] != NULL)
38210 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38211 else
38212 ret = drm_ioctl(filp, cmd, arg);
38213
38214 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38215 index d752c96..fe08455 100644
38216 --- a/drivers/gpu/drm/drm_lock.c
38217 +++ b/drivers/gpu/drm/drm_lock.c
38218 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38219 if (drm_lock_take(&master->lock, lock->context)) {
38220 master->lock.file_priv = file_priv;
38221 master->lock.lock_time = jiffies;
38222 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38223 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38224 break; /* Got lock */
38225 }
38226
38227 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38228 return -EINVAL;
38229 }
38230
38231 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38232 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38233
38234 if (drm_lock_free(&master->lock, lock->context)) {
38235 /* FIXME: Should really bail out here. */
38236 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38237 index 39d8645..59e06fa 100644
38238 --- a/drivers/gpu/drm/drm_stub.c
38239 +++ b/drivers/gpu/drm/drm_stub.c
38240 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
38241
38242 drm_device_set_unplugged(dev);
38243
38244 - if (dev->open_count == 0) {
38245 + if (local_read(&dev->open_count) == 0) {
38246 drm_put_dev(dev);
38247 }
38248 mutex_unlock(&drm_global_mutex);
38249 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38250 index 2290b3b..22056a1 100644
38251 --- a/drivers/gpu/drm/drm_sysfs.c
38252 +++ b/drivers/gpu/drm/drm_sysfs.c
38253 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38254 int drm_sysfs_device_add(struct drm_minor *minor)
38255 {
38256 int err;
38257 - char *minor_str;
38258 + const char *minor_str;
38259
38260 minor->kdev.parent = minor->dev->dev;
38261
38262 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38263 index ab1892eb..d7009ca 100644
38264 --- a/drivers/gpu/drm/i810/i810_dma.c
38265 +++ b/drivers/gpu/drm/i810/i810_dma.c
38266 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38267 dma->buflist[vertex->idx],
38268 vertex->discard, vertex->used);
38269
38270 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38271 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38272 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38273 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38274 sarea_priv->last_enqueue = dev_priv->counter - 1;
38275 sarea_priv->last_dispatch = (int)hw_status[5];
38276
38277 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38278 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38279 mc->last_render);
38280
38281 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38282 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38283 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38284 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38285 sarea_priv->last_enqueue = dev_priv->counter - 1;
38286 sarea_priv->last_dispatch = (int)hw_status[5];
38287
38288 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38289 index d4d16ed..8fb0b51 100644
38290 --- a/drivers/gpu/drm/i810/i810_drv.h
38291 +++ b/drivers/gpu/drm/i810/i810_drv.h
38292 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38293 int page_flipping;
38294
38295 wait_queue_head_t irq_queue;
38296 - atomic_t irq_received;
38297 - atomic_t irq_emitted;
38298 + atomic_unchecked_t irq_received;
38299 + atomic_unchecked_t irq_emitted;
38300
38301 int front_offset;
38302 } drm_i810_private_t;
38303 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38304 index a6f4cb5..6b2beb2 100644
38305 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38306 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38307 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38308 I915_READ(GTIMR));
38309 }
38310 seq_printf(m, "Interrupts received: %d\n",
38311 - atomic_read(&dev_priv->irq_received));
38312 + atomic_read_unchecked(&dev_priv->irq_received));
38313 for_each_ring(ring, dev_priv, i) {
38314 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38315 seq_printf(m,
38316 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38317 index d5c784d..06e5c36 100644
38318 --- a/drivers/gpu/drm/i915/i915_dma.c
38319 +++ b/drivers/gpu/drm/i915/i915_dma.c
38320 @@ -1263,7 +1263,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38321 bool can_switch;
38322
38323 spin_lock(&dev->count_lock);
38324 - can_switch = (dev->open_count == 0);
38325 + can_switch = (local_read(&dev->open_count) == 0);
38326 spin_unlock(&dev->count_lock);
38327 return can_switch;
38328 }
38329 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38330 index ab0f2c0..53c1bda 100644
38331 --- a/drivers/gpu/drm/i915/i915_drv.h
38332 +++ b/drivers/gpu/drm/i915/i915_drv.h
38333 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
38334 drm_dma_handle_t *status_page_dmah;
38335 struct resource mch_res;
38336
38337 - atomic_t irq_received;
38338 + atomic_unchecked_t irq_received;
38339
38340 /* protects the irq masks */
38341 spinlock_t irq_lock;
38342 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38343 index bf34577..3fd2ffa 100644
38344 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38345 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38346 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38347
38348 static int
38349 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38350 - int count)
38351 + unsigned int count)
38352 {
38353 - int i;
38354 + unsigned int i;
38355 int relocs_total = 0;
38356 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38357
38358 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38359 index 3c59584..500f2e9 100644
38360 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38361 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38362 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38363 (unsigned long)request);
38364 }
38365
38366 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38367 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38368 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38369 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38370 [DRM_I915_GETPARAM] = compat_i915_getparam,
38371 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38372 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38373 {
38374 unsigned int nr = DRM_IOCTL_NR(cmd);
38375 - drm_ioctl_compat_t *fn = NULL;
38376 int ret;
38377
38378 if (nr < DRM_COMMAND_BASE)
38379 return drm_compat_ioctl(filp, cmd, arg);
38380
38381 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38382 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38383 -
38384 - if (fn != NULL)
38385 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38386 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38387 ret = (*fn) (filp, cmd, arg);
38388 - else
38389 + } else
38390 ret = drm_ioctl(filp, cmd, arg);
38391
38392 return ret;
38393 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38394 index 4b91228..590c643 100644
38395 --- a/drivers/gpu/drm/i915/i915_irq.c
38396 +++ b/drivers/gpu/drm/i915/i915_irq.c
38397 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38398 int pipe;
38399 u32 pipe_stats[I915_MAX_PIPES];
38400
38401 - atomic_inc(&dev_priv->irq_received);
38402 + atomic_inc_unchecked(&dev_priv->irq_received);
38403
38404 while (true) {
38405 iir = I915_READ(VLV_IIR);
38406 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38407 irqreturn_t ret = IRQ_NONE;
38408 bool err_int_reenable = false;
38409
38410 - atomic_inc(&dev_priv->irq_received);
38411 + atomic_inc_unchecked(&dev_priv->irq_received);
38412
38413 /* We get interrupts on unclaimed registers, so check for this before we
38414 * do any I915_{READ,WRITE}. */
38415 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38416 {
38417 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38418
38419 - atomic_set(&dev_priv->irq_received, 0);
38420 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38421
38422 I915_WRITE(HWSTAM, 0xeffe);
38423
38424 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38425 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38426 int pipe;
38427
38428 - atomic_set(&dev_priv->irq_received, 0);
38429 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38430
38431 /* VLV magic */
38432 I915_WRITE(VLV_IMR, 0);
38433 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38434 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38435 int pipe;
38436
38437 - atomic_set(&dev_priv->irq_received, 0);
38438 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38439
38440 for_each_pipe(pipe)
38441 I915_WRITE(PIPESTAT(pipe), 0);
38442 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38443 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38444 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38445
38446 - atomic_inc(&dev_priv->irq_received);
38447 + atomic_inc_unchecked(&dev_priv->irq_received);
38448
38449 iir = I915_READ16(IIR);
38450 if (iir == 0)
38451 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38452 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38453 int pipe;
38454
38455 - atomic_set(&dev_priv->irq_received, 0);
38456 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38457
38458 if (I915_HAS_HOTPLUG(dev)) {
38459 I915_WRITE(PORT_HOTPLUG_EN, 0);
38460 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38461 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38462 int pipe, ret = IRQ_NONE;
38463
38464 - atomic_inc(&dev_priv->irq_received);
38465 + atomic_inc_unchecked(&dev_priv->irq_received);
38466
38467 iir = I915_READ(IIR);
38468 do {
38469 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38470 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38471 int pipe;
38472
38473 - atomic_set(&dev_priv->irq_received, 0);
38474 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38475
38476 I915_WRITE(PORT_HOTPLUG_EN, 0);
38477 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38478 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38479 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38480 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38481
38482 - atomic_inc(&dev_priv->irq_received);
38483 + atomic_inc_unchecked(&dev_priv->irq_received);
38484
38485 iir = I915_READ(IIR);
38486
38487 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38488 index d78d33f..01d7c58 100644
38489 --- a/drivers/gpu/drm/i915/intel_display.c
38490 +++ b/drivers/gpu/drm/i915/intel_display.c
38491 @@ -9972,13 +9972,13 @@ struct intel_quirk {
38492 int subsystem_vendor;
38493 int subsystem_device;
38494 void (*hook)(struct drm_device *dev);
38495 -};
38496 +} __do_const;
38497
38498 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38499 struct intel_dmi_quirk {
38500 void (*hook)(struct drm_device *dev);
38501 const struct dmi_system_id (*dmi_id_list)[];
38502 -};
38503 +} __do_const;
38504
38505 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38506 {
38507 @@ -9986,18 +9986,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38508 return 1;
38509 }
38510
38511 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38512 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38513 {
38514 - .dmi_id_list = &(const struct dmi_system_id[]) {
38515 - {
38516 - .callback = intel_dmi_reverse_brightness,
38517 - .ident = "NCR Corporation",
38518 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38519 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38520 - },
38521 - },
38522 - { } /* terminating entry */
38523 + .callback = intel_dmi_reverse_brightness,
38524 + .ident = "NCR Corporation",
38525 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38526 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38527 },
38528 + },
38529 + { } /* terminating entry */
38530 +};
38531 +
38532 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38533 + {
38534 + .dmi_id_list = &intel_dmi_quirks_table,
38535 .hook = quirk_invert_brightness,
38536 },
38537 };
38538 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38539 index ca4bc54..ee598a2 100644
38540 --- a/drivers/gpu/drm/mga/mga_drv.h
38541 +++ b/drivers/gpu/drm/mga/mga_drv.h
38542 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38543 u32 clear_cmd;
38544 u32 maccess;
38545
38546 - atomic_t vbl_received; /**< Number of vblanks received. */
38547 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38548 wait_queue_head_t fence_queue;
38549 - atomic_t last_fence_retired;
38550 + atomic_unchecked_t last_fence_retired;
38551 u32 next_fence_to_post;
38552
38553 unsigned int fb_cpp;
38554 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38555 index 709e90d..89a1c0d 100644
38556 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38557 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38558 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38559 return 0;
38560 }
38561
38562 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38563 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38564 [DRM_MGA_INIT] = compat_mga_init,
38565 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38566 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38567 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38568 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38569 {
38570 unsigned int nr = DRM_IOCTL_NR(cmd);
38571 - drm_ioctl_compat_t *fn = NULL;
38572 int ret;
38573
38574 if (nr < DRM_COMMAND_BASE)
38575 return drm_compat_ioctl(filp, cmd, arg);
38576
38577 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38578 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38579 -
38580 - if (fn != NULL)
38581 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38582 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38583 ret = (*fn) (filp, cmd, arg);
38584 - else
38585 + } else
38586 ret = drm_ioctl(filp, cmd, arg);
38587
38588 return ret;
38589 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38590 index 598c281..60d590e 100644
38591 --- a/drivers/gpu/drm/mga/mga_irq.c
38592 +++ b/drivers/gpu/drm/mga/mga_irq.c
38593 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38594 if (crtc != 0)
38595 return 0;
38596
38597 - return atomic_read(&dev_priv->vbl_received);
38598 + return atomic_read_unchecked(&dev_priv->vbl_received);
38599 }
38600
38601
38602 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38603 /* VBLANK interrupt */
38604 if (status & MGA_VLINEPEN) {
38605 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38606 - atomic_inc(&dev_priv->vbl_received);
38607 + atomic_inc_unchecked(&dev_priv->vbl_received);
38608 drm_handle_vblank(dev, 0);
38609 handled = 1;
38610 }
38611 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38612 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38613 MGA_WRITE(MGA_PRIMEND, prim_end);
38614
38615 - atomic_inc(&dev_priv->last_fence_retired);
38616 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38617 DRM_WAKEUP(&dev_priv->fence_queue);
38618 handled = 1;
38619 }
38620 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38621 * using fences.
38622 */
38623 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38624 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38625 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38626 - *sequence) <= (1 << 23)));
38627
38628 *sequence = cur_fence;
38629 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38630 index 3e72876..d1c15ad 100644
38631 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38632 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38633 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38634 struct bit_table {
38635 const char id;
38636 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38637 -};
38638 +} __no_const;
38639
38640 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38641
38642 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38643 index 994fd6e..6e12565 100644
38644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38645 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38646 @@ -94,7 +94,6 @@ struct nouveau_drm {
38647 struct drm_global_reference mem_global_ref;
38648 struct ttm_bo_global_ref bo_global_ref;
38649 struct ttm_bo_device bdev;
38650 - atomic_t validate_sequence;
38651 int (*move)(struct nouveau_channel *,
38652 struct ttm_buffer_object *,
38653 struct ttm_mem_reg *, struct ttm_mem_reg *);
38654 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38655 index c1a7e5a..38b8539 100644
38656 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38657 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38658 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38659 unsigned long arg)
38660 {
38661 unsigned int nr = DRM_IOCTL_NR(cmd);
38662 - drm_ioctl_compat_t *fn = NULL;
38663 + drm_ioctl_compat_t fn = NULL;
38664 int ret;
38665
38666 if (nr < DRM_COMMAND_BASE)
38667 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38668 index 81638d7..2e45854 100644
38669 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38670 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38671 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38672 bool can_switch;
38673
38674 spin_lock(&dev->count_lock);
38675 - can_switch = (dev->open_count == 0);
38676 + can_switch = (local_read(&dev->open_count) == 0);
38677 spin_unlock(&dev->count_lock);
38678 return can_switch;
38679 }
38680 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
38681 index eb89653..613cf71 100644
38682 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
38683 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
38684 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
38685 int ret;
38686
38687 mutex_lock(&qdev->async_io_mutex);
38688 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38689 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38690 if (qdev->last_sent_io_cmd > irq_num) {
38691 if (intr)
38692 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38693 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38694 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38695 else
38696 ret = wait_event_timeout(qdev->io_cmd_event,
38697 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38698 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38699 /* 0 is timeout, just bail the "hw" has gone away */
38700 if (ret <= 0)
38701 goto out;
38702 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38703 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38704 }
38705 outb(val, addr);
38706 qdev->last_sent_io_cmd = irq_num + 1;
38707 if (intr)
38708 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38709 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38710 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38711 else
38712 ret = wait_event_timeout(qdev->io_cmd_event,
38713 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38714 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38715 out:
38716 if (ret > 0)
38717 ret = 0;
38718 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
38719 index c3c2bbd..bc3c0fb 100644
38720 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
38721 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
38722 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
38723 struct drm_info_node *node = (struct drm_info_node *) m->private;
38724 struct qxl_device *qdev = node->minor->dev->dev_private;
38725
38726 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
38727 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
38728 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
38729 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
38730 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
38731 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
38732 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
38733 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
38734 seq_printf(m, "%d\n", qdev->irq_received_error);
38735 return 0;
38736 }
38737 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
38738 index f7c9add..fb971d2 100644
38739 --- a/drivers/gpu/drm/qxl/qxl_drv.h
38740 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
38741 @@ -290,10 +290,10 @@ struct qxl_device {
38742 unsigned int last_sent_io_cmd;
38743
38744 /* interrupt handling */
38745 - atomic_t irq_received;
38746 - atomic_t irq_received_display;
38747 - atomic_t irq_received_cursor;
38748 - atomic_t irq_received_io_cmd;
38749 + atomic_unchecked_t irq_received;
38750 + atomic_unchecked_t irq_received_display;
38751 + atomic_unchecked_t irq_received_cursor;
38752 + atomic_unchecked_t irq_received_io_cmd;
38753 unsigned irq_received_error;
38754 wait_queue_head_t display_event;
38755 wait_queue_head_t cursor_event;
38756 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
38757 index 21393dc..329f3a9 100644
38758 --- a/drivers/gpu/drm/qxl/qxl_irq.c
38759 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
38760 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
38761
38762 pending = xchg(&qdev->ram_header->int_pending, 0);
38763
38764 - atomic_inc(&qdev->irq_received);
38765 + atomic_inc_unchecked(&qdev->irq_received);
38766
38767 if (pending & QXL_INTERRUPT_DISPLAY) {
38768 - atomic_inc(&qdev->irq_received_display);
38769 + atomic_inc_unchecked(&qdev->irq_received_display);
38770 wake_up_all(&qdev->display_event);
38771 qxl_queue_garbage_collect(qdev, false);
38772 }
38773 if (pending & QXL_INTERRUPT_CURSOR) {
38774 - atomic_inc(&qdev->irq_received_cursor);
38775 + atomic_inc_unchecked(&qdev->irq_received_cursor);
38776 wake_up_all(&qdev->cursor_event);
38777 }
38778 if (pending & QXL_INTERRUPT_IO_CMD) {
38779 - atomic_inc(&qdev->irq_received_io_cmd);
38780 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
38781 wake_up_all(&qdev->io_cmd_event);
38782 }
38783 if (pending & QXL_INTERRUPT_ERROR) {
38784 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
38785 init_waitqueue_head(&qdev->io_cmd_event);
38786 INIT_WORK(&qdev->client_monitors_config_work,
38787 qxl_client_monitors_config_work_func);
38788 - atomic_set(&qdev->irq_received, 0);
38789 - atomic_set(&qdev->irq_received_display, 0);
38790 - atomic_set(&qdev->irq_received_cursor, 0);
38791 - atomic_set(&qdev->irq_received_io_cmd, 0);
38792 + atomic_set_unchecked(&qdev->irq_received, 0);
38793 + atomic_set_unchecked(&qdev->irq_received_display, 0);
38794 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
38795 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
38796 qdev->irq_received_error = 0;
38797 ret = drm_irq_install(qdev->ddev);
38798 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
38799 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38800 index 037786d..2a95e33 100644
38801 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38802 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38803 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38804 }
38805 }
38806
38807 -static struct vm_operations_struct qxl_ttm_vm_ops;
38808 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38809 static const struct vm_operations_struct *ttm_vm_ops;
38810
38811 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38812 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38813 return r;
38814 if (unlikely(ttm_vm_ops == NULL)) {
38815 ttm_vm_ops = vma->vm_ops;
38816 + pax_open_kernel();
38817 qxl_ttm_vm_ops = *ttm_vm_ops;
38818 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38819 + pax_close_kernel();
38820 }
38821 vma->vm_ops = &qxl_ttm_vm_ops;
38822 return 0;
38823 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38824 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38825 {
38826 #if defined(CONFIG_DEBUG_FS)
38827 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38828 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38829 - unsigned i;
38830 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38831 + {
38832 + .name = "qxl_mem_mm",
38833 + .show = &qxl_mm_dump_table,
38834 + },
38835 + {
38836 + .name = "qxl_surf_mm",
38837 + .show = &qxl_mm_dump_table,
38838 + }
38839 + };
38840
38841 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38842 - if (i == 0)
38843 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38844 - else
38845 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38846 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38847 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38848 - qxl_mem_types_list[i].driver_features = 0;
38849 - if (i == 0)
38850 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38851 - else
38852 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38853 + pax_open_kernel();
38854 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38855 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38856 + pax_close_kernel();
38857
38858 - }
38859 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38860 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38861 #else
38862 return 0;
38863 #endif
38864 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38865 index c451257..0ad2134 100644
38866 --- a/drivers/gpu/drm/r128/r128_cce.c
38867 +++ b/drivers/gpu/drm/r128/r128_cce.c
38868 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38869
38870 /* GH: Simple idle check.
38871 */
38872 - atomic_set(&dev_priv->idle_count, 0);
38873 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38874
38875 /* We don't support anything other than bus-mastering ring mode,
38876 * but the ring can be in either AGP or PCI space for the ring
38877 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38878 index 56eb5e3..c4ec43d 100644
38879 --- a/drivers/gpu/drm/r128/r128_drv.h
38880 +++ b/drivers/gpu/drm/r128/r128_drv.h
38881 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38882 int is_pci;
38883 unsigned long cce_buffers_offset;
38884
38885 - atomic_t idle_count;
38886 + atomic_unchecked_t idle_count;
38887
38888 int page_flipping;
38889 int current_page;
38890 u32 crtc_offset;
38891 u32 crtc_offset_cntl;
38892
38893 - atomic_t vbl_received;
38894 + atomic_unchecked_t vbl_received;
38895
38896 u32 color_fmt;
38897 unsigned int front_offset;
38898 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38899 index a954c54..9cc595c 100644
38900 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38901 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38902 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38903 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38904 }
38905
38906 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38907 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38908 [DRM_R128_INIT] = compat_r128_init,
38909 [DRM_R128_DEPTH] = compat_r128_depth,
38910 [DRM_R128_STIPPLE] = compat_r128_stipple,
38911 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38912 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38913 {
38914 unsigned int nr = DRM_IOCTL_NR(cmd);
38915 - drm_ioctl_compat_t *fn = NULL;
38916 int ret;
38917
38918 if (nr < DRM_COMMAND_BASE)
38919 return drm_compat_ioctl(filp, cmd, arg);
38920
38921 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38922 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38923 -
38924 - if (fn != NULL)
38925 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38926 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38927 ret = (*fn) (filp, cmd, arg);
38928 - else
38929 + } else
38930 ret = drm_ioctl(filp, cmd, arg);
38931
38932 return ret;
38933 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38934 index 2ea4f09..d391371 100644
38935 --- a/drivers/gpu/drm/r128/r128_irq.c
38936 +++ b/drivers/gpu/drm/r128/r128_irq.c
38937 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38938 if (crtc != 0)
38939 return 0;
38940
38941 - return atomic_read(&dev_priv->vbl_received);
38942 + return atomic_read_unchecked(&dev_priv->vbl_received);
38943 }
38944
38945 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38946 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38947 /* VBLANK interrupt */
38948 if (status & R128_CRTC_VBLANK_INT) {
38949 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38950 - atomic_inc(&dev_priv->vbl_received);
38951 + atomic_inc_unchecked(&dev_priv->vbl_received);
38952 drm_handle_vblank(dev, 0);
38953 return IRQ_HANDLED;
38954 }
38955 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38956 index 01dd9ae..6352f04 100644
38957 --- a/drivers/gpu/drm/r128/r128_state.c
38958 +++ b/drivers/gpu/drm/r128/r128_state.c
38959 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38960
38961 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38962 {
38963 - if (atomic_read(&dev_priv->idle_count) == 0)
38964 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38965 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38966 else
38967 - atomic_set(&dev_priv->idle_count, 0);
38968 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38969 }
38970
38971 #endif
38972 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38973 index af85299..ed9ac8d 100644
38974 --- a/drivers/gpu/drm/radeon/mkregtable.c
38975 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38976 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38977 regex_t mask_rex;
38978 regmatch_t match[4];
38979 char buf[1024];
38980 - size_t end;
38981 + long end;
38982 int len;
38983 int done = 0;
38984 int r;
38985 unsigned o;
38986 struct offset *offset;
38987 char last_reg_s[10];
38988 - int last_reg;
38989 + unsigned long last_reg;
38990
38991 if (regcomp
38992 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38993 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38994 index 841d0e0..9eaa268 100644
38995 --- a/drivers/gpu/drm/radeon/radeon_device.c
38996 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38997 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38998 bool can_switch;
38999
39000 spin_lock(&dev->count_lock);
39001 - can_switch = (dev->open_count == 0);
39002 + can_switch = (local_read(&dev->open_count) == 0);
39003 spin_unlock(&dev->count_lock);
39004 return can_switch;
39005 }
39006 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39007 index b369d42..8dd04eb 100644
39008 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39009 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39010 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39011
39012 /* SW interrupt */
39013 wait_queue_head_t swi_queue;
39014 - atomic_t swi_emitted;
39015 + atomic_unchecked_t swi_emitted;
39016 int vblank_crtc;
39017 uint32_t irq_enable_reg;
39018 uint32_t r500_disp_irq_reg;
39019 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39020 index c180df8..5fd8186 100644
39021 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39022 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39023 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39024 request = compat_alloc_user_space(sizeof(*request));
39025 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39026 || __put_user(req32.param, &request->param)
39027 - || __put_user((void __user *)(unsigned long)req32.value,
39028 + || __put_user((unsigned long)req32.value,
39029 &request->value))
39030 return -EFAULT;
39031
39032 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39033 #define compat_radeon_cp_setparam NULL
39034 #endif /* X86_64 || IA64 */
39035
39036 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39037 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39038 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39039 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39040 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39041 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39042 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39043 {
39044 unsigned int nr = DRM_IOCTL_NR(cmd);
39045 - drm_ioctl_compat_t *fn = NULL;
39046 int ret;
39047
39048 if (nr < DRM_COMMAND_BASE)
39049 return drm_compat_ioctl(filp, cmd, arg);
39050
39051 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39052 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39053 -
39054 - if (fn != NULL)
39055 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39056 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39057 ret = (*fn) (filp, cmd, arg);
39058 - else
39059 + } else
39060 ret = drm_ioctl(filp, cmd, arg);
39061
39062 return ret;
39063 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39064 index 8d68e97..9dcfed8 100644
39065 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39066 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39067 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39068 unsigned int ret;
39069 RING_LOCALS;
39070
39071 - atomic_inc(&dev_priv->swi_emitted);
39072 - ret = atomic_read(&dev_priv->swi_emitted);
39073 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39074 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39075
39076 BEGIN_RING(4);
39077 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39078 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39079 drm_radeon_private_t *dev_priv =
39080 (drm_radeon_private_t *) dev->dev_private;
39081
39082 - atomic_set(&dev_priv->swi_emitted, 0);
39083 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39084 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39085
39086 dev->max_vblank_count = 0x001fffff;
39087 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39088 index 4d20910..6726b6d 100644
39089 --- a/drivers/gpu/drm/radeon/radeon_state.c
39090 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39091 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39092 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39093 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39094
39095 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39096 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39097 sarea_priv->nbox * sizeof(depth_boxes[0])))
39098 return -EFAULT;
39099
39100 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39101 {
39102 drm_radeon_private_t *dev_priv = dev->dev_private;
39103 drm_radeon_getparam_t *param = data;
39104 - int value;
39105 + int value = 0;
39106
39107 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39108
39109 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39110 index 71245d6..94c556d 100644
39111 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39112 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39113 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39114 man->size = size >> PAGE_SHIFT;
39115 }
39116
39117 -static struct vm_operations_struct radeon_ttm_vm_ops;
39118 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39119 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39120
39121 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39122 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39123 }
39124 if (unlikely(ttm_vm_ops == NULL)) {
39125 ttm_vm_ops = vma->vm_ops;
39126 + pax_open_kernel();
39127 radeon_ttm_vm_ops = *ttm_vm_ops;
39128 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39129 + pax_close_kernel();
39130 }
39131 vma->vm_ops = &radeon_ttm_vm_ops;
39132 return 0;
39133 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39134 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39135 {
39136 #if defined(CONFIG_DEBUG_FS)
39137 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39138 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39139 - unsigned i;
39140 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39141 + {
39142 + .name = "radeon_vram_mm",
39143 + .show = &radeon_mm_dump_table,
39144 + },
39145 + {
39146 + .name = "radeon_gtt_mm",
39147 + .show = &radeon_mm_dump_table,
39148 + },
39149 + {
39150 + .name = "ttm_page_pool",
39151 + .show = &ttm_page_alloc_debugfs,
39152 + },
39153 + {
39154 + .name = "ttm_dma_page_pool",
39155 + .show = &ttm_dma_page_alloc_debugfs,
39156 + },
39157 + };
39158 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39159
39160 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39161 - if (i == 0)
39162 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39163 - else
39164 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39165 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39166 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39167 - radeon_mem_types_list[i].driver_features = 0;
39168 - if (i == 0)
39169 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39170 - else
39171 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39172 -
39173 - }
39174 - /* Add ttm page pool to debugfs */
39175 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39176 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39177 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39178 - radeon_mem_types_list[i].driver_features = 0;
39179 - radeon_mem_types_list[i++].data = NULL;
39180 + pax_open_kernel();
39181 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39182 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39183 + pax_close_kernel();
39184 #ifdef CONFIG_SWIOTLB
39185 - if (swiotlb_nr_tbl()) {
39186 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39187 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39188 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39189 - radeon_mem_types_list[i].driver_features = 0;
39190 - radeon_mem_types_list[i++].data = NULL;
39191 - }
39192 + if (swiotlb_nr_tbl())
39193 + i++;
39194 #endif
39195 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39196
39197 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39198 index 1447d79..40b2a5b 100644
39199 --- a/drivers/gpu/drm/radeon/rs690.c
39200 +++ b/drivers/gpu/drm/radeon/rs690.c
39201 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39202 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39203 rdev->pm.sideport_bandwidth.full)
39204 max_bandwidth = rdev->pm.sideport_bandwidth;
39205 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39206 + read_delay_latency.full = dfixed_const(800 * 1000);
39207 read_delay_latency.full = dfixed_div(read_delay_latency,
39208 rdev->pm.igp_sideport_mclk);
39209 + a.full = dfixed_const(370);
39210 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39211 } else {
39212 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39213 rdev->pm.k8_bandwidth.full)
39214 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39215 index dbc2def..0a9f710 100644
39216 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39217 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39218 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39219 zone->glob = glob;
39220 glob->zone_kernel = zone;
39221 ret = kobject_init_and_add(
39222 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39223 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39224 if (unlikely(ret != 0)) {
39225 kobject_put(&zone->kobj);
39226 return ret;
39227 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39228 zone->glob = glob;
39229 glob->zone_dma32 = zone;
39230 ret = kobject_init_and_add(
39231 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39232 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39233 if (unlikely(ret != 0)) {
39234 kobject_put(&zone->kobj);
39235 return ret;
39236 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39237 index 863bef9..cba15cf 100644
39238 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39239 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39240 @@ -391,9 +391,9 @@ out:
39241 static unsigned long
39242 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
39243 {
39244 - static atomic_t start_pool = ATOMIC_INIT(0);
39245 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39246 unsigned i;
39247 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39248 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39249 struct ttm_page_pool *pool;
39250 int shrink_pages = sc->nr_to_scan;
39251 unsigned long freed = 0;
39252 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39253 index 97e9d61..bf23c461 100644
39254 --- a/drivers/gpu/drm/udl/udl_fb.c
39255 +++ b/drivers/gpu/drm/udl/udl_fb.c
39256 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39257 fb_deferred_io_cleanup(info);
39258 kfree(info->fbdefio);
39259 info->fbdefio = NULL;
39260 - info->fbops->fb_mmap = udl_fb_mmap;
39261 }
39262
39263 pr_warn("released /dev/fb%d user=%d count=%d\n",
39264 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39265 index a811ef2..ff99b05 100644
39266 --- a/drivers/gpu/drm/via/via_drv.h
39267 +++ b/drivers/gpu/drm/via/via_drv.h
39268 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39269 typedef uint32_t maskarray_t[5];
39270
39271 typedef struct drm_via_irq {
39272 - atomic_t irq_received;
39273 + atomic_unchecked_t irq_received;
39274 uint32_t pending_mask;
39275 uint32_t enable_mask;
39276 wait_queue_head_t irq_queue;
39277 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39278 struct timeval last_vblank;
39279 int last_vblank_valid;
39280 unsigned usec_per_vblank;
39281 - atomic_t vbl_received;
39282 + atomic_unchecked_t vbl_received;
39283 drm_via_state_t hc_state;
39284 char pci_buf[VIA_PCI_BUF_SIZE];
39285 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39286 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39287 index ac98964..5dbf512 100644
39288 --- a/drivers/gpu/drm/via/via_irq.c
39289 +++ b/drivers/gpu/drm/via/via_irq.c
39290 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39291 if (crtc != 0)
39292 return 0;
39293
39294 - return atomic_read(&dev_priv->vbl_received);
39295 + return atomic_read_unchecked(&dev_priv->vbl_received);
39296 }
39297
39298 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39299 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39300
39301 status = VIA_READ(VIA_REG_INTERRUPT);
39302 if (status & VIA_IRQ_VBLANK_PENDING) {
39303 - atomic_inc(&dev_priv->vbl_received);
39304 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39305 + atomic_inc_unchecked(&dev_priv->vbl_received);
39306 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39307 do_gettimeofday(&cur_vblank);
39308 if (dev_priv->last_vblank_valid) {
39309 dev_priv->usec_per_vblank =
39310 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39311 dev_priv->last_vblank = cur_vblank;
39312 dev_priv->last_vblank_valid = 1;
39313 }
39314 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39315 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39316 DRM_DEBUG("US per vblank is: %u\n",
39317 dev_priv->usec_per_vblank);
39318 }
39319 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39320
39321 for (i = 0; i < dev_priv->num_irqs; ++i) {
39322 if (status & cur_irq->pending_mask) {
39323 - atomic_inc(&cur_irq->irq_received);
39324 + atomic_inc_unchecked(&cur_irq->irq_received);
39325 DRM_WAKEUP(&cur_irq->irq_queue);
39326 handled = 1;
39327 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39328 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39329 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39330 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39331 masks[irq][4]));
39332 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39333 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39334 } else {
39335 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39336 (((cur_irq_sequence =
39337 - atomic_read(&cur_irq->irq_received)) -
39338 + atomic_read_unchecked(&cur_irq->irq_received)) -
39339 *sequence) <= (1 << 23)));
39340 }
39341 *sequence = cur_irq_sequence;
39342 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39343 }
39344
39345 for (i = 0; i < dev_priv->num_irqs; ++i) {
39346 - atomic_set(&cur_irq->irq_received, 0);
39347 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39348 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39349 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39350 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39351 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39352 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39353 case VIA_IRQ_RELATIVE:
39354 irqwait->request.sequence +=
39355 - atomic_read(&cur_irq->irq_received);
39356 + atomic_read_unchecked(&cur_irq->irq_received);
39357 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39358 case VIA_IRQ_ABSOLUTE:
39359 break;
39360 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39361 index 150ec64..f5165f2 100644
39362 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39363 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39364 @@ -290,7 +290,7 @@ struct vmw_private {
39365 * Fencing and IRQs.
39366 */
39367
39368 - atomic_t marker_seq;
39369 + atomic_unchecked_t marker_seq;
39370 wait_queue_head_t fence_queue;
39371 wait_queue_head_t fifo_queue;
39372 int fence_queue_waiters; /* Protected by hw_mutex */
39373 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39374 index 3eb1486..0a47ee9 100644
39375 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39376 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39377 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39378 (unsigned int) min,
39379 (unsigned int) fifo->capabilities);
39380
39381 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39382 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39383 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39384 vmw_marker_queue_init(&fifo->marker_queue);
39385 return vmw_fifo_send_fence(dev_priv, &dummy);
39386 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39387 if (reserveable)
39388 iowrite32(bytes, fifo_mem +
39389 SVGA_FIFO_RESERVED);
39390 - return fifo_mem + (next_cmd >> 2);
39391 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39392 } else {
39393 need_bounce = true;
39394 }
39395 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39396
39397 fm = vmw_fifo_reserve(dev_priv, bytes);
39398 if (unlikely(fm == NULL)) {
39399 - *seqno = atomic_read(&dev_priv->marker_seq);
39400 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39401 ret = -ENOMEM;
39402 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39403 false, 3*HZ);
39404 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39405 }
39406
39407 do {
39408 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39409 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39410 } while (*seqno == 0);
39411
39412 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39413 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39414 index c509d40..3b640c3 100644
39415 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39416 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39417 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39418 int ret;
39419
39420 num_clips = arg->num_clips;
39421 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39422 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39423
39424 if (unlikely(num_clips == 0))
39425 return 0;
39426 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39427 int ret;
39428
39429 num_clips = arg->num_clips;
39430 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39431 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39432
39433 if (unlikely(num_clips == 0))
39434 return 0;
39435 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39436 index 4640adb..e1384ed 100644
39437 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39438 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39439 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39440 * emitted. Then the fence is stale and signaled.
39441 */
39442
39443 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39444 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39445 > VMW_FENCE_WRAP);
39446
39447 return ret;
39448 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39449
39450 if (fifo_idle)
39451 down_read(&fifo_state->rwsem);
39452 - signal_seq = atomic_read(&dev_priv->marker_seq);
39453 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39454 ret = 0;
39455
39456 for (;;) {
39457 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39458 index 8a8725c2..afed796 100644
39459 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39460 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39461 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39462 while (!vmw_lag_lt(queue, us)) {
39463 spin_lock(&queue->lock);
39464 if (list_empty(&queue->head))
39465 - seqno = atomic_read(&dev_priv->marker_seq);
39466 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39467 else {
39468 marker = list_first_entry(&queue->head,
39469 struct vmw_marker, head);
39470 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39471 index b1a05ad..1c9d899 100644
39472 --- a/drivers/gpu/host1x/drm/dc.c
39473 +++ b/drivers/gpu/host1x/drm/dc.c
39474 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39475 }
39476
39477 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39478 - dc->debugfs_files[i].data = dc;
39479 + *(void **)&dc->debugfs_files[i].data = dc;
39480
39481 err = drm_debugfs_create_files(dc->debugfs_files,
39482 ARRAY_SIZE(debugfs_files),
39483 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
39484 index ec0ae2d..dc0780b 100644
39485 --- a/drivers/gpu/vga/vga_switcheroo.c
39486 +++ b/drivers/gpu/vga/vga_switcheroo.c
39487 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
39488
39489 /* this version is for the case where the power switch is separate
39490 to the device being powered down. */
39491 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
39492 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
39493 {
39494 /* copy over all the bus versions */
39495 if (dev->bus && dev->bus->pm) {
39496 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
39497 return ret;
39498 }
39499
39500 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
39501 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
39502 {
39503 /* copy over all the bus versions */
39504 if (dev->bus && dev->bus->pm) {
39505 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39506 index e80da62..bbcba01 100644
39507 --- a/drivers/hid/hid-core.c
39508 +++ b/drivers/hid/hid-core.c
39509 @@ -2417,7 +2417,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39510
39511 int hid_add_device(struct hid_device *hdev)
39512 {
39513 - static atomic_t id = ATOMIC_INIT(0);
39514 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39515 int ret;
39516
39517 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39518 @@ -2451,7 +2451,7 @@ int hid_add_device(struct hid_device *hdev)
39519 /* XXX hack, any other cleaner solution after the driver core
39520 * is converted to allow more than 20 bytes as the device name? */
39521 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39522 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39523 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39524
39525 hid_debug_register(hdev, dev_name(&hdev->dev));
39526 ret = device_add(&hdev->dev);
39527 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39528 index c13fb5b..55a3802 100644
39529 --- a/drivers/hid/hid-wiimote-debug.c
39530 +++ b/drivers/hid/hid-wiimote-debug.c
39531 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39532 else if (size == 0)
39533 return -EIO;
39534
39535 - if (copy_to_user(u, buf, size))
39536 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39537 return -EFAULT;
39538
39539 *off += size;
39540 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39541 index 93b00d7..0a71596 100644
39542 --- a/drivers/hid/uhid.c
39543 +++ b/drivers/hid/uhid.c
39544 @@ -47,7 +47,7 @@ struct uhid_device {
39545 struct mutex report_lock;
39546 wait_queue_head_t report_wait;
39547 atomic_t report_done;
39548 - atomic_t report_id;
39549 + atomic_unchecked_t report_id;
39550 struct uhid_event report_buf;
39551 };
39552
39553 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39554
39555 spin_lock_irqsave(&uhid->qlock, flags);
39556 ev->type = UHID_FEATURE;
39557 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39558 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39559 ev->u.feature.rnum = rnum;
39560 ev->u.feature.rtype = report_type;
39561
39562 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39563 spin_lock_irqsave(&uhid->qlock, flags);
39564
39565 /* id for old report; drop it silently */
39566 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39567 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39568 goto unlock;
39569 if (atomic_read(&uhid->report_done))
39570 goto unlock;
39571 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39572 index 6de6c98..18319e9 100644
39573 --- a/drivers/hv/channel.c
39574 +++ b/drivers/hv/channel.c
39575 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39576 int ret = 0;
39577 int t;
39578
39579 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39580 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39581 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39582 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39583
39584 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39585 if (ret)
39586 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39587 index 88f4096..e50452e 100644
39588 --- a/drivers/hv/hv.c
39589 +++ b/drivers/hv/hv.c
39590 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39591 u64 output_address = (output) ? virt_to_phys(output) : 0;
39592 u32 output_address_hi = output_address >> 32;
39593 u32 output_address_lo = output_address & 0xFFFFFFFF;
39594 - void *hypercall_page = hv_context.hypercall_page;
39595 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39596
39597 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39598 "=a"(hv_status_lo) : "d" (control_hi),
39599 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39600 index 7e17a54..a50a33d 100644
39601 --- a/drivers/hv/hv_balloon.c
39602 +++ b/drivers/hv/hv_balloon.c
39603 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39604
39605 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39606 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39607 -static atomic_t trans_id = ATOMIC_INIT(0);
39608 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39609
39610 static int dm_ring_size = (5 * PAGE_SIZE);
39611
39612 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
39613 pr_info("Memory hot add failed\n");
39614
39615 dm->state = DM_INITIALIZED;
39616 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39617 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39618 vmbus_sendpacket(dm->dev->channel, &resp,
39619 sizeof(struct dm_hot_add_response),
39620 (unsigned long)NULL,
39621 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39622 memset(&status, 0, sizeof(struct dm_status));
39623 status.hdr.type = DM_STATUS_REPORT;
39624 status.hdr.size = sizeof(struct dm_status);
39625 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39626 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39627
39628 /*
39629 * The host expects the guest to report free memory.
39630 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39631 * send the status. This can happen if we were interrupted
39632 * after we picked our transaction ID.
39633 */
39634 - if (status.hdr.trans_id != atomic_read(&trans_id))
39635 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39636 return;
39637
39638 vmbus_sendpacket(dm->dev->channel, &status,
39639 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
39640 */
39641
39642 do {
39643 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39644 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39645 ret = vmbus_sendpacket(dm_device.dev->channel,
39646 bl_resp,
39647 bl_resp->hdr.size,
39648 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39649
39650 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39651 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39652 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39653 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39654 resp.hdr.size = sizeof(struct dm_unballoon_response);
39655
39656 vmbus_sendpacket(dm_device.dev->channel, &resp,
39657 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39658 memset(&version_req, 0, sizeof(struct dm_version_request));
39659 version_req.hdr.type = DM_VERSION_REQUEST;
39660 version_req.hdr.size = sizeof(struct dm_version_request);
39661 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39662 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39663 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39664 version_req.is_last_attempt = 1;
39665
39666 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39667 memset(&version_req, 0, sizeof(struct dm_version_request));
39668 version_req.hdr.type = DM_VERSION_REQUEST;
39669 version_req.hdr.size = sizeof(struct dm_version_request);
39670 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39671 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39672 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39673 version_req.is_last_attempt = 0;
39674
39675 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39676 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39677 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39678 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39679 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39680 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39681
39682 cap_msg.caps.cap_bits.balloon = 1;
39683 cap_msg.caps.cap_bits.hot_add = 1;
39684 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39685 index d84918f..7f38f9f 100644
39686 --- a/drivers/hv/hyperv_vmbus.h
39687 +++ b/drivers/hv/hyperv_vmbus.h
39688 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39689 struct vmbus_connection {
39690 enum vmbus_connect_state conn_state;
39691
39692 - atomic_t next_gpadl_handle;
39693 + atomic_unchecked_t next_gpadl_handle;
39694
39695 /*
39696 * Represents channel interrupts. Each bit position represents a
39697 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39698 index f9fe46f..356b119 100644
39699 --- a/drivers/hv/vmbus_drv.c
39700 +++ b/drivers/hv/vmbus_drv.c
39701 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39702 {
39703 int ret = 0;
39704
39705 - static atomic_t device_num = ATOMIC_INIT(0);
39706 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39707
39708 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39709 - atomic_inc_return(&device_num));
39710 + atomic_inc_return_unchecked(&device_num));
39711
39712 child_device_obj->device.bus = &hv_bus;
39713 child_device_obj->device.parent = &hv_acpi_dev->dev;
39714 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39715 index a9e3d01..9dd246e 100644
39716 --- a/drivers/hwmon/acpi_power_meter.c
39717 +++ b/drivers/hwmon/acpi_power_meter.c
39718 @@ -117,7 +117,7 @@ struct sensor_template {
39719 struct device_attribute *devattr,
39720 const char *buf, size_t count);
39721 int index;
39722 -};
39723 +} __do_const;
39724
39725 /* Averaging interval */
39726 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39727 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39728 struct sensor_template *attrs)
39729 {
39730 struct device *dev = &resource->acpi_dev->dev;
39731 - struct sensor_device_attribute *sensors =
39732 + sensor_device_attribute_no_const *sensors =
39733 &resource->sensors[resource->num_sensors];
39734 int res = 0;
39735
39736 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39737 index 3288f13..71cfb4e 100644
39738 --- a/drivers/hwmon/applesmc.c
39739 +++ b/drivers/hwmon/applesmc.c
39740 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39741 {
39742 struct applesmc_node_group *grp;
39743 struct applesmc_dev_attr *node;
39744 - struct attribute *attr;
39745 + attribute_no_const *attr;
39746 int ret, i;
39747
39748 for (grp = groups; grp->format; grp++) {
39749 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39750 index b25c643..a13460d 100644
39751 --- a/drivers/hwmon/asus_atk0110.c
39752 +++ b/drivers/hwmon/asus_atk0110.c
39753 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39754 struct atk_sensor_data {
39755 struct list_head list;
39756 struct atk_data *data;
39757 - struct device_attribute label_attr;
39758 - struct device_attribute input_attr;
39759 - struct device_attribute limit1_attr;
39760 - struct device_attribute limit2_attr;
39761 + device_attribute_no_const label_attr;
39762 + device_attribute_no_const input_attr;
39763 + device_attribute_no_const limit1_attr;
39764 + device_attribute_no_const limit2_attr;
39765 char label_attr_name[ATTR_NAME_SIZE];
39766 char input_attr_name[ATTR_NAME_SIZE];
39767 char limit1_attr_name[ATTR_NAME_SIZE];
39768 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39769 static struct device_attribute atk_name_attr =
39770 __ATTR(name, 0444, atk_name_show, NULL);
39771
39772 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39773 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39774 sysfs_show_func show)
39775 {
39776 sysfs_attr_init(&attr->attr);
39777 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39778 index 78be661..4dd032f 100644
39779 --- a/drivers/hwmon/coretemp.c
39780 +++ b/drivers/hwmon/coretemp.c
39781 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39782 return NOTIFY_OK;
39783 }
39784
39785 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39786 +static struct notifier_block coretemp_cpu_notifier = {
39787 .notifier_call = coretemp_cpu_callback,
39788 };
39789
39790 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39791 index 632f1dc..57e6a58 100644
39792 --- a/drivers/hwmon/ibmaem.c
39793 +++ b/drivers/hwmon/ibmaem.c
39794 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39795 struct aem_rw_sensor_template *rw)
39796 {
39797 struct device *dev = &data->pdev->dev;
39798 - struct sensor_device_attribute *sensors = data->sensors;
39799 + sensor_device_attribute_no_const *sensors = data->sensors;
39800 int err;
39801
39802 /* Set up read-only sensors */
39803 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39804 index 708081b..fe2d4ab 100644
39805 --- a/drivers/hwmon/iio_hwmon.c
39806 +++ b/drivers/hwmon/iio_hwmon.c
39807 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39808 {
39809 struct device *dev = &pdev->dev;
39810 struct iio_hwmon_state *st;
39811 - struct sensor_device_attribute *a;
39812 + sensor_device_attribute_no_const *a;
39813 int ret, i;
39814 int in_i = 1, temp_i = 1, curr_i = 1;
39815 enum iio_chan_type type;
39816 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
39817 index 6eb03ce..bea7e3e 100644
39818 --- a/drivers/hwmon/nct6775.c
39819 +++ b/drivers/hwmon/nct6775.c
39820 @@ -936,10 +936,10 @@ static struct attribute_group *
39821 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
39822 int repeat)
39823 {
39824 - struct attribute_group *group;
39825 + attribute_group_no_const *group;
39826 struct sensor_device_attr_u *su;
39827 - struct sensor_device_attribute *a;
39828 - struct sensor_device_attribute_2 *a2;
39829 + sensor_device_attribute_no_const *a;
39830 + sensor_device_attribute_2_no_const *a2;
39831 struct attribute **attrs;
39832 struct sensor_device_template **t;
39833 int err, i, j, count;
39834 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39835 index 9319fcf..189ff45 100644
39836 --- a/drivers/hwmon/pmbus/pmbus_core.c
39837 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39838 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39839 return 0;
39840 }
39841
39842 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39843 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39844 const char *name,
39845 umode_t mode,
39846 ssize_t (*show)(struct device *dev,
39847 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39848 dev_attr->store = store;
39849 }
39850
39851 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39852 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39853 const char *name,
39854 umode_t mode,
39855 ssize_t (*show)(struct device *dev,
39856 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39857 u16 reg, u8 mask)
39858 {
39859 struct pmbus_boolean *boolean;
39860 - struct sensor_device_attribute *a;
39861 + sensor_device_attribute_no_const *a;
39862
39863 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39864 if (!boolean)
39865 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39866 bool update, bool readonly)
39867 {
39868 struct pmbus_sensor *sensor;
39869 - struct device_attribute *a;
39870 + device_attribute_no_const *a;
39871
39872 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39873 if (!sensor)
39874 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39875 const char *lstring, int index)
39876 {
39877 struct pmbus_label *label;
39878 - struct device_attribute *a;
39879 + device_attribute_no_const *a;
39880
39881 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39882 if (!label)
39883 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39884 index 97cd45a..ac54d8b 100644
39885 --- a/drivers/hwmon/sht15.c
39886 +++ b/drivers/hwmon/sht15.c
39887 @@ -169,7 +169,7 @@ struct sht15_data {
39888 int supply_uv;
39889 bool supply_uv_valid;
39890 struct work_struct update_supply_work;
39891 - atomic_t interrupt_handled;
39892 + atomic_unchecked_t interrupt_handled;
39893 };
39894
39895 /**
39896 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39897 ret = gpio_direction_input(data->pdata->gpio_data);
39898 if (ret)
39899 return ret;
39900 - atomic_set(&data->interrupt_handled, 0);
39901 + atomic_set_unchecked(&data->interrupt_handled, 0);
39902
39903 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39904 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39905 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39906 /* Only relevant if the interrupt hasn't occurred. */
39907 - if (!atomic_read(&data->interrupt_handled))
39908 + if (!atomic_read_unchecked(&data->interrupt_handled))
39909 schedule_work(&data->read_work);
39910 }
39911 ret = wait_event_timeout(data->wait_queue,
39912 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39913
39914 /* First disable the interrupt */
39915 disable_irq_nosync(irq);
39916 - atomic_inc(&data->interrupt_handled);
39917 + atomic_inc_unchecked(&data->interrupt_handled);
39918 /* Then schedule a reading work struct */
39919 if (data->state != SHT15_READING_NOTHING)
39920 schedule_work(&data->read_work);
39921 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39922 * If not, then start the interrupt again - care here as could
39923 * have gone low in meantime so verify it hasn't!
39924 */
39925 - atomic_set(&data->interrupt_handled, 0);
39926 + atomic_set_unchecked(&data->interrupt_handled, 0);
39927 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39928 /* If still not occurred or another handler was scheduled */
39929 if (gpio_get_value(data->pdata->gpio_data)
39930 - || atomic_read(&data->interrupt_handled))
39931 + || atomic_read_unchecked(&data->interrupt_handled))
39932 return;
39933 }
39934
39935 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39936 index 38944e9..ae9e5ed 100644
39937 --- a/drivers/hwmon/via-cputemp.c
39938 +++ b/drivers/hwmon/via-cputemp.c
39939 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39940 return NOTIFY_OK;
39941 }
39942
39943 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39944 +static struct notifier_block via_cputemp_cpu_notifier = {
39945 .notifier_call = via_cputemp_cpu_callback,
39946 };
39947
39948 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39949 index 07f01ac..d79ad3d 100644
39950 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39951 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39952 @@ -43,7 +43,7 @@
39953 extern struct i2c_adapter amd756_smbus;
39954
39955 static struct i2c_adapter *s4882_adapter;
39956 -static struct i2c_algorithm *s4882_algo;
39957 +static i2c_algorithm_no_const *s4882_algo;
39958
39959 /* Wrapper access functions for multiplexed SMBus */
39960 static DEFINE_MUTEX(amd756_lock);
39961 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
39962 index dae3ddf..26e21d1 100644
39963 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
39964 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
39965 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
39966 /* usb layer */
39967
39968 /* Send command to device, and get response. */
39969 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
39970 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
39971 {
39972 int ret = 0;
39973 int actual;
39974 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39975 index 2ca268d..c6acbdf 100644
39976 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39977 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39978 @@ -41,7 +41,7 @@
39979 extern struct i2c_adapter *nforce2_smbus;
39980
39981 static struct i2c_adapter *s4985_adapter;
39982 -static struct i2c_algorithm *s4985_algo;
39983 +static i2c_algorithm_no_const *s4985_algo;
39984
39985 /* Wrapper access functions for multiplexed SMBus */
39986 static DEFINE_MUTEX(nforce2_lock);
39987 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39988 index c3ccdea..5b3dc1a 100644
39989 --- a/drivers/i2c/i2c-dev.c
39990 +++ b/drivers/i2c/i2c-dev.c
39991 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39992 break;
39993 }
39994
39995 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39996 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39997 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39998 if (IS_ERR(rdwr_pa[i].buf)) {
39999 res = PTR_ERR(rdwr_pa[i].buf);
40000 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40001 index 0b510ba..4fbb5085 100644
40002 --- a/drivers/ide/ide-cd.c
40003 +++ b/drivers/ide/ide-cd.c
40004 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40005 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40006 if ((unsigned long)buf & alignment
40007 || blk_rq_bytes(rq) & q->dma_pad_mask
40008 - || object_is_on_stack(buf))
40009 + || object_starts_on_stack(buf))
40010 drive->dma = 0;
40011 }
40012 }
40013 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40014 index f95c697..0a1b05c 100644
40015 --- a/drivers/iio/industrialio-core.c
40016 +++ b/drivers/iio/industrialio-core.c
40017 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40018 }
40019
40020 static
40021 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40022 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40023 const char *postfix,
40024 struct iio_chan_spec const *chan,
40025 ssize_t (*readfunc)(struct device *dev,
40026 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40027 index 784b97c..c9ceadf 100644
40028 --- a/drivers/infiniband/core/cm.c
40029 +++ b/drivers/infiniband/core/cm.c
40030 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40031
40032 struct cm_counter_group {
40033 struct kobject obj;
40034 - atomic_long_t counter[CM_ATTR_COUNT];
40035 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40036 };
40037
40038 struct cm_counter_attribute {
40039 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40040 struct ib_mad_send_buf *msg = NULL;
40041 int ret;
40042
40043 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40044 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40045 counter[CM_REQ_COUNTER]);
40046
40047 /* Quick state check to discard duplicate REQs. */
40048 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40049 if (!cm_id_priv)
40050 return;
40051
40052 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40053 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40054 counter[CM_REP_COUNTER]);
40055 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40056 if (ret)
40057 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40058 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40059 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40060 spin_unlock_irq(&cm_id_priv->lock);
40061 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40062 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40063 counter[CM_RTU_COUNTER]);
40064 goto out;
40065 }
40066 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40067 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40068 dreq_msg->local_comm_id);
40069 if (!cm_id_priv) {
40070 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40071 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40072 counter[CM_DREQ_COUNTER]);
40073 cm_issue_drep(work->port, work->mad_recv_wc);
40074 return -EINVAL;
40075 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40076 case IB_CM_MRA_REP_RCVD:
40077 break;
40078 case IB_CM_TIMEWAIT:
40079 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40080 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40081 counter[CM_DREQ_COUNTER]);
40082 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40083 goto unlock;
40084 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40085 cm_free_msg(msg);
40086 goto deref;
40087 case IB_CM_DREQ_RCVD:
40088 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40089 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40090 counter[CM_DREQ_COUNTER]);
40091 goto unlock;
40092 default:
40093 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40094 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40095 cm_id_priv->msg, timeout)) {
40096 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40097 - atomic_long_inc(&work->port->
40098 + atomic_long_inc_unchecked(&work->port->
40099 counter_group[CM_RECV_DUPLICATES].
40100 counter[CM_MRA_COUNTER]);
40101 goto out;
40102 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40103 break;
40104 case IB_CM_MRA_REQ_RCVD:
40105 case IB_CM_MRA_REP_RCVD:
40106 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40107 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40108 counter[CM_MRA_COUNTER]);
40109 /* fall through */
40110 default:
40111 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40112 case IB_CM_LAP_IDLE:
40113 break;
40114 case IB_CM_MRA_LAP_SENT:
40115 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40116 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40117 counter[CM_LAP_COUNTER]);
40118 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40119 goto unlock;
40120 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40121 cm_free_msg(msg);
40122 goto deref;
40123 case IB_CM_LAP_RCVD:
40124 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40125 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40126 counter[CM_LAP_COUNTER]);
40127 goto unlock;
40128 default:
40129 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40130 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40131 if (cur_cm_id_priv) {
40132 spin_unlock_irq(&cm.lock);
40133 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40134 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40135 counter[CM_SIDR_REQ_COUNTER]);
40136 goto out; /* Duplicate message. */
40137 }
40138 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40139 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40140 msg->retries = 1;
40141
40142 - atomic_long_add(1 + msg->retries,
40143 + atomic_long_add_unchecked(1 + msg->retries,
40144 &port->counter_group[CM_XMIT].counter[attr_index]);
40145 if (msg->retries)
40146 - atomic_long_add(msg->retries,
40147 + atomic_long_add_unchecked(msg->retries,
40148 &port->counter_group[CM_XMIT_RETRIES].
40149 counter[attr_index]);
40150
40151 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40152 }
40153
40154 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40155 - atomic_long_inc(&port->counter_group[CM_RECV].
40156 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40157 counter[attr_id - CM_ATTR_ID_OFFSET]);
40158
40159 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40160 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40161 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40162
40163 return sprintf(buf, "%ld\n",
40164 - atomic_long_read(&group->counter[cm_attr->index]));
40165 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40166 }
40167
40168 static const struct sysfs_ops cm_counter_ops = {
40169 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40170 index 9f5ad7c..588cd84 100644
40171 --- a/drivers/infiniband/core/fmr_pool.c
40172 +++ b/drivers/infiniband/core/fmr_pool.c
40173 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40174
40175 struct task_struct *thread;
40176
40177 - atomic_t req_ser;
40178 - atomic_t flush_ser;
40179 + atomic_unchecked_t req_ser;
40180 + atomic_unchecked_t flush_ser;
40181
40182 wait_queue_head_t force_wait;
40183 };
40184 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40185 struct ib_fmr_pool *pool = pool_ptr;
40186
40187 do {
40188 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40189 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40190 ib_fmr_batch_release(pool);
40191
40192 - atomic_inc(&pool->flush_ser);
40193 + atomic_inc_unchecked(&pool->flush_ser);
40194 wake_up_interruptible(&pool->force_wait);
40195
40196 if (pool->flush_function)
40197 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40198 }
40199
40200 set_current_state(TASK_INTERRUPTIBLE);
40201 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40202 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40203 !kthread_should_stop())
40204 schedule();
40205 __set_current_state(TASK_RUNNING);
40206 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40207 pool->dirty_watermark = params->dirty_watermark;
40208 pool->dirty_len = 0;
40209 spin_lock_init(&pool->pool_lock);
40210 - atomic_set(&pool->req_ser, 0);
40211 - atomic_set(&pool->flush_ser, 0);
40212 + atomic_set_unchecked(&pool->req_ser, 0);
40213 + atomic_set_unchecked(&pool->flush_ser, 0);
40214 init_waitqueue_head(&pool->force_wait);
40215
40216 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40217 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40218 }
40219 spin_unlock_irq(&pool->pool_lock);
40220
40221 - serial = atomic_inc_return(&pool->req_ser);
40222 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40223 wake_up_process(pool->thread);
40224
40225 if (wait_event_interruptible(pool->force_wait,
40226 - atomic_read(&pool->flush_ser) - serial >= 0))
40227 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40228 return -EINTR;
40229
40230 return 0;
40231 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40232 } else {
40233 list_add_tail(&fmr->list, &pool->dirty_list);
40234 if (++pool->dirty_len >= pool->dirty_watermark) {
40235 - atomic_inc(&pool->req_ser);
40236 + atomic_inc_unchecked(&pool->req_ser);
40237 wake_up_process(pool->thread);
40238 }
40239 }
40240 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40241 index 4cb8eb2..146bf60 100644
40242 --- a/drivers/infiniband/hw/cxgb4/mem.c
40243 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40244 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40245 int err;
40246 struct fw_ri_tpte tpt;
40247 u32 stag_idx;
40248 - static atomic_t key;
40249 + static atomic_unchecked_t key;
40250
40251 if (c4iw_fatal_error(rdev))
40252 return -EIO;
40253 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40254 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40255 rdev->stats.stag.max = rdev->stats.stag.cur;
40256 mutex_unlock(&rdev->stats.lock);
40257 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40258 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40259 }
40260 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40261 __func__, stag_state, type, pdid, stag_idx);
40262 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40263 index 79b3dbc..96e5fcc 100644
40264 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40265 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40266 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40267 struct ib_atomic_eth *ateth;
40268 struct ipath_ack_entry *e;
40269 u64 vaddr;
40270 - atomic64_t *maddr;
40271 + atomic64_unchecked_t *maddr;
40272 u64 sdata;
40273 u32 rkey;
40274 u8 next;
40275 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40276 IB_ACCESS_REMOTE_ATOMIC)))
40277 goto nack_acc_unlck;
40278 /* Perform atomic OP and save result. */
40279 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40280 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40281 sdata = be64_to_cpu(ateth->swap_data);
40282 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40283 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40284 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40285 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40286 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40287 be64_to_cpu(ateth->compare_data),
40288 sdata);
40289 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40290 index 1f95bba..9530f87 100644
40291 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40292 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40293 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40294 unsigned long flags;
40295 struct ib_wc wc;
40296 u64 sdata;
40297 - atomic64_t *maddr;
40298 + atomic64_unchecked_t *maddr;
40299 enum ib_wc_status send_status;
40300
40301 /*
40302 @@ -382,11 +382,11 @@ again:
40303 IB_ACCESS_REMOTE_ATOMIC)))
40304 goto acc_err;
40305 /* Perform atomic OP and save result. */
40306 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40307 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40308 sdata = wqe->wr.wr.atomic.compare_add;
40309 *(u64 *) sqp->s_sge.sge.vaddr =
40310 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40311 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40312 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40313 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40314 sdata, wqe->wr.wr.atomic.swap);
40315 goto send_comp;
40316 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40317 index f2a3f48..673ec79 100644
40318 --- a/drivers/infiniband/hw/mlx4/mad.c
40319 +++ b/drivers/infiniband/hw/mlx4/mad.c
40320 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40321
40322 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40323 {
40324 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40325 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40326 cpu_to_be64(0xff00000000000000LL);
40327 }
40328
40329 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40330 index 25b2cdf..099ff97 100644
40331 --- a/drivers/infiniband/hw/mlx4/mcg.c
40332 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40333 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40334 {
40335 char name[20];
40336
40337 - atomic_set(&ctx->tid, 0);
40338 + atomic_set_unchecked(&ctx->tid, 0);
40339 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40340 ctx->mcg_wq = create_singlethread_workqueue(name);
40341 if (!ctx->mcg_wq)
40342 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40343 index 036b663..c9a8c73 100644
40344 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40345 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40346 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
40347 struct list_head mcg_mgid0_list;
40348 struct workqueue_struct *mcg_wq;
40349 struct mlx4_ib_demux_pv_ctx **tun;
40350 - atomic_t tid;
40351 + atomic_unchecked_t tid;
40352 int flushing; /* flushing the work queue */
40353 };
40354
40355 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40356 index 9d3e5c1..6f166df 100644
40357 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40358 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40359 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40360 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40361 }
40362
40363 -int mthca_QUERY_FW(struct mthca_dev *dev)
40364 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40365 {
40366 struct mthca_mailbox *mailbox;
40367 u32 *outbox;
40368 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40369 CMD_TIME_CLASS_B);
40370 }
40371
40372 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40373 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40374 int num_mtt)
40375 {
40376 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
40377 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
40378 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
40379 }
40380
40381 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40382 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40383 int eq_num)
40384 {
40385 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
40386 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
40387 CMD_TIME_CLASS_B);
40388 }
40389
40390 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40391 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40392 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
40393 void *in_mad, void *response_mad)
40394 {
40395 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
40396 index 87897b9..7e79542 100644
40397 --- a/drivers/infiniband/hw/mthca/mthca_main.c
40398 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
40399 @@ -692,7 +692,7 @@ err_close:
40400 return err;
40401 }
40402
40403 -static int mthca_setup_hca(struct mthca_dev *dev)
40404 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
40405 {
40406 int err;
40407
40408 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40409 index ed9a989..6aa5dc2 100644
40410 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40411 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40412 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
40413 * through the bitmaps)
40414 */
40415
40416 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40417 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40418 {
40419 int o;
40420 int m;
40421 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40422 return key;
40423 }
40424
40425 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40426 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40427 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40428 {
40429 struct mthca_mailbox *mailbox;
40430 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
40431 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
40432 }
40433
40434 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40435 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40436 u64 *buffer_list, int buffer_size_shift,
40437 int list_len, u64 iova, u64 total_size,
40438 u32 access, struct mthca_mr *mr)
40439 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
40440 index 5b71d43..35a9e14 100644
40441 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
40442 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
40443 @@ -763,7 +763,7 @@ unlock:
40444 return 0;
40445 }
40446
40447 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40448 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40449 {
40450 struct mthca_dev *dev = to_mdev(ibcq->device);
40451 struct mthca_cq *cq = to_mcq(ibcq);
40452 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40453 index 4291410..d2ab1fb 100644
40454 --- a/drivers/infiniband/hw/nes/nes.c
40455 +++ b/drivers/infiniband/hw/nes/nes.c
40456 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40457 LIST_HEAD(nes_adapter_list);
40458 static LIST_HEAD(nes_dev_list);
40459
40460 -atomic_t qps_destroyed;
40461 +atomic_unchecked_t qps_destroyed;
40462
40463 static unsigned int ee_flsh_adapter;
40464 static unsigned int sysfs_nonidx_addr;
40465 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40466 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40467 struct nes_adapter *nesadapter = nesdev->nesadapter;
40468
40469 - atomic_inc(&qps_destroyed);
40470 + atomic_inc_unchecked(&qps_destroyed);
40471
40472 /* Free the control structures */
40473
40474 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40475 index 33cc589..3bd6538 100644
40476 --- a/drivers/infiniband/hw/nes/nes.h
40477 +++ b/drivers/infiniband/hw/nes/nes.h
40478 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40479 extern unsigned int wqm_quanta;
40480 extern struct list_head nes_adapter_list;
40481
40482 -extern atomic_t cm_connects;
40483 -extern atomic_t cm_accepts;
40484 -extern atomic_t cm_disconnects;
40485 -extern atomic_t cm_closes;
40486 -extern atomic_t cm_connecteds;
40487 -extern atomic_t cm_connect_reqs;
40488 -extern atomic_t cm_rejects;
40489 -extern atomic_t mod_qp_timouts;
40490 -extern atomic_t qps_created;
40491 -extern atomic_t qps_destroyed;
40492 -extern atomic_t sw_qps_destroyed;
40493 +extern atomic_unchecked_t cm_connects;
40494 +extern atomic_unchecked_t cm_accepts;
40495 +extern atomic_unchecked_t cm_disconnects;
40496 +extern atomic_unchecked_t cm_closes;
40497 +extern atomic_unchecked_t cm_connecteds;
40498 +extern atomic_unchecked_t cm_connect_reqs;
40499 +extern atomic_unchecked_t cm_rejects;
40500 +extern atomic_unchecked_t mod_qp_timouts;
40501 +extern atomic_unchecked_t qps_created;
40502 +extern atomic_unchecked_t qps_destroyed;
40503 +extern atomic_unchecked_t sw_qps_destroyed;
40504 extern u32 mh_detected;
40505 extern u32 mh_pauses_sent;
40506 extern u32 cm_packets_sent;
40507 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40508 extern u32 cm_packets_received;
40509 extern u32 cm_packets_dropped;
40510 extern u32 cm_packets_retrans;
40511 -extern atomic_t cm_listens_created;
40512 -extern atomic_t cm_listens_destroyed;
40513 +extern atomic_unchecked_t cm_listens_created;
40514 +extern atomic_unchecked_t cm_listens_destroyed;
40515 extern u32 cm_backlog_drops;
40516 -extern atomic_t cm_loopbacks;
40517 -extern atomic_t cm_nodes_created;
40518 -extern atomic_t cm_nodes_destroyed;
40519 -extern atomic_t cm_accel_dropped_pkts;
40520 -extern atomic_t cm_resets_recvd;
40521 -extern atomic_t pau_qps_created;
40522 -extern atomic_t pau_qps_destroyed;
40523 +extern atomic_unchecked_t cm_loopbacks;
40524 +extern atomic_unchecked_t cm_nodes_created;
40525 +extern atomic_unchecked_t cm_nodes_destroyed;
40526 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40527 +extern atomic_unchecked_t cm_resets_recvd;
40528 +extern atomic_unchecked_t pau_qps_created;
40529 +extern atomic_unchecked_t pau_qps_destroyed;
40530
40531 extern u32 int_mod_timer_init;
40532 extern u32 int_mod_cq_depth_256;
40533 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40534 index 6b29249..57081dd 100644
40535 --- a/drivers/infiniband/hw/nes/nes_cm.c
40536 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40537 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40538 u32 cm_packets_retrans;
40539 u32 cm_packets_created;
40540 u32 cm_packets_received;
40541 -atomic_t cm_listens_created;
40542 -atomic_t cm_listens_destroyed;
40543 +atomic_unchecked_t cm_listens_created;
40544 +atomic_unchecked_t cm_listens_destroyed;
40545 u32 cm_backlog_drops;
40546 -atomic_t cm_loopbacks;
40547 -atomic_t cm_nodes_created;
40548 -atomic_t cm_nodes_destroyed;
40549 -atomic_t cm_accel_dropped_pkts;
40550 -atomic_t cm_resets_recvd;
40551 +atomic_unchecked_t cm_loopbacks;
40552 +atomic_unchecked_t cm_nodes_created;
40553 +atomic_unchecked_t cm_nodes_destroyed;
40554 +atomic_unchecked_t cm_accel_dropped_pkts;
40555 +atomic_unchecked_t cm_resets_recvd;
40556
40557 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40558 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40559 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40560
40561 static struct nes_cm_core *g_cm_core;
40562
40563 -atomic_t cm_connects;
40564 -atomic_t cm_accepts;
40565 -atomic_t cm_disconnects;
40566 -atomic_t cm_closes;
40567 -atomic_t cm_connecteds;
40568 -atomic_t cm_connect_reqs;
40569 -atomic_t cm_rejects;
40570 +atomic_unchecked_t cm_connects;
40571 +atomic_unchecked_t cm_accepts;
40572 +atomic_unchecked_t cm_disconnects;
40573 +atomic_unchecked_t cm_closes;
40574 +atomic_unchecked_t cm_connecteds;
40575 +atomic_unchecked_t cm_connect_reqs;
40576 +atomic_unchecked_t cm_rejects;
40577
40578 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40579 {
40580 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40581 kfree(listener);
40582 listener = NULL;
40583 ret = 0;
40584 - atomic_inc(&cm_listens_destroyed);
40585 + atomic_inc_unchecked(&cm_listens_destroyed);
40586 } else {
40587 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40588 }
40589 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40590 cm_node->rem_mac);
40591
40592 add_hte_node(cm_core, cm_node);
40593 - atomic_inc(&cm_nodes_created);
40594 + atomic_inc_unchecked(&cm_nodes_created);
40595
40596 return cm_node;
40597 }
40598 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40599 }
40600
40601 atomic_dec(&cm_core->node_cnt);
40602 - atomic_inc(&cm_nodes_destroyed);
40603 + atomic_inc_unchecked(&cm_nodes_destroyed);
40604 nesqp = cm_node->nesqp;
40605 if (nesqp) {
40606 nesqp->cm_node = NULL;
40607 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40608
40609 static void drop_packet(struct sk_buff *skb)
40610 {
40611 - atomic_inc(&cm_accel_dropped_pkts);
40612 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40613 dev_kfree_skb_any(skb);
40614 }
40615
40616 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40617 {
40618
40619 int reset = 0; /* whether to send reset in case of err.. */
40620 - atomic_inc(&cm_resets_recvd);
40621 + atomic_inc_unchecked(&cm_resets_recvd);
40622 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40623 " refcnt=%d\n", cm_node, cm_node->state,
40624 atomic_read(&cm_node->ref_count));
40625 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40626 rem_ref_cm_node(cm_node->cm_core, cm_node);
40627 return NULL;
40628 }
40629 - atomic_inc(&cm_loopbacks);
40630 + atomic_inc_unchecked(&cm_loopbacks);
40631 loopbackremotenode->loopbackpartner = cm_node;
40632 loopbackremotenode->tcp_cntxt.rcv_wscale =
40633 NES_CM_DEFAULT_RCV_WND_SCALE;
40634 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40635 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40636 else {
40637 rem_ref_cm_node(cm_core, cm_node);
40638 - atomic_inc(&cm_accel_dropped_pkts);
40639 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40640 dev_kfree_skb_any(skb);
40641 }
40642 break;
40643 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40644
40645 if ((cm_id) && (cm_id->event_handler)) {
40646 if (issue_disconn) {
40647 - atomic_inc(&cm_disconnects);
40648 + atomic_inc_unchecked(&cm_disconnects);
40649 cm_event.event = IW_CM_EVENT_DISCONNECT;
40650 cm_event.status = disconn_status;
40651 cm_event.local_addr = cm_id->local_addr;
40652 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40653 }
40654
40655 if (issue_close) {
40656 - atomic_inc(&cm_closes);
40657 + atomic_inc_unchecked(&cm_closes);
40658 nes_disconnect(nesqp, 1);
40659
40660 cm_id->provider_data = nesqp;
40661 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40662
40663 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40664 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40665 - atomic_inc(&cm_accepts);
40666 + atomic_inc_unchecked(&cm_accepts);
40667
40668 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40669 netdev_refcnt_read(nesvnic->netdev));
40670 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40671 struct nes_cm_core *cm_core;
40672 u8 *start_buff;
40673
40674 - atomic_inc(&cm_rejects);
40675 + atomic_inc_unchecked(&cm_rejects);
40676 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40677 loopback = cm_node->loopbackpartner;
40678 cm_core = cm_node->cm_core;
40679 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40680 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
40681 ntohs(laddr->sin_port));
40682
40683 - atomic_inc(&cm_connects);
40684 + atomic_inc_unchecked(&cm_connects);
40685 nesqp->active_conn = 1;
40686
40687 /* cache the cm_id in the qp */
40688 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40689 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40690 return err;
40691 }
40692 - atomic_inc(&cm_listens_created);
40693 + atomic_inc_unchecked(&cm_listens_created);
40694 }
40695
40696 cm_id->add_ref(cm_id);
40697 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40698
40699 if (nesqp->destroyed)
40700 return;
40701 - atomic_inc(&cm_connecteds);
40702 + atomic_inc_unchecked(&cm_connecteds);
40703 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40704 " local port 0x%04X. jiffies = %lu.\n",
40705 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
40706 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40707
40708 cm_id->add_ref(cm_id);
40709 ret = cm_id->event_handler(cm_id, &cm_event);
40710 - atomic_inc(&cm_closes);
40711 + atomic_inc_unchecked(&cm_closes);
40712 cm_event.event = IW_CM_EVENT_CLOSE;
40713 cm_event.status = 0;
40714 cm_event.provider_data = cm_id->provider_data;
40715 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40716 return;
40717 cm_id = cm_node->cm_id;
40718
40719 - atomic_inc(&cm_connect_reqs);
40720 + atomic_inc_unchecked(&cm_connect_reqs);
40721 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40722 cm_node, cm_id, jiffies);
40723
40724 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40725 return;
40726 cm_id = cm_node->cm_id;
40727
40728 - atomic_inc(&cm_connect_reqs);
40729 + atomic_inc_unchecked(&cm_connect_reqs);
40730 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40731 cm_node, cm_id, jiffies);
40732
40733 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40734 index 4166452..fc952c3 100644
40735 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40736 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40737 @@ -40,8 +40,8 @@
40738 #include "nes.h"
40739 #include "nes_mgt.h"
40740
40741 -atomic_t pau_qps_created;
40742 -atomic_t pau_qps_destroyed;
40743 +atomic_unchecked_t pau_qps_created;
40744 +atomic_unchecked_t pau_qps_destroyed;
40745
40746 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40747 {
40748 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40749 {
40750 struct sk_buff *skb;
40751 unsigned long flags;
40752 - atomic_inc(&pau_qps_destroyed);
40753 + atomic_inc_unchecked(&pau_qps_destroyed);
40754
40755 /* Free packets that have not yet been forwarded */
40756 /* Lock is acquired by skb_dequeue when removing the skb */
40757 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40758 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40759 skb_queue_head_init(&nesqp->pau_list);
40760 spin_lock_init(&nesqp->pau_lock);
40761 - atomic_inc(&pau_qps_created);
40762 + atomic_inc_unchecked(&pau_qps_created);
40763 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40764 }
40765
40766 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40767 index 49eb511..a774366 100644
40768 --- a/drivers/infiniband/hw/nes/nes_nic.c
40769 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40770 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40771 target_stat_values[++index] = mh_detected;
40772 target_stat_values[++index] = mh_pauses_sent;
40773 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40774 - target_stat_values[++index] = atomic_read(&cm_connects);
40775 - target_stat_values[++index] = atomic_read(&cm_accepts);
40776 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40777 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40778 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40779 - target_stat_values[++index] = atomic_read(&cm_rejects);
40780 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40781 - target_stat_values[++index] = atomic_read(&qps_created);
40782 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40783 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40784 - target_stat_values[++index] = atomic_read(&cm_closes);
40785 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40786 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40787 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40788 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40789 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40790 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40791 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40792 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40793 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40794 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40795 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40796 target_stat_values[++index] = cm_packets_sent;
40797 target_stat_values[++index] = cm_packets_bounced;
40798 target_stat_values[++index] = cm_packets_created;
40799 target_stat_values[++index] = cm_packets_received;
40800 target_stat_values[++index] = cm_packets_dropped;
40801 target_stat_values[++index] = cm_packets_retrans;
40802 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40803 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40804 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40805 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40806 target_stat_values[++index] = cm_backlog_drops;
40807 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40808 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40809 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40810 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40811 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40812 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40813 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40814 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40815 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40816 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40817 target_stat_values[++index] = nesadapter->free_4kpbl;
40818 target_stat_values[++index] = nesadapter->free_256pbl;
40819 target_stat_values[++index] = int_mod_timer_init;
40820 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40821 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40822 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40823 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40824 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40825 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40826 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40827 }
40828
40829 /**
40830 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40831 index 5b53ca5..443da3c 100644
40832 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40833 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40834 @@ -46,9 +46,9 @@
40835
40836 #include <rdma/ib_umem.h>
40837
40838 -atomic_t mod_qp_timouts;
40839 -atomic_t qps_created;
40840 -atomic_t sw_qps_destroyed;
40841 +atomic_unchecked_t mod_qp_timouts;
40842 +atomic_unchecked_t qps_created;
40843 +atomic_unchecked_t sw_qps_destroyed;
40844
40845 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40846
40847 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40848 if (init_attr->create_flags)
40849 return ERR_PTR(-EINVAL);
40850
40851 - atomic_inc(&qps_created);
40852 + atomic_inc_unchecked(&qps_created);
40853 switch (init_attr->qp_type) {
40854 case IB_QPT_RC:
40855 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40856 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40857 struct iw_cm_event cm_event;
40858 int ret = 0;
40859
40860 - atomic_inc(&sw_qps_destroyed);
40861 + atomic_inc_unchecked(&sw_qps_destroyed);
40862 nesqp->destroyed = 1;
40863
40864 /* Blow away the connection if it exists. */
40865 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40866 index 1946101..09766d2 100644
40867 --- a/drivers/infiniband/hw/qib/qib.h
40868 +++ b/drivers/infiniband/hw/qib/qib.h
40869 @@ -52,6 +52,7 @@
40870 #include <linux/kref.h>
40871 #include <linux/sched.h>
40872 #include <linux/kthread.h>
40873 +#include <linux/slab.h>
40874
40875 #include "qib_common.h"
40876 #include "qib_verbs.h"
40877 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40878 index 922a7fe..bb035db 100644
40879 --- a/drivers/input/gameport/gameport.c
40880 +++ b/drivers/input/gameport/gameport.c
40881 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40882 */
40883 static void gameport_init_port(struct gameport *gameport)
40884 {
40885 - static atomic_t gameport_no = ATOMIC_INIT(0);
40886 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40887
40888 __module_get(THIS_MODULE);
40889
40890 mutex_init(&gameport->drv_mutex);
40891 device_initialize(&gameport->dev);
40892 dev_set_name(&gameport->dev, "gameport%lu",
40893 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40894 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40895 gameport->dev.bus = &gameport_bus;
40896 gameport->dev.release = gameport_release_port;
40897 if (gameport->parent)
40898 diff --git a/drivers/input/input.c b/drivers/input/input.c
40899 index e75d015..57d1c28 100644
40900 --- a/drivers/input/input.c
40901 +++ b/drivers/input/input.c
40902 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
40903 */
40904 struct input_dev *input_allocate_device(void)
40905 {
40906 - static atomic_t input_no = ATOMIC_INIT(0);
40907 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40908 struct input_dev *dev;
40909
40910 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
40911 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
40912 INIT_LIST_HEAD(&dev->node);
40913
40914 dev_set_name(&dev->dev, "input%ld",
40915 - (unsigned long) atomic_inc_return(&input_no) - 1);
40916 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40917
40918 __module_get(THIS_MODULE);
40919 }
40920 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40921 index 04c69af..5f92d00 100644
40922 --- a/drivers/input/joystick/sidewinder.c
40923 +++ b/drivers/input/joystick/sidewinder.c
40924 @@ -30,6 +30,7 @@
40925 #include <linux/kernel.h>
40926 #include <linux/module.h>
40927 #include <linux/slab.h>
40928 +#include <linux/sched.h>
40929 #include <linux/init.h>
40930 #include <linux/input.h>
40931 #include <linux/gameport.h>
40932 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40933 index 75e3b10..fb390fd 100644
40934 --- a/drivers/input/joystick/xpad.c
40935 +++ b/drivers/input/joystick/xpad.c
40936 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40937
40938 static int xpad_led_probe(struct usb_xpad *xpad)
40939 {
40940 - static atomic_t led_seq = ATOMIC_INIT(0);
40941 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40942 long led_no;
40943 struct xpad_led *led;
40944 struct led_classdev *led_cdev;
40945 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40946 if (!led)
40947 return -ENOMEM;
40948
40949 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40950 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40951
40952 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40953 led->xpad = xpad;
40954 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40955 index e204f26..8459f15 100644
40956 --- a/drivers/input/misc/ims-pcu.c
40957 +++ b/drivers/input/misc/ims-pcu.c
40958 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40959
40960 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40961 {
40962 - static atomic_t device_no = ATOMIC_INIT(0);
40963 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40964
40965 const struct ims_pcu_device_info *info;
40966 u8 device_id;
40967 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40968 }
40969
40970 /* Device appears to be operable, complete initialization */
40971 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40972 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40973
40974 error = ims_pcu_setup_backlight(pcu);
40975 if (error)
40976 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40977 index 2f0b39d..7370f13 100644
40978 --- a/drivers/input/mouse/psmouse.h
40979 +++ b/drivers/input/mouse/psmouse.h
40980 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40981 ssize_t (*set)(struct psmouse *psmouse, void *data,
40982 const char *buf, size_t count);
40983 bool protect;
40984 -};
40985 +} __do_const;
40986 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40987
40988 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40989 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40990 index 4c842c3..590b0bf 100644
40991 --- a/drivers/input/mousedev.c
40992 +++ b/drivers/input/mousedev.c
40993 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40994
40995 spin_unlock_irq(&client->packet_lock);
40996
40997 - if (copy_to_user(buffer, data, count))
40998 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40999 return -EFAULT;
41000
41001 return count;
41002 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41003 index 2b56855..5a55837 100644
41004 --- a/drivers/input/serio/serio.c
41005 +++ b/drivers/input/serio/serio.c
41006 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41007 */
41008 static void serio_init_port(struct serio *serio)
41009 {
41010 - static atomic_t serio_no = ATOMIC_INIT(0);
41011 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41012
41013 __module_get(THIS_MODULE);
41014
41015 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41016 mutex_init(&serio->drv_mutex);
41017 device_initialize(&serio->dev);
41018 dev_set_name(&serio->dev, "serio%ld",
41019 - (long)atomic_inc_return(&serio_no) - 1);
41020 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41021 serio->dev.bus = &serio_bus;
41022 serio->dev.release = serio_release_port;
41023 serio->dev.groups = serio_device_attr_groups;
41024 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41025 index 59df2e7..8f1cafb 100644
41026 --- a/drivers/input/serio/serio_raw.c
41027 +++ b/drivers/input/serio/serio_raw.c
41028 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41029
41030 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41031 {
41032 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41033 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41034 struct serio_raw *serio_raw;
41035 int err;
41036
41037 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41038 }
41039
41040 snprintf(serio_raw->name, sizeof(serio_raw->name),
41041 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41042 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41043 kref_init(&serio_raw->kref);
41044 INIT_LIST_HEAD(&serio_raw->client_list);
41045 init_waitqueue_head(&serio_raw->wait);
41046 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41047 index fbe9ca7..dbee61d 100644
41048 --- a/drivers/iommu/iommu.c
41049 +++ b/drivers/iommu/iommu.c
41050 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41051 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41052 {
41053 bus_register_notifier(bus, &iommu_bus_nb);
41054 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41055 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41056 }
41057
41058 /**
41059 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41060 index 39f81ae..2660096 100644
41061 --- a/drivers/iommu/irq_remapping.c
41062 +++ b/drivers/iommu/irq_remapping.c
41063 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41064 void panic_if_irq_remap(const char *msg)
41065 {
41066 if (irq_remapping_enabled)
41067 - panic(msg);
41068 + panic("%s", msg);
41069 }
41070
41071 static void ir_ack_apic_edge(struct irq_data *data)
41072 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41073
41074 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41075 {
41076 - chip->irq_print_chip = ir_print_prefix;
41077 - chip->irq_ack = ir_ack_apic_edge;
41078 - chip->irq_eoi = ir_ack_apic_level;
41079 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41080 + pax_open_kernel();
41081 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41082 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41083 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41084 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41085 + pax_close_kernel();
41086 }
41087
41088 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41089 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41090 index d0e9480..d2b6340 100644
41091 --- a/drivers/irqchip/irq-gic.c
41092 +++ b/drivers/irqchip/irq-gic.c
41093 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41094 * Supported arch specific GIC irq extension.
41095 * Default make them NULL.
41096 */
41097 -struct irq_chip gic_arch_extn = {
41098 +irq_chip_no_const gic_arch_extn = {
41099 .irq_eoi = NULL,
41100 .irq_mask = NULL,
41101 .irq_unmask = NULL,
41102 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41103 chained_irq_exit(chip, desc);
41104 }
41105
41106 -static struct irq_chip gic_chip = {
41107 +static irq_chip_no_const gic_chip __read_only = {
41108 .name = "GIC",
41109 .irq_mask = gic_mask_irq,
41110 .irq_unmask = gic_unmask_irq,
41111 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41112 index ac6f72b..81150f2 100644
41113 --- a/drivers/isdn/capi/capi.c
41114 +++ b/drivers/isdn/capi/capi.c
41115 @@ -81,8 +81,8 @@ struct capiminor {
41116
41117 struct capi20_appl *ap;
41118 u32 ncci;
41119 - atomic_t datahandle;
41120 - atomic_t msgid;
41121 + atomic_unchecked_t datahandle;
41122 + atomic_unchecked_t msgid;
41123
41124 struct tty_port port;
41125 int ttyinstop;
41126 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41127 capimsg_setu16(s, 2, mp->ap->applid);
41128 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41129 capimsg_setu8 (s, 5, CAPI_RESP);
41130 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41131 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41132 capimsg_setu32(s, 8, mp->ncci);
41133 capimsg_setu16(s, 12, datahandle);
41134 }
41135 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41136 mp->outbytes -= len;
41137 spin_unlock_bh(&mp->outlock);
41138
41139 - datahandle = atomic_inc_return(&mp->datahandle);
41140 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41141 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41142 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41143 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41144 capimsg_setu16(skb->data, 2, mp->ap->applid);
41145 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41146 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41147 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41148 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41149 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41150 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41151 capimsg_setu16(skb->data, 16, len); /* Data length */
41152 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41153 index 600c79b..3752bab 100644
41154 --- a/drivers/isdn/gigaset/interface.c
41155 +++ b/drivers/isdn/gigaset/interface.c
41156 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41157 }
41158 tty->driver_data = cs;
41159
41160 - ++cs->port.count;
41161 + atomic_inc(&cs->port.count);
41162
41163 - if (cs->port.count == 1) {
41164 + if (atomic_read(&cs->port.count) == 1) {
41165 tty_port_tty_set(&cs->port, tty);
41166 cs->port.low_latency = 1;
41167 }
41168 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41169
41170 if (!cs->connected)
41171 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41172 - else if (!cs->port.count)
41173 + else if (!atomic_read(&cs->port.count))
41174 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41175 - else if (!--cs->port.count)
41176 + else if (!atomic_dec_return(&cs->port.count))
41177 tty_port_tty_set(&cs->port, NULL);
41178
41179 mutex_unlock(&cs->mutex);
41180 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41181 index d0a41cb..f0cdb8c 100644
41182 --- a/drivers/isdn/gigaset/usb-gigaset.c
41183 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41184 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41185 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41186 memcpy(cs->hw.usb->bchars, buf, 6);
41187 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41188 - 0, 0, &buf, 6, 2000);
41189 + 0, 0, buf, 6, 2000);
41190 }
41191
41192 static void gigaset_freebcshw(struct bc_state *bcs)
41193 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41194 index 4d9b195..455075c 100644
41195 --- a/drivers/isdn/hardware/avm/b1.c
41196 +++ b/drivers/isdn/hardware/avm/b1.c
41197 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41198 }
41199 if (left) {
41200 if (t4file->user) {
41201 - if (copy_from_user(buf, dp, left))
41202 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41203 return -EFAULT;
41204 } else {
41205 memcpy(buf, dp, left);
41206 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41207 }
41208 if (left) {
41209 if (config->user) {
41210 - if (copy_from_user(buf, dp, left))
41211 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41212 return -EFAULT;
41213 } else {
41214 memcpy(buf, dp, left);
41215 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41216 index 9bb12ba..d4262f7 100644
41217 --- a/drivers/isdn/i4l/isdn_common.c
41218 +++ b/drivers/isdn/i4l/isdn_common.c
41219 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41220 } else
41221 return -EINVAL;
41222 case IIOCDBGVAR:
41223 + if (!capable(CAP_SYS_RAWIO))
41224 + return -EPERM;
41225 if (arg) {
41226 if (copy_to_user(argp, &dev, sizeof(ulong)))
41227 return -EFAULT;
41228 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41229 index 3c5f249..5fac4d0 100644
41230 --- a/drivers/isdn/i4l/isdn_tty.c
41231 +++ b/drivers/isdn/i4l/isdn_tty.c
41232 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41233
41234 #ifdef ISDN_DEBUG_MODEM_OPEN
41235 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41236 - port->count);
41237 + atomic_read(&port->count));
41238 #endif
41239 - port->count++;
41240 + atomic_inc(&port->count);
41241 port->tty = tty;
41242 /*
41243 * Start up serial port
41244 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41245 #endif
41246 return;
41247 }
41248 - if ((tty->count == 1) && (port->count != 1)) {
41249 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41250 /*
41251 * Uh, oh. tty->count is 1, which means that the tty
41252 * structure will be freed. Info->count should always
41253 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41254 * serial port won't be shutdown.
41255 */
41256 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41257 - "info->count is %d\n", port->count);
41258 - port->count = 1;
41259 + "info->count is %d\n", atomic_read(&port->count));
41260 + atomic_set(&port->count, 1);
41261 }
41262 - if (--port->count < 0) {
41263 + if (atomic_dec_return(&port->count) < 0) {
41264 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41265 - info->line, port->count);
41266 - port->count = 0;
41267 + info->line, atomic_read(&port->count));
41268 + atomic_set(&port->count, 0);
41269 }
41270 - if (port->count) {
41271 + if (atomic_read(&port->count)) {
41272 #ifdef ISDN_DEBUG_MODEM_OPEN
41273 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41274 #endif
41275 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41276 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41277 return;
41278 isdn_tty_shutdown(info);
41279 - port->count = 0;
41280 + atomic_set(&port->count, 0);
41281 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41282 port->tty = NULL;
41283 wake_up_interruptible(&port->open_wait);
41284 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41285 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41286 modem_info *info = &dev->mdm.info[i];
41287
41288 - if (info->port.count == 0)
41289 + if (atomic_read(&info->port.count) == 0)
41290 continue;
41291 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41292 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41293 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41294 index e74df7c..03a03ba 100644
41295 --- a/drivers/isdn/icn/icn.c
41296 +++ b/drivers/isdn/icn/icn.c
41297 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41298 if (count > len)
41299 count = len;
41300 if (user) {
41301 - if (copy_from_user(msg, buf, count))
41302 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41303 return -EFAULT;
41304 } else
41305 memcpy(msg, buf, count);
41306 diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
41307 index baf2686..02125e6 100644
41308 --- a/drivers/isdn/isdnloop/isdnloop.c
41309 +++ b/drivers/isdn/isdnloop/isdnloop.c
41310 @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41311 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41312 return -ENOMEM;
41313 }
41314 - for (i = 0; i < 3; i++)
41315 - strcpy(card->s0num[i], sdef.num[i]);
41316 + for (i = 0; i < 3; i++) {
41317 + strlcpy(card->s0num[i], sdef.num[i],
41318 + sizeof(card->s0num[0]));
41319 + }
41320 break;
41321 case ISDN_PTYPE_1TR6:
41322 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
41323 @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41324 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41325 return -ENOMEM;
41326 }
41327 - strcpy(card->s0num[0], sdef.num[0]);
41328 + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
41329 card->s0num[1][0] = '\0';
41330 card->s0num[2][0] = '\0';
41331 break;
41332 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
41333 index a4f05c5..1433bc5 100644
41334 --- a/drivers/isdn/mISDN/dsp_cmx.c
41335 +++ b/drivers/isdn/mISDN/dsp_cmx.c
41336 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
41337 static u16 dsp_count; /* last sample count */
41338 static int dsp_count_valid; /* if we have last sample count */
41339
41340 -void
41341 +void __intentional_overflow(-1)
41342 dsp_cmx_send(void *arg)
41343 {
41344 struct dsp_conf *conf;
41345 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41346 index d93e245..e7ece6b 100644
41347 --- a/drivers/leds/leds-clevo-mail.c
41348 +++ b/drivers/leds/leds-clevo-mail.c
41349 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41350 * detected as working, but in reality it is not) as low as
41351 * possible.
41352 */
41353 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
41354 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
41355 {
41356 .callback = clevo_mail_led_dmi_callback,
41357 .ident = "Clevo D410J",
41358 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41359 index 5b8f938..b73d657 100644
41360 --- a/drivers/leds/leds-ss4200.c
41361 +++ b/drivers/leds/leds-ss4200.c
41362 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41363 * detected as working, but in reality it is not) as low as
41364 * possible.
41365 */
41366 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
41367 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
41368 {
41369 .callback = ss4200_led_dmi_callback,
41370 .ident = "Intel SS4200-E",
41371 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41372 index 0bf1e4e..b4bf44e 100644
41373 --- a/drivers/lguest/core.c
41374 +++ b/drivers/lguest/core.c
41375 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41376 * The end address needs +1 because __get_vm_area allocates an
41377 * extra guard page, so we need space for that.
41378 */
41379 +
41380 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41381 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41382 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41383 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41384 +#else
41385 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41386 VM_ALLOC, switcher_addr, switcher_addr
41387 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41388 +#endif
41389 +
41390 if (!switcher_vma) {
41391 err = -ENOMEM;
41392 printk("lguest: could not map switcher pages high\n");
41393 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41394 * Now the Switcher is mapped at the right address, we can't fail!
41395 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41396 */
41397 - memcpy(switcher_vma->addr, start_switcher_text,
41398 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41399 end_switcher_text - start_switcher_text);
41400
41401 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41402 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41403 index bfb39bb..08a603b 100644
41404 --- a/drivers/lguest/page_tables.c
41405 +++ b/drivers/lguest/page_tables.c
41406 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41407 /*:*/
41408
41409 #ifdef CONFIG_X86_PAE
41410 -static void release_pmd(pmd_t *spmd)
41411 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41412 {
41413 /* If the entry's not present, there's nothing to release. */
41414 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41415 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41416 index 5169239..47cb4db 100644
41417 --- a/drivers/lguest/x86/core.c
41418 +++ b/drivers/lguest/x86/core.c
41419 @@ -59,7 +59,7 @@ static struct {
41420 /* Offset from where switcher.S was compiled to where we've copied it */
41421 static unsigned long switcher_offset(void)
41422 {
41423 - return switcher_addr - (unsigned long)start_switcher_text;
41424 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41425 }
41426
41427 /* This cpu's struct lguest_pages (after the Switcher text page) */
41428 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41429 * These copies are pretty cheap, so we do them unconditionally: */
41430 /* Save the current Host top-level page directory.
41431 */
41432 +
41433 +#ifdef CONFIG_PAX_PER_CPU_PGD
41434 + pages->state.host_cr3 = read_cr3();
41435 +#else
41436 pages->state.host_cr3 = __pa(current->mm->pgd);
41437 +#endif
41438 +
41439 /*
41440 * Set up the Guest's page tables to see this CPU's pages (and no
41441 * other CPU's pages).
41442 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41443 * compiled-in switcher code and the high-mapped copy we just made.
41444 */
41445 for (i = 0; i < IDT_ENTRIES; i++)
41446 - default_idt_entries[i] += switcher_offset();
41447 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41448
41449 /*
41450 * Set up the Switcher's per-cpu areas.
41451 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41452 * it will be undisturbed when we switch. To change %cs and jump we
41453 * need this structure to feed to Intel's "lcall" instruction.
41454 */
41455 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41456 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41457 lguest_entry.segment = LGUEST_CS;
41458
41459 /*
41460 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41461 index 40634b0..4f5855e 100644
41462 --- a/drivers/lguest/x86/switcher_32.S
41463 +++ b/drivers/lguest/x86/switcher_32.S
41464 @@ -87,6 +87,7 @@
41465 #include <asm/page.h>
41466 #include <asm/segment.h>
41467 #include <asm/lguest.h>
41468 +#include <asm/processor-flags.h>
41469
41470 // We mark the start of the code to copy
41471 // It's placed in .text tho it's never run here
41472 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41473 // Changes type when we load it: damn Intel!
41474 // For after we switch over our page tables
41475 // That entry will be read-only: we'd crash.
41476 +
41477 +#ifdef CONFIG_PAX_KERNEXEC
41478 + mov %cr0, %edx
41479 + xor $X86_CR0_WP, %edx
41480 + mov %edx, %cr0
41481 +#endif
41482 +
41483 movl $(GDT_ENTRY_TSS*8), %edx
41484 ltr %dx
41485
41486 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41487 // Let's clear it again for our return.
41488 // The GDT descriptor of the Host
41489 // Points to the table after two "size" bytes
41490 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41491 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41492 // Clear "used" from type field (byte 5, bit 2)
41493 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41494 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41495 +
41496 +#ifdef CONFIG_PAX_KERNEXEC
41497 + mov %cr0, %eax
41498 + xor $X86_CR0_WP, %eax
41499 + mov %eax, %cr0
41500 +#endif
41501
41502 // Once our page table's switched, the Guest is live!
41503 // The Host fades as we run this final step.
41504 @@ -295,13 +309,12 @@ deliver_to_host:
41505 // I consulted gcc, and it gave
41506 // These instructions, which I gladly credit:
41507 leal (%edx,%ebx,8), %eax
41508 - movzwl (%eax),%edx
41509 - movl 4(%eax), %eax
41510 - xorw %ax, %ax
41511 - orl %eax, %edx
41512 + movl 4(%eax), %edx
41513 + movw (%eax), %dx
41514 // Now the address of the handler's in %edx
41515 // We call it now: its "iret" drops us home.
41516 - jmp *%edx
41517 + ljmp $__KERNEL_CS, $1f
41518 +1: jmp *%edx
41519
41520 // Every interrupt can come to us here
41521 // But we must truly tell each apart.
41522 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41523 index 0003992..854bbce 100644
41524 --- a/drivers/md/bcache/closure.h
41525 +++ b/drivers/md/bcache/closure.h
41526 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41527 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41528 struct workqueue_struct *wq)
41529 {
41530 - BUG_ON(object_is_on_stack(cl));
41531 + BUG_ON(object_starts_on_stack(cl));
41532 closure_set_ip(cl);
41533 cl->fn = fn;
41534 cl->wq = wq;
41535 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41536 index 547c4c5..5be1de4 100644
41537 --- a/drivers/md/bcache/super.c
41538 +++ b/drivers/md/bcache/super.c
41539 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41540 err:
41541 closure_sync(&op.cl);
41542 /* XXX: test this, it's broken */
41543 - bch_cache_set_error(c, err);
41544 + bch_cache_set_error(c, "%s", err);
41545 }
41546
41547 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41548 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41549 index a7fd821..9dcf6c3 100644
41550 --- a/drivers/md/bitmap.c
41551 +++ b/drivers/md/bitmap.c
41552 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41553 chunk_kb ? "KB" : "B");
41554 if (bitmap->storage.file) {
41555 seq_printf(seq, ", file: ");
41556 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41557 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41558 }
41559
41560 seq_printf(seq, "\n");
41561 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41562 index afe0814..8cf3794 100644
41563 --- a/drivers/md/dm-ioctl.c
41564 +++ b/drivers/md/dm-ioctl.c
41565 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41566 cmd == DM_LIST_VERSIONS_CMD)
41567 return 0;
41568
41569 - if ((cmd == DM_DEV_CREATE_CMD)) {
41570 + if (cmd == DM_DEV_CREATE_CMD) {
41571 if (!*param->name) {
41572 DMWARN("name not supplied when creating device");
41573 return -EINVAL;
41574 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41575 index 9584443..9fc9ac9 100644
41576 --- a/drivers/md/dm-raid1.c
41577 +++ b/drivers/md/dm-raid1.c
41578 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41579
41580 struct mirror {
41581 struct mirror_set *ms;
41582 - atomic_t error_count;
41583 + atomic_unchecked_t error_count;
41584 unsigned long error_type;
41585 struct dm_dev *dev;
41586 sector_t offset;
41587 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41588 struct mirror *m;
41589
41590 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41591 - if (!atomic_read(&m->error_count))
41592 + if (!atomic_read_unchecked(&m->error_count))
41593 return m;
41594
41595 return NULL;
41596 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41597 * simple way to tell if a device has encountered
41598 * errors.
41599 */
41600 - atomic_inc(&m->error_count);
41601 + atomic_inc_unchecked(&m->error_count);
41602
41603 if (test_and_set_bit(error_type, &m->error_type))
41604 return;
41605 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41606 struct mirror *m = get_default_mirror(ms);
41607
41608 do {
41609 - if (likely(!atomic_read(&m->error_count)))
41610 + if (likely(!atomic_read_unchecked(&m->error_count)))
41611 return m;
41612
41613 if (m-- == ms->mirror)
41614 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41615 {
41616 struct mirror *default_mirror = get_default_mirror(m->ms);
41617
41618 - return !atomic_read(&default_mirror->error_count);
41619 + return !atomic_read_unchecked(&default_mirror->error_count);
41620 }
41621
41622 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41623 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41624 */
41625 if (likely(region_in_sync(ms, region, 1)))
41626 m = choose_mirror(ms, bio->bi_sector);
41627 - else if (m && atomic_read(&m->error_count))
41628 + else if (m && atomic_read_unchecked(&m->error_count))
41629 m = NULL;
41630
41631 if (likely(m))
41632 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
41633 }
41634
41635 ms->mirror[mirror].ms = ms;
41636 - atomic_set(&(ms->mirror[mirror].error_count), 0);
41637 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
41638 ms->mirror[mirror].error_type = 0;
41639 ms->mirror[mirror].offset = offset;
41640
41641 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
41642 */
41643 static char device_status_char(struct mirror *m)
41644 {
41645 - if (!atomic_read(&(m->error_count)))
41646 + if (!atomic_read_unchecked(&(m->error_count)))
41647 return 'A';
41648
41649 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
41650 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
41651 index 3d404c1..b62af0e 100644
41652 --- a/drivers/md/dm-stats.c
41653 +++ b/drivers/md/dm-stats.c
41654 @@ -382,7 +382,7 @@ do_sync_free:
41655 synchronize_rcu_expedited();
41656 dm_stat_free(&s->rcu_head);
41657 } else {
41658 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
41659 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
41660 call_rcu(&s->rcu_head, dm_stat_free);
41661 }
41662 return 0;
41663 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
41664 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
41665 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
41666 ));
41667 - ACCESS_ONCE(last->last_sector) = end_sector;
41668 - ACCESS_ONCE(last->last_rw) = bi_rw;
41669 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
41670 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
41671 }
41672
41673 rcu_read_lock();
41674 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
41675 index 73c1712..7347292 100644
41676 --- a/drivers/md/dm-stripe.c
41677 +++ b/drivers/md/dm-stripe.c
41678 @@ -21,7 +21,7 @@ struct stripe {
41679 struct dm_dev *dev;
41680 sector_t physical_start;
41681
41682 - atomic_t error_count;
41683 + atomic_unchecked_t error_count;
41684 };
41685
41686 struct stripe_c {
41687 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
41688 kfree(sc);
41689 return r;
41690 }
41691 - atomic_set(&(sc->stripe[i].error_count), 0);
41692 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
41693 }
41694
41695 ti->private = sc;
41696 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
41697 DMEMIT("%d ", sc->stripes);
41698 for (i = 0; i < sc->stripes; i++) {
41699 DMEMIT("%s ", sc->stripe[i].dev->name);
41700 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
41701 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
41702 'D' : 'A';
41703 }
41704 buffer[i] = '\0';
41705 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
41706 */
41707 for (i = 0; i < sc->stripes; i++)
41708 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
41709 - atomic_inc(&(sc->stripe[i].error_count));
41710 - if (atomic_read(&(sc->stripe[i].error_count)) <
41711 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
41712 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
41713 DM_IO_ERROR_THRESHOLD)
41714 schedule_work(&sc->trigger_event);
41715 }
41716 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
41717 index 8f87835..531854d 100644
41718 --- a/drivers/md/dm-table.c
41719 +++ b/drivers/md/dm-table.c
41720 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
41721 static int open_dev(struct dm_dev_internal *d, dev_t dev,
41722 struct mapped_device *md)
41723 {
41724 - static char *_claim_ptr = "I belong to device-mapper";
41725 + static char _claim_ptr[] = "I belong to device-mapper";
41726 struct block_device *bdev;
41727
41728 int r;
41729 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
41730 if (!dev_size)
41731 return 0;
41732
41733 - if ((start >= dev_size) || (start + len > dev_size)) {
41734 + if ((start >= dev_size) || (len > dev_size - start)) {
41735 DMWARN("%s: %s too small for target: "
41736 "start=%llu, len=%llu, dev_size=%llu",
41737 dm_device_name(ti->table->md), bdevname(bdev, b),
41738 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
41739 index 60bce43..9b997d0 100644
41740 --- a/drivers/md/dm-thin-metadata.c
41741 +++ b/drivers/md/dm-thin-metadata.c
41742 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41743 {
41744 pmd->info.tm = pmd->tm;
41745 pmd->info.levels = 2;
41746 - pmd->info.value_type.context = pmd->data_sm;
41747 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41748 pmd->info.value_type.size = sizeof(__le64);
41749 pmd->info.value_type.inc = data_block_inc;
41750 pmd->info.value_type.dec = data_block_dec;
41751 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41752
41753 pmd->bl_info.tm = pmd->tm;
41754 pmd->bl_info.levels = 1;
41755 - pmd->bl_info.value_type.context = pmd->data_sm;
41756 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41757 pmd->bl_info.value_type.size = sizeof(__le64);
41758 pmd->bl_info.value_type.inc = data_block_inc;
41759 pmd->bl_info.value_type.dec = data_block_dec;
41760 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
41761 index b3e26c7..1efca94 100644
41762 --- a/drivers/md/dm.c
41763 +++ b/drivers/md/dm.c
41764 @@ -179,9 +179,9 @@ struct mapped_device {
41765 /*
41766 * Event handling.
41767 */
41768 - atomic_t event_nr;
41769 + atomic_unchecked_t event_nr;
41770 wait_queue_head_t eventq;
41771 - atomic_t uevent_seq;
41772 + atomic_unchecked_t uevent_seq;
41773 struct list_head uevent_list;
41774 spinlock_t uevent_lock; /* Protect access to uevent_list */
41775
41776 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
41777 spin_lock_init(&md->deferred_lock);
41778 atomic_set(&md->holders, 1);
41779 atomic_set(&md->open_count, 0);
41780 - atomic_set(&md->event_nr, 0);
41781 - atomic_set(&md->uevent_seq, 0);
41782 + atomic_set_unchecked(&md->event_nr, 0);
41783 + atomic_set_unchecked(&md->uevent_seq, 0);
41784 INIT_LIST_HEAD(&md->uevent_list);
41785 spin_lock_init(&md->uevent_lock);
41786
41787 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
41788
41789 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
41790
41791 - atomic_inc(&md->event_nr);
41792 + atomic_inc_unchecked(&md->event_nr);
41793 wake_up(&md->eventq);
41794 }
41795
41796 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
41797
41798 uint32_t dm_next_uevent_seq(struct mapped_device *md)
41799 {
41800 - return atomic_add_return(1, &md->uevent_seq);
41801 + return atomic_add_return_unchecked(1, &md->uevent_seq);
41802 }
41803
41804 uint32_t dm_get_event_nr(struct mapped_device *md)
41805 {
41806 - return atomic_read(&md->event_nr);
41807 + return atomic_read_unchecked(&md->event_nr);
41808 }
41809
41810 int dm_wait_event(struct mapped_device *md, int event_nr)
41811 {
41812 return wait_event_interruptible(md->eventq,
41813 - (event_nr != atomic_read(&md->event_nr)));
41814 + (event_nr != atomic_read_unchecked(&md->event_nr)));
41815 }
41816
41817 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
41818 diff --git a/drivers/md/md.c b/drivers/md/md.c
41819 index 561a65f..f4e8c71 100644
41820 --- a/drivers/md/md.c
41821 +++ b/drivers/md/md.c
41822 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
41823 * start build, activate spare
41824 */
41825 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
41826 -static atomic_t md_event_count;
41827 +static atomic_unchecked_t md_event_count;
41828 void md_new_event(struct mddev *mddev)
41829 {
41830 - atomic_inc(&md_event_count);
41831 + atomic_inc_unchecked(&md_event_count);
41832 wake_up(&md_event_waiters);
41833 }
41834 EXPORT_SYMBOL_GPL(md_new_event);
41835 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
41836 */
41837 static void md_new_event_inintr(struct mddev *mddev)
41838 {
41839 - atomic_inc(&md_event_count);
41840 + atomic_inc_unchecked(&md_event_count);
41841 wake_up(&md_event_waiters);
41842 }
41843
41844 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
41845 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
41846 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
41847 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
41848 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41849 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41850
41851 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
41852 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
41853 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
41854 else
41855 sb->resync_offset = cpu_to_le64(0);
41856
41857 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
41858 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
41859
41860 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
41861 sb->size = cpu_to_le64(mddev->dev_sectors);
41862 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
41863 static ssize_t
41864 errors_show(struct md_rdev *rdev, char *page)
41865 {
41866 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
41867 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
41868 }
41869
41870 static ssize_t
41871 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
41872 char *e;
41873 unsigned long n = simple_strtoul(buf, &e, 10);
41874 if (*buf && (*e == 0 || *e == '\n')) {
41875 - atomic_set(&rdev->corrected_errors, n);
41876 + atomic_set_unchecked(&rdev->corrected_errors, n);
41877 return len;
41878 }
41879 return -EINVAL;
41880 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
41881 rdev->sb_loaded = 0;
41882 rdev->bb_page = NULL;
41883 atomic_set(&rdev->nr_pending, 0);
41884 - atomic_set(&rdev->read_errors, 0);
41885 - atomic_set(&rdev->corrected_errors, 0);
41886 + atomic_set_unchecked(&rdev->read_errors, 0);
41887 + atomic_set_unchecked(&rdev->corrected_errors, 0);
41888
41889 INIT_LIST_HEAD(&rdev->same_set);
41890 init_waitqueue_head(&rdev->blocked_wait);
41891 @@ -7042,7 +7042,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
41892
41893 spin_unlock(&pers_lock);
41894 seq_printf(seq, "\n");
41895 - seq->poll_event = atomic_read(&md_event_count);
41896 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41897 return 0;
41898 }
41899 if (v == (void*)2) {
41900 @@ -7145,7 +7145,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
41901 return error;
41902
41903 seq = file->private_data;
41904 - seq->poll_event = atomic_read(&md_event_count);
41905 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41906 return error;
41907 }
41908
41909 @@ -7159,7 +7159,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
41910 /* always allow read */
41911 mask = POLLIN | POLLRDNORM;
41912
41913 - if (seq->poll_event != atomic_read(&md_event_count))
41914 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
41915 mask |= POLLERR | POLLPRI;
41916 return mask;
41917 }
41918 @@ -7203,7 +7203,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
41919 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
41920 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
41921 (int)part_stat_read(&disk->part0, sectors[1]) -
41922 - atomic_read(&disk->sync_io);
41923 + atomic_read_unchecked(&disk->sync_io);
41924 /* sync IO will cause sync_io to increase before the disk_stats
41925 * as sync_io is counted when a request starts, and
41926 * disk_stats is counted when it completes.
41927 diff --git a/drivers/md/md.h b/drivers/md/md.h
41928 index 608050c..6e77db5d 100644
41929 --- a/drivers/md/md.h
41930 +++ b/drivers/md/md.h
41931 @@ -94,13 +94,13 @@ struct md_rdev {
41932 * only maintained for arrays that
41933 * support hot removal
41934 */
41935 - atomic_t read_errors; /* number of consecutive read errors that
41936 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
41937 * we have tried to ignore.
41938 */
41939 struct timespec last_read_error; /* monotonic time since our
41940 * last read error
41941 */
41942 - atomic_t corrected_errors; /* number of corrected read errors,
41943 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
41944 * for reporting to userspace and storing
41945 * in superblock.
41946 */
41947 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
41948
41949 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
41950 {
41951 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
41952 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
41953 }
41954
41955 struct md_personality
41956 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
41957 index 3e6d115..ffecdeb 100644
41958 --- a/drivers/md/persistent-data/dm-space-map.h
41959 +++ b/drivers/md/persistent-data/dm-space-map.h
41960 @@ -71,6 +71,7 @@ struct dm_space_map {
41961 dm_sm_threshold_fn fn,
41962 void *context);
41963 };
41964 +typedef struct dm_space_map __no_const dm_space_map_no_const;
41965
41966 /*----------------------------------------------------------------*/
41967
41968 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
41969 index aacf6bf..67d63f2 100644
41970 --- a/drivers/md/raid1.c
41971 +++ b/drivers/md/raid1.c
41972 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
41973 if (r1_sync_page_io(rdev, sect, s,
41974 bio->bi_io_vec[idx].bv_page,
41975 READ) != 0)
41976 - atomic_add(s, &rdev->corrected_errors);
41977 + atomic_add_unchecked(s, &rdev->corrected_errors);
41978 }
41979 sectors -= s;
41980 sect += s;
41981 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
41982 test_bit(In_sync, &rdev->flags)) {
41983 if (r1_sync_page_io(rdev, sect, s,
41984 conf->tmppage, READ)) {
41985 - atomic_add(s, &rdev->corrected_errors);
41986 + atomic_add_unchecked(s, &rdev->corrected_errors);
41987 printk(KERN_INFO
41988 "md/raid1:%s: read error corrected "
41989 "(%d sectors at %llu on %s)\n",
41990 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
41991 index 73dc8a3..bdd515a 100644
41992 --- a/drivers/md/raid10.c
41993 +++ b/drivers/md/raid10.c
41994 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
41995 /* The write handler will notice the lack of
41996 * R10BIO_Uptodate and record any errors etc
41997 */
41998 - atomic_add(r10_bio->sectors,
41999 + atomic_add_unchecked(r10_bio->sectors,
42000 &conf->mirrors[d].rdev->corrected_errors);
42001
42002 /* for reconstruct, we always reschedule after a read.
42003 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42004 {
42005 struct timespec cur_time_mon;
42006 unsigned long hours_since_last;
42007 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42008 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42009
42010 ktime_get_ts(&cur_time_mon);
42011
42012 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42013 * overflowing the shift of read_errors by hours_since_last.
42014 */
42015 if (hours_since_last >= 8 * sizeof(read_errors))
42016 - atomic_set(&rdev->read_errors, 0);
42017 + atomic_set_unchecked(&rdev->read_errors, 0);
42018 else
42019 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42020 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42021 }
42022
42023 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42024 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42025 return;
42026
42027 check_decay_read_errors(mddev, rdev);
42028 - atomic_inc(&rdev->read_errors);
42029 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42030 + atomic_inc_unchecked(&rdev->read_errors);
42031 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42032 char b[BDEVNAME_SIZE];
42033 bdevname(rdev->bdev, b);
42034
42035 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42036 "md/raid10:%s: %s: Raid device exceeded "
42037 "read_error threshold [cur %d:max %d]\n",
42038 mdname(mddev), b,
42039 - atomic_read(&rdev->read_errors), max_read_errors);
42040 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42041 printk(KERN_NOTICE
42042 "md/raid10:%s: %s: Failing raid device\n",
42043 mdname(mddev), b);
42044 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42045 sect +
42046 choose_data_offset(r10_bio, rdev)),
42047 bdevname(rdev->bdev, b));
42048 - atomic_add(s, &rdev->corrected_errors);
42049 + atomic_add_unchecked(s, &rdev->corrected_errors);
42050 }
42051
42052 rdev_dec_pending(rdev, mddev);
42053 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42054 index f8b9068..7a2b9fc 100644
42055 --- a/drivers/md/raid5.c
42056 +++ b/drivers/md/raid5.c
42057 @@ -1886,21 +1886,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42058 mdname(conf->mddev), STRIPE_SECTORS,
42059 (unsigned long long)s,
42060 bdevname(rdev->bdev, b));
42061 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42062 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42063 clear_bit(R5_ReadError, &sh->dev[i].flags);
42064 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42065 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42066 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42067
42068 - if (atomic_read(&rdev->read_errors))
42069 - atomic_set(&rdev->read_errors, 0);
42070 + if (atomic_read_unchecked(&rdev->read_errors))
42071 + atomic_set_unchecked(&rdev->read_errors, 0);
42072 } else {
42073 const char *bdn = bdevname(rdev->bdev, b);
42074 int retry = 0;
42075 int set_bad = 0;
42076
42077 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42078 - atomic_inc(&rdev->read_errors);
42079 + atomic_inc_unchecked(&rdev->read_errors);
42080 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42081 printk_ratelimited(
42082 KERN_WARNING
42083 @@ -1928,7 +1928,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42084 mdname(conf->mddev),
42085 (unsigned long long)s,
42086 bdn);
42087 - } else if (atomic_read(&rdev->read_errors)
42088 + } else if (atomic_read_unchecked(&rdev->read_errors)
42089 > conf->max_nr_stripes)
42090 printk(KERN_WARNING
42091 "md/raid:%s: Too many read errors, failing device %s.\n",
42092 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42093 index 401ef64..836e563 100644
42094 --- a/drivers/media/dvb-core/dvbdev.c
42095 +++ b/drivers/media/dvb-core/dvbdev.c
42096 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42097 const struct dvb_device *template, void *priv, int type)
42098 {
42099 struct dvb_device *dvbdev;
42100 - struct file_operations *dvbdevfops;
42101 + file_operations_no_const *dvbdevfops;
42102 struct device *clsdev;
42103 int minor;
42104 int id;
42105 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42106 index 9b6c3bb..baeb5c7 100644
42107 --- a/drivers/media/dvb-frontends/dib3000.h
42108 +++ b/drivers/media/dvb-frontends/dib3000.h
42109 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42110 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42111 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42112 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42113 -};
42114 +} __no_const;
42115
42116 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42117 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42118 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42119 index ecf21d9..b992428d 100644
42120 --- a/drivers/media/pci/cx88/cx88-video.c
42121 +++ b/drivers/media/pci/cx88/cx88-video.c
42122 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42123
42124 /* ------------------------------------------------------------------ */
42125
42126 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42127 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42128 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42129 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42130 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42131 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42132
42133 module_param_array(video_nr, int, NULL, 0444);
42134 module_param_array(vbi_nr, int, NULL, 0444);
42135 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42136 index c08ae3e..eb59af1 100644
42137 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42138 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42139 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42140 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42141
42142 /* ivtv instance counter */
42143 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42144 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42145
42146 /* Parameter declarations */
42147 static int cardtype[IVTV_MAX_CARDS];
42148 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42149 index dfd0a21..6bbb465 100644
42150 --- a/drivers/media/platform/omap/omap_vout.c
42151 +++ b/drivers/media/platform/omap/omap_vout.c
42152 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42153 OMAP_VIDEO2,
42154 };
42155
42156 -static struct videobuf_queue_ops video_vbq_ops;
42157 /* Variables configurable through module params*/
42158 static u32 video1_numbuffers = 3;
42159 static u32 video2_numbuffers = 3;
42160 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42161 {
42162 struct videobuf_queue *q;
42163 struct omap_vout_device *vout = NULL;
42164 + static struct videobuf_queue_ops video_vbq_ops = {
42165 + .buf_setup = omap_vout_buffer_setup,
42166 + .buf_prepare = omap_vout_buffer_prepare,
42167 + .buf_release = omap_vout_buffer_release,
42168 + .buf_queue = omap_vout_buffer_queue,
42169 + };
42170
42171 vout = video_drvdata(file);
42172 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42173 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42174 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42175
42176 q = &vout->vbq;
42177 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42178 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42179 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42180 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42181 spin_lock_init(&vout->vbq_lock);
42182
42183 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42184 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42185 index 04e6490..2df65bf 100644
42186 --- a/drivers/media/platform/s5p-tv/mixer.h
42187 +++ b/drivers/media/platform/s5p-tv/mixer.h
42188 @@ -156,7 +156,7 @@ struct mxr_layer {
42189 /** layer index (unique identifier) */
42190 int idx;
42191 /** callbacks for layer methods */
42192 - struct mxr_layer_ops ops;
42193 + struct mxr_layer_ops *ops;
42194 /** format array */
42195 const struct mxr_format **fmt_array;
42196 /** size of format array */
42197 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42198 index b93a21f..2535195 100644
42199 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42200 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42201 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42202 {
42203 struct mxr_layer *layer;
42204 int ret;
42205 - struct mxr_layer_ops ops = {
42206 + static struct mxr_layer_ops ops = {
42207 .release = mxr_graph_layer_release,
42208 .buffer_set = mxr_graph_buffer_set,
42209 .stream_set = mxr_graph_stream_set,
42210 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42211 index b713403..53cb5ad 100644
42212 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42213 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42214 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42215 layer->update_buf = next;
42216 }
42217
42218 - layer->ops.buffer_set(layer, layer->update_buf);
42219 + layer->ops->buffer_set(layer, layer->update_buf);
42220
42221 if (done && done != layer->shadow_buf)
42222 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42223 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42224 index 641b1f0..49cff30 100644
42225 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42226 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42227 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42228 layer->geo.src.height = layer->geo.src.full_height;
42229
42230 mxr_geometry_dump(mdev, &layer->geo);
42231 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42232 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42233 mxr_geometry_dump(mdev, &layer->geo);
42234 }
42235
42236 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42237 layer->geo.dst.full_width = mbus_fmt.width;
42238 layer->geo.dst.full_height = mbus_fmt.height;
42239 layer->geo.dst.field = mbus_fmt.field;
42240 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42241 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42242
42243 mxr_geometry_dump(mdev, &layer->geo);
42244 }
42245 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42246 /* set source size to highest accepted value */
42247 geo->src.full_width = max(geo->dst.full_width, pix->width);
42248 geo->src.full_height = max(geo->dst.full_height, pix->height);
42249 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42250 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42251 mxr_geometry_dump(mdev, &layer->geo);
42252 /* set cropping to total visible screen */
42253 geo->src.width = pix->width;
42254 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42255 geo->src.x_offset = 0;
42256 geo->src.y_offset = 0;
42257 /* assure consistency of geometry */
42258 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42259 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42260 mxr_geometry_dump(mdev, &layer->geo);
42261 /* set full size to lowest possible value */
42262 geo->src.full_width = 0;
42263 geo->src.full_height = 0;
42264 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42265 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42266 mxr_geometry_dump(mdev, &layer->geo);
42267
42268 /* returning results */
42269 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42270 target->width = s->r.width;
42271 target->height = s->r.height;
42272
42273 - layer->ops.fix_geometry(layer, stage, s->flags);
42274 + layer->ops->fix_geometry(layer, stage, s->flags);
42275
42276 /* retrieve update selection rectangle */
42277 res.left = target->x_offset;
42278 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42279 mxr_output_get(mdev);
42280
42281 mxr_layer_update_output(layer);
42282 - layer->ops.format_set(layer);
42283 + layer->ops->format_set(layer);
42284 /* enabling layer in hardware */
42285 spin_lock_irqsave(&layer->enq_slock, flags);
42286 layer->state = MXR_LAYER_STREAMING;
42287 spin_unlock_irqrestore(&layer->enq_slock, flags);
42288
42289 - layer->ops.stream_set(layer, MXR_ENABLE);
42290 + layer->ops->stream_set(layer, MXR_ENABLE);
42291 mxr_streamer_get(mdev);
42292
42293 return 0;
42294 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42295 spin_unlock_irqrestore(&layer->enq_slock, flags);
42296
42297 /* disabling layer in hardware */
42298 - layer->ops.stream_set(layer, MXR_DISABLE);
42299 + layer->ops->stream_set(layer, MXR_DISABLE);
42300 /* remove one streamer */
42301 mxr_streamer_put(mdev);
42302 /* allow changes in output configuration */
42303 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42304
42305 void mxr_layer_release(struct mxr_layer *layer)
42306 {
42307 - if (layer->ops.release)
42308 - layer->ops.release(layer);
42309 + if (layer->ops->release)
42310 + layer->ops->release(layer);
42311 }
42312
42313 void mxr_base_layer_release(struct mxr_layer *layer)
42314 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42315
42316 layer->mdev = mdev;
42317 layer->idx = idx;
42318 - layer->ops = *ops;
42319 + layer->ops = ops;
42320
42321 spin_lock_init(&layer->enq_slock);
42322 INIT_LIST_HEAD(&layer->enq_list);
42323 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42324 index 3d13a63..da31bf1 100644
42325 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42326 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42327 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42328 {
42329 struct mxr_layer *layer;
42330 int ret;
42331 - struct mxr_layer_ops ops = {
42332 + static struct mxr_layer_ops ops = {
42333 .release = mxr_vp_layer_release,
42334 .buffer_set = mxr_vp_buffer_set,
42335 .stream_set = mxr_vp_stream_set,
42336 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42337 index 545c04c..a14bded 100644
42338 --- a/drivers/media/radio/radio-cadet.c
42339 +++ b/drivers/media/radio/radio-cadet.c
42340 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42341 unsigned char readbuf[RDS_BUFFER];
42342 int i = 0;
42343
42344 + if (count > RDS_BUFFER)
42345 + return -EFAULT;
42346 mutex_lock(&dev->lock);
42347 if (dev->rdsstat == 0)
42348 cadet_start_rds(dev);
42349 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42350 while (i < count && dev->rdsin != dev->rdsout)
42351 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42352
42353 - if (i && copy_to_user(data, readbuf, i))
42354 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42355 i = -EFAULT;
42356 unlock:
42357 mutex_unlock(&dev->lock);
42358 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42359 index 5236035..c622c74 100644
42360 --- a/drivers/media/radio/radio-maxiradio.c
42361 +++ b/drivers/media/radio/radio-maxiradio.c
42362 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42363 /* TEA5757 pin mappings */
42364 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42365
42366 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42367 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42368
42369 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42370 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42371 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42372 index b914772..7ddbf9b 100644
42373 --- a/drivers/media/radio/radio-shark.c
42374 +++ b/drivers/media/radio/radio-shark.c
42375 @@ -79,7 +79,7 @@ struct shark_device {
42376 u32 last_val;
42377 };
42378
42379 -static atomic_t shark_instance = ATOMIC_INIT(0);
42380 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42381
42382 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42383 {
42384 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42385 index 9fb6697..f167415 100644
42386 --- a/drivers/media/radio/radio-shark2.c
42387 +++ b/drivers/media/radio/radio-shark2.c
42388 @@ -74,7 +74,7 @@ struct shark_device {
42389 u8 *transfer_buffer;
42390 };
42391
42392 -static atomic_t shark_instance = ATOMIC_INIT(0);
42393 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42394
42395 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42396 {
42397 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42398 index 9c9084c..a9e8dfb 100644
42399 --- a/drivers/media/radio/radio-si476x.c
42400 +++ b/drivers/media/radio/radio-si476x.c
42401 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42402 struct si476x_radio *radio;
42403 struct v4l2_ctrl *ctrl;
42404
42405 - static atomic_t instance = ATOMIC_INIT(0);
42406 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42407
42408 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42409 if (!radio)
42410 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42411 index 46da365..3ba4206 100644
42412 --- a/drivers/media/rc/rc-main.c
42413 +++ b/drivers/media/rc/rc-main.c
42414 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42415 int rc_register_device(struct rc_dev *dev)
42416 {
42417 static bool raw_init = false; /* raw decoders loaded? */
42418 - static atomic_t devno = ATOMIC_INIT(0);
42419 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42420 struct rc_map *rc_map;
42421 const char *path;
42422 int rc;
42423 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
42424 */
42425 mutex_lock(&dev->lock);
42426
42427 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42428 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42429 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42430 dev_set_drvdata(&dev->dev, dev);
42431 rc = device_add(&dev->dev);
42432 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42433 index 3940bb0..fb3952a 100644
42434 --- a/drivers/media/usb/dvb-usb/cxusb.c
42435 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42436 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42437
42438 struct dib0700_adapter_state {
42439 int (*set_param_save) (struct dvb_frontend *);
42440 -};
42441 +} __no_const;
42442
42443 static int dib7070_set_param_override(struct dvb_frontend *fe)
42444 {
42445 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42446 index 6e237b6..dc25556 100644
42447 --- a/drivers/media/usb/dvb-usb/dw2102.c
42448 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42449 @@ -118,7 +118,7 @@ struct su3000_state {
42450
42451 struct s6x0_state {
42452 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42453 -};
42454 +} __no_const;
42455
42456 /* debug */
42457 static int dvb_usb_dw2102_debug;
42458 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42459 index 8f7a6a4..59502dd 100644
42460 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42461 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42462 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42463 __u32 reserved;
42464 };
42465
42466 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42467 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42468 enum v4l2_memory memory)
42469 {
42470 void __user *up_pln;
42471 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42472 return 0;
42473 }
42474
42475 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42476 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42477 enum v4l2_memory memory)
42478 {
42479 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42480 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42481 put_user(kp->start_block, &up->start_block) ||
42482 put_user(kp->blocks, &up->blocks) ||
42483 put_user(tmp, &up->edid) ||
42484 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42485 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42486 return -EFAULT;
42487 return 0;
42488 }
42489 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42490 index 02d1b63..5fd6b16 100644
42491 --- a/drivers/media/v4l2-core/v4l2-device.c
42492 +++ b/drivers/media/v4l2-core/v4l2-device.c
42493 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42494 EXPORT_SYMBOL_GPL(v4l2_device_put);
42495
42496 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42497 - atomic_t *instance)
42498 + atomic_unchecked_t *instance)
42499 {
42500 - int num = atomic_inc_return(instance) - 1;
42501 + int num = atomic_inc_return_unchecked(instance) - 1;
42502 int len = strlen(basename);
42503
42504 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42505 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42506 index 68e6b5e..d8b923e 100644
42507 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42508 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42509 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42510 struct file *file, void *fh, void *p);
42511 } u;
42512 void (*debug)(const void *arg, bool write_only);
42513 -};
42514 +} __do_const;
42515 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42516
42517 /* This control needs a priority check */
42518 #define INFO_FL_PRIO (1 << 0)
42519 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42520 struct video_device *vfd = video_devdata(file);
42521 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42522 bool write_only = false;
42523 - struct v4l2_ioctl_info default_info;
42524 + v4l2_ioctl_info_no_const default_info;
42525 const struct v4l2_ioctl_info *info;
42526 void *fh = file->private_data;
42527 struct v4l2_fh *vfh = NULL;
42528 @@ -2194,7 +2195,7 @@ done:
42529 }
42530
42531 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42532 - void * __user *user_ptr, void ***kernel_ptr)
42533 + void __user **user_ptr, void ***kernel_ptr)
42534 {
42535 int ret = 0;
42536
42537 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42538 ret = -EINVAL;
42539 break;
42540 }
42541 - *user_ptr = (void __user *)buf->m.planes;
42542 + *user_ptr = (void __force_user *)buf->m.planes;
42543 *kernel_ptr = (void *)&buf->m.planes;
42544 *array_size = sizeof(struct v4l2_plane) * buf->length;
42545 ret = 1;
42546 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42547 ret = -EINVAL;
42548 break;
42549 }
42550 - *user_ptr = (void __user *)ctrls->controls;
42551 + *user_ptr = (void __force_user *)ctrls->controls;
42552 *kernel_ptr = (void *)&ctrls->controls;
42553 *array_size = sizeof(struct v4l2_ext_control)
42554 * ctrls->count;
42555 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42556 index 767ff4d..c69d259 100644
42557 --- a/drivers/message/fusion/mptbase.c
42558 +++ b/drivers/message/fusion/mptbase.c
42559 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42560 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42561 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42562
42563 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42564 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42565 +#else
42566 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42567 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42568 +#endif
42569 +
42570 /*
42571 * Rounding UP to nearest 4-kB boundary here...
42572 */
42573 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42574 ioc->facts.GlobalCredits);
42575
42576 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42577 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42578 + NULL, NULL);
42579 +#else
42580 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42581 +#endif
42582 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42583 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42584 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42585 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42586 index dd239bd..689c4f7 100644
42587 --- a/drivers/message/fusion/mptsas.c
42588 +++ b/drivers/message/fusion/mptsas.c
42589 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42590 return 0;
42591 }
42592
42593 +static inline void
42594 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42595 +{
42596 + if (phy_info->port_details) {
42597 + phy_info->port_details->rphy = rphy;
42598 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42599 + ioc->name, rphy));
42600 + }
42601 +
42602 + if (rphy) {
42603 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42604 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42605 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42606 + ioc->name, rphy, rphy->dev.release));
42607 + }
42608 +}
42609 +
42610 /* no mutex */
42611 static void
42612 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42613 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42614 return NULL;
42615 }
42616
42617 -static inline void
42618 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42619 -{
42620 - if (phy_info->port_details) {
42621 - phy_info->port_details->rphy = rphy;
42622 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42623 - ioc->name, rphy));
42624 - }
42625 -
42626 - if (rphy) {
42627 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42628 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42629 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42630 - ioc->name, rphy, rphy->dev.release));
42631 - }
42632 -}
42633 -
42634 static inline struct sas_port *
42635 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42636 {
42637 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42638 index 727819c..ad74694 100644
42639 --- a/drivers/message/fusion/mptscsih.c
42640 +++ b/drivers/message/fusion/mptscsih.c
42641 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42642
42643 h = shost_priv(SChost);
42644
42645 - if (h) {
42646 - if (h->info_kbuf == NULL)
42647 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42648 - return h->info_kbuf;
42649 - h->info_kbuf[0] = '\0';
42650 + if (!h)
42651 + return NULL;
42652
42653 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42654 - h->info_kbuf[size-1] = '\0';
42655 - }
42656 + if (h->info_kbuf == NULL)
42657 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42658 + return h->info_kbuf;
42659 + h->info_kbuf[0] = '\0';
42660 +
42661 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42662 + h->info_kbuf[size-1] = '\0';
42663
42664 return h->info_kbuf;
42665 }
42666 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
42667 index b7d87cd..3fb36da 100644
42668 --- a/drivers/message/i2o/i2o_proc.c
42669 +++ b/drivers/message/i2o/i2o_proc.c
42670 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
42671 "Array Controller Device"
42672 };
42673
42674 -static char *chtostr(char *tmp, u8 *chars, int n)
42675 -{
42676 - tmp[0] = 0;
42677 - return strncat(tmp, (char *)chars, n);
42678 -}
42679 -
42680 static int i2o_report_query_status(struct seq_file *seq, int block_status,
42681 char *group)
42682 {
42683 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
42684 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
42685 {
42686 struct i2o_controller *c = (struct i2o_controller *)seq->private;
42687 - static u32 work32[5];
42688 - static u8 *work8 = (u8 *) work32;
42689 - static u16 *work16 = (u16 *) work32;
42690 + u32 work32[5];
42691 + u8 *work8 = (u8 *) work32;
42692 + u16 *work16 = (u16 *) work32;
42693 int token;
42694 u32 hwcap;
42695
42696 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42697 } *result;
42698
42699 i2o_exec_execute_ddm_table ddm_table;
42700 - char tmp[28 + 1];
42701
42702 result = kmalloc(sizeof(*result), GFP_KERNEL);
42703 if (!result)
42704 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42705
42706 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
42707 seq_printf(seq, "%-#8x", ddm_table.module_id);
42708 - seq_printf(seq, "%-29s",
42709 - chtostr(tmp, ddm_table.module_name_version, 28));
42710 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
42711 seq_printf(seq, "%9d ", ddm_table.data_size);
42712 seq_printf(seq, "%8d", ddm_table.code_size);
42713
42714 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42715
42716 i2o_driver_result_table *result;
42717 i2o_driver_store_table *dst;
42718 - char tmp[28 + 1];
42719
42720 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
42721 if (result == NULL)
42722 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42723
42724 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
42725 seq_printf(seq, "%-#8x", dst->module_id);
42726 - seq_printf(seq, "%-29s",
42727 - chtostr(tmp, dst->module_name_version, 28));
42728 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
42729 + seq_printf(seq, "%-.28s", dst->module_name_version);
42730 + seq_printf(seq, "%-.8s", dst->date);
42731 seq_printf(seq, "%8d ", dst->module_size);
42732 seq_printf(seq, "%8d ", dst->mpb_size);
42733 seq_printf(seq, "0x%04x", dst->module_flags);
42734 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
42735 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42736 {
42737 struct i2o_device *d = (struct i2o_device *)seq->private;
42738 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42739 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42740 // == (allow) 512d bytes (max)
42741 - static u16 *work16 = (u16 *) work32;
42742 + u16 *work16 = (u16 *) work32;
42743 int token;
42744 - char tmp[16 + 1];
42745
42746 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
42747
42748 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42749 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
42750 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
42751 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
42752 - seq_printf(seq, "Vendor info : %s\n",
42753 - chtostr(tmp, (u8 *) (work32 + 2), 16));
42754 - seq_printf(seq, "Product info : %s\n",
42755 - chtostr(tmp, (u8 *) (work32 + 6), 16));
42756 - seq_printf(seq, "Description : %s\n",
42757 - chtostr(tmp, (u8 *) (work32 + 10), 16));
42758 - seq_printf(seq, "Product rev. : %s\n",
42759 - chtostr(tmp, (u8 *) (work32 + 14), 8));
42760 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
42761 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
42762 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
42763 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
42764
42765 seq_printf(seq, "Serial number : ");
42766 print_serial_number(seq, (u8 *) (work32 + 16),
42767 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42768 u8 pad[256]; // allow up to 256 byte (max) serial number
42769 } result;
42770
42771 - char tmp[24 + 1];
42772 -
42773 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
42774
42775 if (token < 0) {
42776 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42777 }
42778
42779 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
42780 - seq_printf(seq, "Module name : %s\n",
42781 - chtostr(tmp, result.module_name, 24));
42782 - seq_printf(seq, "Module revision : %s\n",
42783 - chtostr(tmp, result.module_rev, 8));
42784 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
42785 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
42786
42787 seq_printf(seq, "Serial number : ");
42788 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
42789 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42790 u8 instance_number[4];
42791 } result;
42792
42793 - char tmp[64 + 1];
42794 -
42795 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
42796
42797 if (token < 0) {
42798 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42799 return 0;
42800 }
42801
42802 - seq_printf(seq, "Device name : %s\n",
42803 - chtostr(tmp, result.device_name, 64));
42804 - seq_printf(seq, "Service name : %s\n",
42805 - chtostr(tmp, result.service_name, 64));
42806 - seq_printf(seq, "Physical name : %s\n",
42807 - chtostr(tmp, result.physical_location, 64));
42808 - seq_printf(seq, "Instance number : %s\n",
42809 - chtostr(tmp, result.instance_number, 4));
42810 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
42811 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
42812 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
42813 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
42814
42815 return 0;
42816 }
42817 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42818 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
42819 {
42820 struct i2o_device *d = (struct i2o_device *)seq->private;
42821 - static u32 work32[12];
42822 - static u16 *work16 = (u16 *) work32;
42823 - static u8 *work8 = (u8 *) work32;
42824 + u32 work32[12];
42825 + u16 *work16 = (u16 *) work32;
42826 + u8 *work8 = (u8 *) work32;
42827 int token;
42828
42829 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
42830 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
42831 index a8c08f3..155fe3d 100644
42832 --- a/drivers/message/i2o/iop.c
42833 +++ b/drivers/message/i2o/iop.c
42834 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
42835
42836 spin_lock_irqsave(&c->context_list_lock, flags);
42837
42838 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
42839 - atomic_inc(&c->context_list_counter);
42840 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
42841 + atomic_inc_unchecked(&c->context_list_counter);
42842
42843 - entry->context = atomic_read(&c->context_list_counter);
42844 + entry->context = atomic_read_unchecked(&c->context_list_counter);
42845
42846 list_add(&entry->list, &c->context_list);
42847
42848 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
42849
42850 #if BITS_PER_LONG == 64
42851 spin_lock_init(&c->context_list_lock);
42852 - atomic_set(&c->context_list_counter, 0);
42853 + atomic_set_unchecked(&c->context_list_counter, 0);
42854 INIT_LIST_HEAD(&c->context_list);
42855 #endif
42856
42857 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
42858 index fcbb2e9..2635e11 100644
42859 --- a/drivers/mfd/janz-cmodio.c
42860 +++ b/drivers/mfd/janz-cmodio.c
42861 @@ -13,6 +13,7 @@
42862
42863 #include <linux/kernel.h>
42864 #include <linux/module.h>
42865 +#include <linux/slab.h>
42866 #include <linux/init.h>
42867 #include <linux/pci.h>
42868 #include <linux/interrupt.h>
42869 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
42870 index de7fb80..7c1b931 100644
42871 --- a/drivers/mfd/max8925-i2c.c
42872 +++ b/drivers/mfd/max8925-i2c.c
42873 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
42874 const struct i2c_device_id *id)
42875 {
42876 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
42877 - static struct max8925_chip *chip;
42878 + struct max8925_chip *chip;
42879 struct device_node *node = client->dev.of_node;
42880
42881 if (node && !pdata) {
42882 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
42883 index d792772..cd73ba3 100644
42884 --- a/drivers/mfd/tps65910.c
42885 +++ b/drivers/mfd/tps65910.c
42886 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
42887 struct tps65910_platform_data *pdata)
42888 {
42889 int ret = 0;
42890 - static struct regmap_irq_chip *tps6591x_irqs_chip;
42891 + struct regmap_irq_chip *tps6591x_irqs_chip;
42892
42893 if (!irq) {
42894 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
42895 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
42896 index 9aa6d1e..1631bfc 100644
42897 --- a/drivers/mfd/twl4030-irq.c
42898 +++ b/drivers/mfd/twl4030-irq.c
42899 @@ -35,6 +35,7 @@
42900 #include <linux/of.h>
42901 #include <linux/irqdomain.h>
42902 #include <linux/i2c/twl.h>
42903 +#include <asm/pgtable.h>
42904
42905 #include "twl-core.h"
42906
42907 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
42908 * Install an irq handler for each of the SIH modules;
42909 * clone dummy irq_chip since PIH can't *do* anything
42910 */
42911 - twl4030_irq_chip = dummy_irq_chip;
42912 - twl4030_irq_chip.name = "twl4030";
42913 + pax_open_kernel();
42914 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
42915 + *(const char **)&twl4030_irq_chip.name = "twl4030";
42916
42917 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42918 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42919 + pax_close_kernel();
42920
42921 for (i = irq_base; i < irq_end; i++) {
42922 irq_set_chip_and_handler(i, &twl4030_irq_chip,
42923 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
42924 index 464419b..64bae8d 100644
42925 --- a/drivers/misc/c2port/core.c
42926 +++ b/drivers/misc/c2port/core.c
42927 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
42928 goto error_idr_alloc;
42929 c2dev->id = ret;
42930
42931 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
42932 + pax_open_kernel();
42933 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
42934 + pax_close_kernel();
42935
42936 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
42937 "c2port%d", c2dev->id);
42938 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
42939 index 36f5d52..32311c3 100644
42940 --- a/drivers/misc/kgdbts.c
42941 +++ b/drivers/misc/kgdbts.c
42942 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
42943 char before[BREAK_INSTR_SIZE];
42944 char after[BREAK_INSTR_SIZE];
42945
42946 - probe_kernel_read(before, (char *)kgdbts_break_test,
42947 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
42948 BREAK_INSTR_SIZE);
42949 init_simple_test();
42950 ts.tst = plant_and_detach_test;
42951 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
42952 /* Activate test with initial breakpoint */
42953 if (!is_early)
42954 kgdb_breakpoint();
42955 - probe_kernel_read(after, (char *)kgdbts_break_test,
42956 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
42957 BREAK_INSTR_SIZE);
42958 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
42959 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
42960 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
42961 index 036effe..b3a6336 100644
42962 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
42963 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
42964 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
42965 * the lid is closed. This leads to interrupts as soon as a little move
42966 * is done.
42967 */
42968 - atomic_inc(&lis3->count);
42969 + atomic_inc_unchecked(&lis3->count);
42970
42971 wake_up_interruptible(&lis3->misc_wait);
42972 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
42973 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
42974 if (lis3->pm_dev)
42975 pm_runtime_get_sync(lis3->pm_dev);
42976
42977 - atomic_set(&lis3->count, 0);
42978 + atomic_set_unchecked(&lis3->count, 0);
42979 return 0;
42980 }
42981
42982 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
42983 add_wait_queue(&lis3->misc_wait, &wait);
42984 while (true) {
42985 set_current_state(TASK_INTERRUPTIBLE);
42986 - data = atomic_xchg(&lis3->count, 0);
42987 + data = atomic_xchg_unchecked(&lis3->count, 0);
42988 if (data)
42989 break;
42990
42991 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
42992 struct lis3lv02d, miscdev);
42993
42994 poll_wait(file, &lis3->misc_wait, wait);
42995 - if (atomic_read(&lis3->count))
42996 + if (atomic_read_unchecked(&lis3->count))
42997 return POLLIN | POLLRDNORM;
42998 return 0;
42999 }
43000 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43001 index c439c82..1f20f57 100644
43002 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43003 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43004 @@ -297,7 +297,7 @@ struct lis3lv02d {
43005 struct input_polled_dev *idev; /* input device */
43006 struct platform_device *pdev; /* platform device */
43007 struct regulator_bulk_data regulators[2];
43008 - atomic_t count; /* interrupt count after last read */
43009 + atomic_unchecked_t count; /* interrupt count after last read */
43010 union axis_conversion ac; /* hw -> logical axis */
43011 int mapped_btns[3];
43012
43013 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43014 index 2f30bad..c4c13d0 100644
43015 --- a/drivers/misc/sgi-gru/gruhandles.c
43016 +++ b/drivers/misc/sgi-gru/gruhandles.c
43017 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43018 unsigned long nsec;
43019
43020 nsec = CLKS2NSEC(clks);
43021 - atomic_long_inc(&mcs_op_statistics[op].count);
43022 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43023 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43024 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43025 if (mcs_op_statistics[op].max < nsec)
43026 mcs_op_statistics[op].max = nsec;
43027 }
43028 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43029 index 4f76359..cdfcb2e 100644
43030 --- a/drivers/misc/sgi-gru/gruprocfs.c
43031 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43032 @@ -32,9 +32,9 @@
43033
43034 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43035
43036 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43037 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43038 {
43039 - unsigned long val = atomic_long_read(v);
43040 + unsigned long val = atomic_long_read_unchecked(v);
43041
43042 seq_printf(s, "%16lu %s\n", val, id);
43043 }
43044 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43045
43046 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43047 for (op = 0; op < mcsop_last; op++) {
43048 - count = atomic_long_read(&mcs_op_statistics[op].count);
43049 - total = atomic_long_read(&mcs_op_statistics[op].total);
43050 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43051 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43052 max = mcs_op_statistics[op].max;
43053 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43054 count ? total / count : 0, max);
43055 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43056 index 5c3ce24..4915ccb 100644
43057 --- a/drivers/misc/sgi-gru/grutables.h
43058 +++ b/drivers/misc/sgi-gru/grutables.h
43059 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43060 * GRU statistics.
43061 */
43062 struct gru_stats_s {
43063 - atomic_long_t vdata_alloc;
43064 - atomic_long_t vdata_free;
43065 - atomic_long_t gts_alloc;
43066 - atomic_long_t gts_free;
43067 - atomic_long_t gms_alloc;
43068 - atomic_long_t gms_free;
43069 - atomic_long_t gts_double_allocate;
43070 - atomic_long_t assign_context;
43071 - atomic_long_t assign_context_failed;
43072 - atomic_long_t free_context;
43073 - atomic_long_t load_user_context;
43074 - atomic_long_t load_kernel_context;
43075 - atomic_long_t lock_kernel_context;
43076 - atomic_long_t unlock_kernel_context;
43077 - atomic_long_t steal_user_context;
43078 - atomic_long_t steal_kernel_context;
43079 - atomic_long_t steal_context_failed;
43080 - atomic_long_t nopfn;
43081 - atomic_long_t asid_new;
43082 - atomic_long_t asid_next;
43083 - atomic_long_t asid_wrap;
43084 - atomic_long_t asid_reuse;
43085 - atomic_long_t intr;
43086 - atomic_long_t intr_cbr;
43087 - atomic_long_t intr_tfh;
43088 - atomic_long_t intr_spurious;
43089 - atomic_long_t intr_mm_lock_failed;
43090 - atomic_long_t call_os;
43091 - atomic_long_t call_os_wait_queue;
43092 - atomic_long_t user_flush_tlb;
43093 - atomic_long_t user_unload_context;
43094 - atomic_long_t user_exception;
43095 - atomic_long_t set_context_option;
43096 - atomic_long_t check_context_retarget_intr;
43097 - atomic_long_t check_context_unload;
43098 - atomic_long_t tlb_dropin;
43099 - atomic_long_t tlb_preload_page;
43100 - atomic_long_t tlb_dropin_fail_no_asid;
43101 - atomic_long_t tlb_dropin_fail_upm;
43102 - atomic_long_t tlb_dropin_fail_invalid;
43103 - atomic_long_t tlb_dropin_fail_range_active;
43104 - atomic_long_t tlb_dropin_fail_idle;
43105 - atomic_long_t tlb_dropin_fail_fmm;
43106 - atomic_long_t tlb_dropin_fail_no_exception;
43107 - atomic_long_t tfh_stale_on_fault;
43108 - atomic_long_t mmu_invalidate_range;
43109 - atomic_long_t mmu_invalidate_page;
43110 - atomic_long_t flush_tlb;
43111 - atomic_long_t flush_tlb_gru;
43112 - atomic_long_t flush_tlb_gru_tgh;
43113 - atomic_long_t flush_tlb_gru_zero_asid;
43114 + atomic_long_unchecked_t vdata_alloc;
43115 + atomic_long_unchecked_t vdata_free;
43116 + atomic_long_unchecked_t gts_alloc;
43117 + atomic_long_unchecked_t gts_free;
43118 + atomic_long_unchecked_t gms_alloc;
43119 + atomic_long_unchecked_t gms_free;
43120 + atomic_long_unchecked_t gts_double_allocate;
43121 + atomic_long_unchecked_t assign_context;
43122 + atomic_long_unchecked_t assign_context_failed;
43123 + atomic_long_unchecked_t free_context;
43124 + atomic_long_unchecked_t load_user_context;
43125 + atomic_long_unchecked_t load_kernel_context;
43126 + atomic_long_unchecked_t lock_kernel_context;
43127 + atomic_long_unchecked_t unlock_kernel_context;
43128 + atomic_long_unchecked_t steal_user_context;
43129 + atomic_long_unchecked_t steal_kernel_context;
43130 + atomic_long_unchecked_t steal_context_failed;
43131 + atomic_long_unchecked_t nopfn;
43132 + atomic_long_unchecked_t asid_new;
43133 + atomic_long_unchecked_t asid_next;
43134 + atomic_long_unchecked_t asid_wrap;
43135 + atomic_long_unchecked_t asid_reuse;
43136 + atomic_long_unchecked_t intr;
43137 + atomic_long_unchecked_t intr_cbr;
43138 + atomic_long_unchecked_t intr_tfh;
43139 + atomic_long_unchecked_t intr_spurious;
43140 + atomic_long_unchecked_t intr_mm_lock_failed;
43141 + atomic_long_unchecked_t call_os;
43142 + atomic_long_unchecked_t call_os_wait_queue;
43143 + atomic_long_unchecked_t user_flush_tlb;
43144 + atomic_long_unchecked_t user_unload_context;
43145 + atomic_long_unchecked_t user_exception;
43146 + atomic_long_unchecked_t set_context_option;
43147 + atomic_long_unchecked_t check_context_retarget_intr;
43148 + atomic_long_unchecked_t check_context_unload;
43149 + atomic_long_unchecked_t tlb_dropin;
43150 + atomic_long_unchecked_t tlb_preload_page;
43151 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43152 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43153 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43154 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43155 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43156 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43157 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43158 + atomic_long_unchecked_t tfh_stale_on_fault;
43159 + atomic_long_unchecked_t mmu_invalidate_range;
43160 + atomic_long_unchecked_t mmu_invalidate_page;
43161 + atomic_long_unchecked_t flush_tlb;
43162 + atomic_long_unchecked_t flush_tlb_gru;
43163 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43164 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43165
43166 - atomic_long_t copy_gpa;
43167 - atomic_long_t read_gpa;
43168 + atomic_long_unchecked_t copy_gpa;
43169 + atomic_long_unchecked_t read_gpa;
43170
43171 - atomic_long_t mesq_receive;
43172 - atomic_long_t mesq_receive_none;
43173 - atomic_long_t mesq_send;
43174 - atomic_long_t mesq_send_failed;
43175 - atomic_long_t mesq_noop;
43176 - atomic_long_t mesq_send_unexpected_error;
43177 - atomic_long_t mesq_send_lb_overflow;
43178 - atomic_long_t mesq_send_qlimit_reached;
43179 - atomic_long_t mesq_send_amo_nacked;
43180 - atomic_long_t mesq_send_put_nacked;
43181 - atomic_long_t mesq_page_overflow;
43182 - atomic_long_t mesq_qf_locked;
43183 - atomic_long_t mesq_qf_noop_not_full;
43184 - atomic_long_t mesq_qf_switch_head_failed;
43185 - atomic_long_t mesq_qf_unexpected_error;
43186 - atomic_long_t mesq_noop_unexpected_error;
43187 - atomic_long_t mesq_noop_lb_overflow;
43188 - atomic_long_t mesq_noop_qlimit_reached;
43189 - atomic_long_t mesq_noop_amo_nacked;
43190 - atomic_long_t mesq_noop_put_nacked;
43191 - atomic_long_t mesq_noop_page_overflow;
43192 + atomic_long_unchecked_t mesq_receive;
43193 + atomic_long_unchecked_t mesq_receive_none;
43194 + atomic_long_unchecked_t mesq_send;
43195 + atomic_long_unchecked_t mesq_send_failed;
43196 + atomic_long_unchecked_t mesq_noop;
43197 + atomic_long_unchecked_t mesq_send_unexpected_error;
43198 + atomic_long_unchecked_t mesq_send_lb_overflow;
43199 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43200 + atomic_long_unchecked_t mesq_send_amo_nacked;
43201 + atomic_long_unchecked_t mesq_send_put_nacked;
43202 + atomic_long_unchecked_t mesq_page_overflow;
43203 + atomic_long_unchecked_t mesq_qf_locked;
43204 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43205 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43206 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43207 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43208 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43209 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43210 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43211 + atomic_long_unchecked_t mesq_noop_put_nacked;
43212 + atomic_long_unchecked_t mesq_noop_page_overflow;
43213
43214 };
43215
43216 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43217 tghop_invalidate, mcsop_last};
43218
43219 struct mcs_op_statistic {
43220 - atomic_long_t count;
43221 - atomic_long_t total;
43222 + atomic_long_unchecked_t count;
43223 + atomic_long_unchecked_t total;
43224 unsigned long max;
43225 };
43226
43227 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43228
43229 #define STAT(id) do { \
43230 if (gru_options & OPT_STATS) \
43231 - atomic_long_inc(&gru_stats.id); \
43232 + atomic_long_inc_unchecked(&gru_stats.id); \
43233 } while (0)
43234
43235 #ifdef CONFIG_SGI_GRU_DEBUG
43236 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43237 index c862cd4..0d176fe 100644
43238 --- a/drivers/misc/sgi-xp/xp.h
43239 +++ b/drivers/misc/sgi-xp/xp.h
43240 @@ -288,7 +288,7 @@ struct xpc_interface {
43241 xpc_notify_func, void *);
43242 void (*received) (short, int, void *);
43243 enum xp_retval (*partid_to_nasids) (short, void *);
43244 -};
43245 +} __no_const;
43246
43247 extern struct xpc_interface xpc_interface;
43248
43249 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43250 index b94d5f7..7f494c5 100644
43251 --- a/drivers/misc/sgi-xp/xpc.h
43252 +++ b/drivers/misc/sgi-xp/xpc.h
43253 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43254 void (*received_payload) (struct xpc_channel *, void *);
43255 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43256 };
43257 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43258
43259 /* struct xpc_partition act_state values (for XPC HB) */
43260
43261 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43262 /* found in xpc_main.c */
43263 extern struct device *xpc_part;
43264 extern struct device *xpc_chan;
43265 -extern struct xpc_arch_operations xpc_arch_ops;
43266 +extern xpc_arch_operations_no_const xpc_arch_ops;
43267 extern int xpc_disengage_timelimit;
43268 extern int xpc_disengage_timedout;
43269 extern int xpc_activate_IRQ_rcvd;
43270 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43271 index 82dc574..8539ab2 100644
43272 --- a/drivers/misc/sgi-xp/xpc_main.c
43273 +++ b/drivers/misc/sgi-xp/xpc_main.c
43274 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43275 .notifier_call = xpc_system_die,
43276 };
43277
43278 -struct xpc_arch_operations xpc_arch_ops;
43279 +xpc_arch_operations_no_const xpc_arch_ops;
43280
43281 /*
43282 * Timer function to enforce the timelimit on the partition disengage.
43283 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43284
43285 if (((die_args->trapnr == X86_TRAP_MF) ||
43286 (die_args->trapnr == X86_TRAP_XF)) &&
43287 - !user_mode_vm(die_args->regs))
43288 + !user_mode(die_args->regs))
43289 xpc_die_deactivate();
43290
43291 break;
43292 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43293 index ef18348..1b53cf0 100644
43294 --- a/drivers/mmc/core/mmc_ops.c
43295 +++ b/drivers/mmc/core/mmc_ops.c
43296 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43297 void *data_buf;
43298 int is_on_stack;
43299
43300 - is_on_stack = object_is_on_stack(buf);
43301 + is_on_stack = object_starts_on_stack(buf);
43302 if (is_on_stack) {
43303 /*
43304 * dma onto stack is unsafe/nonportable, but callers to this
43305 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43306 index 81b2994..dce857e 100644
43307 --- a/drivers/mmc/host/dw_mmc.h
43308 +++ b/drivers/mmc/host/dw_mmc.h
43309 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43310 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43311 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43312 int (*parse_dt)(struct dw_mci *host);
43313 -};
43314 +} __do_const;
43315 #endif /* _DW_MMC_H_ */
43316 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43317 index c3785ed..1984c44 100644
43318 --- a/drivers/mmc/host/mmci.c
43319 +++ b/drivers/mmc/host/mmci.c
43320 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43321 }
43322
43323 if (variant->busy_detect) {
43324 - mmci_ops.card_busy = mmci_card_busy;
43325 + pax_open_kernel();
43326 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43327 + pax_close_kernel();
43328 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43329 }
43330
43331 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43332 index 6debda9..2ba7427 100644
43333 --- a/drivers/mmc/host/sdhci-s3c.c
43334 +++ b/drivers/mmc/host/sdhci-s3c.c
43335 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43336 * we can use overriding functions instead of default.
43337 */
43338 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43339 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43340 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43341 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43342 + pax_open_kernel();
43343 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43344 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43345 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43346 + pax_close_kernel();
43347 }
43348
43349 /* It supports additional host capabilities if needed */
43350 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43351 index 096993f..f02c23b 100644
43352 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43353 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43354 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43355 size_t totlen = 0, thislen;
43356 int ret = 0;
43357 size_t buflen = 0;
43358 - static char *buffer;
43359 + char *buffer;
43360
43361 if (!ECCBUF_SIZE) {
43362 /* We should fall back to a general writev implementation.
43363 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43364 index 2ed2bb3..2d0b82e 100644
43365 --- a/drivers/mtd/nand/denali.c
43366 +++ b/drivers/mtd/nand/denali.c
43367 @@ -24,6 +24,7 @@
43368 #include <linux/slab.h>
43369 #include <linux/mtd/mtd.h>
43370 #include <linux/module.h>
43371 +#include <linux/slab.h>
43372
43373 #include "denali.h"
43374
43375 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43376 index 51b9d6a..52af9a7 100644
43377 --- a/drivers/mtd/nftlmount.c
43378 +++ b/drivers/mtd/nftlmount.c
43379 @@ -24,6 +24,7 @@
43380 #include <asm/errno.h>
43381 #include <linux/delay.h>
43382 #include <linux/slab.h>
43383 +#include <linux/sched.h>
43384 #include <linux/mtd/mtd.h>
43385 #include <linux/mtd/nand.h>
43386 #include <linux/mtd/nftl.h>
43387 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43388 index 4b8e895..6b3c498 100644
43389 --- a/drivers/mtd/sm_ftl.c
43390 +++ b/drivers/mtd/sm_ftl.c
43391 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43392 #define SM_CIS_VENDOR_OFFSET 0x59
43393 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43394 {
43395 - struct attribute_group *attr_group;
43396 + attribute_group_no_const *attr_group;
43397 struct attribute **attributes;
43398 struct sm_sysfs_attribute *vendor_attribute;
43399
43400 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43401 index e883bfe..e51a1ec 100644
43402 --- a/drivers/net/bonding/bond_main.c
43403 +++ b/drivers/net/bonding/bond_main.c
43404 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
43405 return tx_queues;
43406 }
43407
43408 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43409 +static struct rtnl_link_ops bond_link_ops = {
43410 .kind = "bond",
43411 .priv_size = sizeof(struct bonding),
43412 .setup = bond_setup,
43413 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
43414
43415 bond_destroy_debugfs();
43416
43417 - rtnl_link_unregister(&bond_link_ops);
43418 unregister_pernet_subsys(&bond_net_ops);
43419 + rtnl_link_unregister(&bond_link_ops);
43420
43421 #ifdef CONFIG_NET_POLL_CONTROLLER
43422 /*
43423 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43424 index f92f001..0b2f9bf 100644
43425 --- a/drivers/net/ethernet/8390/ax88796.c
43426 +++ b/drivers/net/ethernet/8390/ax88796.c
43427 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43428 if (ax->plat->reg_offsets)
43429 ei_local->reg_offset = ax->plat->reg_offsets;
43430 else {
43431 + resource_size_t _mem_size = mem_size;
43432 + do_div(_mem_size, 0x18);
43433 ei_local->reg_offset = ax->reg_offsets;
43434 for (ret = 0; ret < 0x18; ret++)
43435 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43436 + ax->reg_offsets[ret] = _mem_size * ret;
43437 }
43438
43439 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43440 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43441 index da8fcaa..f4b5d3b 100644
43442 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43443 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43444 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43445 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43446 {
43447 /* RX_MODE controlling object */
43448 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43449 + bnx2x_init_rx_mode_obj(bp);
43450
43451 /* multicast configuration controlling object */
43452 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43453 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43454 index 9fbeee5..5e3e37a 100644
43455 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43456 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43457 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43458 return rc;
43459 }
43460
43461 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43462 - struct bnx2x_rx_mode_obj *o)
43463 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43464 {
43465 if (CHIP_IS_E1x(bp)) {
43466 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43467 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43468 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43469 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43470 } else {
43471 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43472 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43473 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43474 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43475 }
43476 }
43477
43478 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43479 index 658f4e3..15074a6 100644
43480 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43481 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43482 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43483
43484 /********************* RX MODE ****************/
43485
43486 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43487 - struct bnx2x_rx_mode_obj *o);
43488 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43489
43490 /**
43491 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43492 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43493 index 7025780..e55a71c 100644
43494 --- a/drivers/net/ethernet/broadcom/tg3.h
43495 +++ b/drivers/net/ethernet/broadcom/tg3.h
43496 @@ -147,6 +147,7 @@
43497 #define CHIPREV_ID_5750_A0 0x4000
43498 #define CHIPREV_ID_5750_A1 0x4001
43499 #define CHIPREV_ID_5750_A3 0x4003
43500 +#define CHIPREV_ID_5750_C1 0x4201
43501 #define CHIPREV_ID_5750_C2 0x4202
43502 #define CHIPREV_ID_5752_A0_HW 0x5000
43503 #define CHIPREV_ID_5752_A0 0x6000
43504 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43505 index 8cffcdf..aadf043 100644
43506 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43507 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43508 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43509 */
43510 struct l2t_skb_cb {
43511 arp_failure_handler_func arp_failure_handler;
43512 -};
43513 +} __no_const;
43514
43515 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43516
43517 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43518 index c73cabd..cd278b1 100644
43519 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43520 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43521 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43522
43523 int i;
43524 struct adapter *ap = netdev2adap(dev);
43525 - static const unsigned int *reg_ranges;
43526 + const unsigned int *reg_ranges;
43527 int arr_size = 0, buf_size = 0;
43528
43529 if (is_t4(ap->chip)) {
43530 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43531 index 263b92c..f05134b 100644
43532 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43533 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43534 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43535 for (i=0; i<ETH_ALEN; i++) {
43536 tmp.addr[i] = dev->dev_addr[i];
43537 }
43538 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43539 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43540 break;
43541
43542 case DE4X5_SET_HWADDR: /* Set the hardware address */
43543 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43544 spin_lock_irqsave(&lp->lock, flags);
43545 memcpy(&statbuf, &lp->pktStats, ioc->len);
43546 spin_unlock_irqrestore(&lp->lock, flags);
43547 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43548 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43549 return -EFAULT;
43550 break;
43551 }
43552 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43553 index 2c38cc4..0323f6e 100644
43554 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43555 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43556 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43557
43558 if (wrapped)
43559 newacc += 65536;
43560 - ACCESS_ONCE(*acc) = newacc;
43561 + ACCESS_ONCE_RW(*acc) = newacc;
43562 }
43563
43564 static void populate_erx_stats(struct be_adapter *adapter,
43565 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43566 index 212f44b..fb69959 100644
43567 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43568 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43569 @@ -31,6 +31,8 @@
43570 #include <linux/netdevice.h>
43571 #include <linux/phy.h>
43572 #include <linux/platform_device.h>
43573 +#include <linux/interrupt.h>
43574 +#include <linux/irqreturn.h>
43575 #include <net/ip.h>
43576
43577 #include "ftgmac100.h"
43578 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43579 index 8be5b40..081bc1b 100644
43580 --- a/drivers/net/ethernet/faraday/ftmac100.c
43581 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43582 @@ -31,6 +31,8 @@
43583 #include <linux/module.h>
43584 #include <linux/netdevice.h>
43585 #include <linux/platform_device.h>
43586 +#include <linux/interrupt.h>
43587 +#include <linux/irqreturn.h>
43588
43589 #include "ftmac100.h"
43590
43591 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43592 index 5184e2a..acb28c3 100644
43593 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43594 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43595 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43596 }
43597
43598 /* update the base incval used to calculate frequency adjustment */
43599 - ACCESS_ONCE(adapter->base_incval) = incval;
43600 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43601 smp_mb();
43602
43603 /* need lock to prevent incorrect read while modifying cyclecounter */
43604 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43605 index fbe5363..266b4e3 100644
43606 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
43607 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43608 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43609 struct __vxge_hw_fifo *fifo;
43610 struct vxge_hw_fifo_config *config;
43611 u32 txdl_size, txdl_per_memblock;
43612 - struct vxge_hw_mempool_cbs fifo_mp_callback;
43613 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
43614 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
43615 + };
43616 +
43617 struct __vxge_hw_virtualpath *vpath;
43618
43619 if ((vp == NULL) || (attr == NULL)) {
43620 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43621 goto exit;
43622 }
43623
43624 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
43625 -
43626 fifo->mempool =
43627 __vxge_hw_mempool_create(vpath->hldev,
43628 fifo->config->memblock_size,
43629 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43630 index f09e787..f3916a8 100644
43631 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43632 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43633 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
43634
43635 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
43636 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
43637 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43638 + pax_open_kernel();
43639 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43640 + pax_close_kernel();
43641 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43642 } else {
43643 return -EIO;
43644 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43645 index 0248a4c..9648d96 100644
43646 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43647 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43648 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
43649 case QLCNIC_NON_PRIV_FUNC:
43650 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
43651 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43652 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43653 + pax_open_kernel();
43654 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43655 + pax_close_kernel();
43656 break;
43657 case QLCNIC_PRIV_FUNC:
43658 ahw->op_mode = QLCNIC_PRIV_FUNC;
43659 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
43660 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43661 + pax_open_kernel();
43662 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43663 + pax_close_kernel();
43664 break;
43665 case QLCNIC_MGMT_FUNC:
43666 ahw->op_mode = QLCNIC_MGMT_FUNC;
43667 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43668 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43669 + pax_open_kernel();
43670 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43671 + pax_close_kernel();
43672 break;
43673 default:
43674 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
43675 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43676 index 1551360..ed6510f 100644
43677 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43678 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43679 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
43680 struct qlcnic_dump_entry *entry;
43681 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
43682 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
43683 - static const struct qlcnic_dump_operations *fw_dump_ops;
43684 + const struct qlcnic_dump_operations *fw_dump_ops;
43685 struct device *dev = &adapter->pdev->dev;
43686 struct qlcnic_hardware_context *ahw;
43687 void *temp_buffer;
43688 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
43689 index 3397cee..101f8fa 100644
43690 --- a/drivers/net/ethernet/realtek/r8169.c
43691 +++ b/drivers/net/ethernet/realtek/r8169.c
43692 @@ -759,22 +759,22 @@ struct rtl8169_private {
43693 struct mdio_ops {
43694 void (*write)(struct rtl8169_private *, int, int);
43695 int (*read)(struct rtl8169_private *, int);
43696 - } mdio_ops;
43697 + } __no_const mdio_ops;
43698
43699 struct pll_power_ops {
43700 void (*down)(struct rtl8169_private *);
43701 void (*up)(struct rtl8169_private *);
43702 - } pll_power_ops;
43703 + } __no_const pll_power_ops;
43704
43705 struct jumbo_ops {
43706 void (*enable)(struct rtl8169_private *);
43707 void (*disable)(struct rtl8169_private *);
43708 - } jumbo_ops;
43709 + } __no_const jumbo_ops;
43710
43711 struct csi_ops {
43712 void (*write)(struct rtl8169_private *, int, int);
43713 u32 (*read)(struct rtl8169_private *, int);
43714 - } csi_ops;
43715 + } __no_const csi_ops;
43716
43717 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
43718 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
43719 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
43720 index 03acf57..e1251ff 100644
43721 --- a/drivers/net/ethernet/sfc/ptp.c
43722 +++ b/drivers/net/ethernet/sfc/ptp.c
43723 @@ -539,7 +539,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
43724 ptp->start.dma_addr);
43725
43726 /* Clear flag that signals MC ready */
43727 - ACCESS_ONCE(*start) = 0;
43728 + ACCESS_ONCE_RW(*start) = 0;
43729 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
43730 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
43731 EFX_BUG_ON_PARANOID(rc);
43732 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43733 index 50617c5..b13724c 100644
43734 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43735 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43736 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
43737
43738 writel(value, ioaddr + MMC_CNTRL);
43739
43740 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43741 - MMC_CNTRL, value);
43742 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43743 +// MMC_CNTRL, value);
43744 }
43745
43746 /* To mask all all interrupts.*/
43747 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
43748 index e6fe0d8..2b7d752 100644
43749 --- a/drivers/net/hyperv/hyperv_net.h
43750 +++ b/drivers/net/hyperv/hyperv_net.h
43751 @@ -101,7 +101,7 @@ struct rndis_device {
43752
43753 enum rndis_device_state state;
43754 bool link_state;
43755 - atomic_t new_req_id;
43756 + atomic_unchecked_t new_req_id;
43757
43758 spinlock_t request_lock;
43759 struct list_head req_list;
43760 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
43761 index 0775f0a..d4fb316 100644
43762 --- a/drivers/net/hyperv/rndis_filter.c
43763 +++ b/drivers/net/hyperv/rndis_filter.c
43764 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
43765 * template
43766 */
43767 set = &rndis_msg->msg.set_req;
43768 - set->req_id = atomic_inc_return(&dev->new_req_id);
43769 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43770
43771 /* Add to the request list */
43772 spin_lock_irqsave(&dev->request_lock, flags);
43773 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
43774
43775 /* Setup the rndis set */
43776 halt = &request->request_msg.msg.halt_req;
43777 - halt->req_id = atomic_inc_return(&dev->new_req_id);
43778 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43779
43780 /* Ignore return since this msg is optional. */
43781 rndis_filter_send_request(dev, request);
43782 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
43783 index bf0d55e..82bcfbd1 100644
43784 --- a/drivers/net/ieee802154/fakehard.c
43785 +++ b/drivers/net/ieee802154/fakehard.c
43786 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
43787 phy->transmit_power = 0xbf;
43788
43789 dev->netdev_ops = &fake_ops;
43790 - dev->ml_priv = &fake_mlme;
43791 + dev->ml_priv = (void *)&fake_mlme;
43792
43793 priv = netdev_priv(dev);
43794 priv->phy = phy;
43795 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
43796 index 9bf46bd..bfdaa84 100644
43797 --- a/drivers/net/macvlan.c
43798 +++ b/drivers/net/macvlan.c
43799 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
43800 int macvlan_link_register(struct rtnl_link_ops *ops)
43801 {
43802 /* common fields */
43803 - ops->priv_size = sizeof(struct macvlan_dev);
43804 - ops->validate = macvlan_validate;
43805 - ops->maxtype = IFLA_MACVLAN_MAX;
43806 - ops->policy = macvlan_policy;
43807 - ops->changelink = macvlan_changelink;
43808 - ops->get_size = macvlan_get_size;
43809 - ops->fill_info = macvlan_fill_info;
43810 + pax_open_kernel();
43811 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
43812 + *(void **)&ops->validate = macvlan_validate;
43813 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
43814 + *(const void **)&ops->policy = macvlan_policy;
43815 + *(void **)&ops->changelink = macvlan_changelink;
43816 + *(void **)&ops->get_size = macvlan_get_size;
43817 + *(void **)&ops->fill_info = macvlan_fill_info;
43818 + pax_close_kernel();
43819
43820 return rtnl_link_register(ops);
43821 };
43822 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
43823 return NOTIFY_DONE;
43824 }
43825
43826 -static struct notifier_block macvlan_notifier_block __read_mostly = {
43827 +static struct notifier_block macvlan_notifier_block = {
43828 .notifier_call = macvlan_device_event,
43829 };
43830
43831 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
43832 index 9dccb1e..19fd4c9 100644
43833 --- a/drivers/net/macvtap.c
43834 +++ b/drivers/net/macvtap.c
43835 @@ -1183,7 +1183,7 @@ static int macvtap_device_event(struct notifier_block *unused,
43836 return NOTIFY_DONE;
43837 }
43838
43839 -static struct notifier_block macvtap_notifier_block __read_mostly = {
43840 +static struct notifier_block macvtap_notifier_block = {
43841 .notifier_call = macvtap_device_event,
43842 };
43843
43844 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
43845 index daec9b0..6428fcb 100644
43846 --- a/drivers/net/phy/mdio-bitbang.c
43847 +++ b/drivers/net/phy/mdio-bitbang.c
43848 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
43849 struct mdiobb_ctrl *ctrl = bus->priv;
43850
43851 module_put(ctrl->ops->owner);
43852 + mdiobus_unregister(bus);
43853 mdiobus_free(bus);
43854 }
43855 EXPORT_SYMBOL(free_mdio_bitbang);
43856 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
43857 index 72ff14b..11d442d 100644
43858 --- a/drivers/net/ppp/ppp_generic.c
43859 +++ b/drivers/net/ppp/ppp_generic.c
43860 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43861 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
43862 struct ppp_stats stats;
43863 struct ppp_comp_stats cstats;
43864 - char *vers;
43865
43866 switch (cmd) {
43867 case SIOCGPPPSTATS:
43868 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43869 break;
43870
43871 case SIOCGPPPVER:
43872 - vers = PPP_VERSION;
43873 - if (copy_to_user(addr, vers, strlen(vers) + 1))
43874 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
43875 break;
43876 err = 0;
43877 break;
43878 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
43879 index 1252d9c..80e660b 100644
43880 --- a/drivers/net/slip/slhc.c
43881 +++ b/drivers/net/slip/slhc.c
43882 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
43883 register struct tcphdr *thp;
43884 register struct iphdr *ip;
43885 register struct cstate *cs;
43886 - int len, hdrlen;
43887 + long len, hdrlen;
43888 unsigned char *cp = icp;
43889
43890 /* We've got a compressed packet; read the change byte */
43891 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
43892 index 50e43e6..e1a5807 100644
43893 --- a/drivers/net/team/team.c
43894 +++ b/drivers/net/team/team.c
43895 @@ -2869,7 +2869,7 @@ static int team_device_event(struct notifier_block *unused,
43896 return NOTIFY_DONE;
43897 }
43898
43899 -static struct notifier_block team_notifier_block __read_mostly = {
43900 +static struct notifier_block team_notifier_block = {
43901 .notifier_call = team_device_event,
43902 };
43903
43904 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
43905 index 7cb105c..11214ff 100644
43906 --- a/drivers/net/tun.c
43907 +++ b/drivers/net/tun.c
43908 @@ -1826,7 +1826,7 @@ unlock:
43909 }
43910
43911 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43912 - unsigned long arg, int ifreq_len)
43913 + unsigned long arg, size_t ifreq_len)
43914 {
43915 struct tun_file *tfile = file->private_data;
43916 struct tun_struct *tun;
43917 @@ -1839,6 +1839,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43918 unsigned int ifindex;
43919 int ret;
43920
43921 + if (ifreq_len > sizeof ifr)
43922 + return -EFAULT;
43923 +
43924 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
43925 if (copy_from_user(&ifr, argp, ifreq_len))
43926 return -EFAULT;
43927 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
43928 index 86292e6..8d34433 100644
43929 --- a/drivers/net/usb/hso.c
43930 +++ b/drivers/net/usb/hso.c
43931 @@ -71,7 +71,7 @@
43932 #include <asm/byteorder.h>
43933 #include <linux/serial_core.h>
43934 #include <linux/serial.h>
43935 -
43936 +#include <asm/local.h>
43937
43938 #define MOD_AUTHOR "Option Wireless"
43939 #define MOD_DESCRIPTION "USB High Speed Option driver"
43940 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
43941 struct urb *urb;
43942
43943 urb = serial->rx_urb[0];
43944 - if (serial->port.count > 0) {
43945 + if (atomic_read(&serial->port.count) > 0) {
43946 count = put_rxbuf_data(urb, serial);
43947 if (count == -1)
43948 return;
43949 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
43950 DUMP1(urb->transfer_buffer, urb->actual_length);
43951
43952 /* Anyone listening? */
43953 - if (serial->port.count == 0)
43954 + if (atomic_read(&serial->port.count) == 0)
43955 return;
43956
43957 if (status == 0) {
43958 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
43959 tty_port_tty_set(&serial->port, tty);
43960
43961 /* check for port already opened, if not set the termios */
43962 - serial->port.count++;
43963 - if (serial->port.count == 1) {
43964 + if (atomic_inc_return(&serial->port.count) == 1) {
43965 serial->rx_state = RX_IDLE;
43966 /* Force default termio settings */
43967 _hso_serial_set_termios(tty, NULL);
43968 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
43969 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
43970 if (result) {
43971 hso_stop_serial_device(serial->parent);
43972 - serial->port.count--;
43973 + atomic_dec(&serial->port.count);
43974 kref_put(&serial->parent->ref, hso_serial_ref_free);
43975 }
43976 } else {
43977 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
43978
43979 /* reset the rts and dtr */
43980 /* do the actual close */
43981 - serial->port.count--;
43982 + atomic_dec(&serial->port.count);
43983
43984 - if (serial->port.count <= 0) {
43985 - serial->port.count = 0;
43986 + if (atomic_read(&serial->port.count) <= 0) {
43987 + atomic_set(&serial->port.count, 0);
43988 tty_port_tty_set(&serial->port, NULL);
43989 if (!usb_gone)
43990 hso_stop_serial_device(serial->parent);
43991 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
43992
43993 /* the actual setup */
43994 spin_lock_irqsave(&serial->serial_lock, flags);
43995 - if (serial->port.count)
43996 + if (atomic_read(&serial->port.count))
43997 _hso_serial_set_termios(tty, old);
43998 else
43999 tty->termios = *old;
44000 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44001 D1("Pending read interrupt on port %d\n", i);
44002 spin_lock(&serial->serial_lock);
44003 if (serial->rx_state == RX_IDLE &&
44004 - serial->port.count > 0) {
44005 + atomic_read(&serial->port.count) > 0) {
44006 /* Setup and send a ctrl req read on
44007 * port i */
44008 if (!serial->rx_urb_filled[0]) {
44009 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44010 /* Start all serial ports */
44011 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44012 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44013 - if (dev2ser(serial_table[i])->port.count) {
44014 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44015 result =
44016 hso_start_serial_device(serial_table[i], GFP_NOIO);
44017 hso_kick_transmit(dev2ser(serial_table[i]));
44018 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44019 index a79e9d3..78cd4fa 100644
44020 --- a/drivers/net/usb/sierra_net.c
44021 +++ b/drivers/net/usb/sierra_net.c
44022 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44023 /* atomic counter partially included in MAC address to make sure 2 devices
44024 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44025 */
44026 -static atomic_t iface_counter = ATOMIC_INIT(0);
44027 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44028
44029 /*
44030 * SYNC Timer Delay definition used to set the expiry time
44031 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44032 dev->net->netdev_ops = &sierra_net_device_ops;
44033
44034 /* change MAC addr to include, ifacenum, and to be unique */
44035 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44036 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44037 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44038
44039 /* we will have to manufacture ethernet headers, prepare template */
44040 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44041 index 2ef5b62..6fa0ec3 100644
44042 --- a/drivers/net/vxlan.c
44043 +++ b/drivers/net/vxlan.c
44044 @@ -2615,7 +2615,7 @@ nla_put_failure:
44045 return -EMSGSIZE;
44046 }
44047
44048 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44049 +static struct rtnl_link_ops vxlan_link_ops = {
44050 .kind = "vxlan",
44051 .maxtype = IFLA_VXLAN_MAX,
44052 .policy = vxlan_policy,
44053 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44054 index 0b60295..b8bfa5b 100644
44055 --- a/drivers/net/wimax/i2400m/rx.c
44056 +++ b/drivers/net/wimax/i2400m/rx.c
44057 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44058 if (i2400m->rx_roq == NULL)
44059 goto error_roq_alloc;
44060
44061 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44062 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44063 GFP_KERNEL);
44064 if (rd == NULL) {
44065 result = -ENOMEM;
44066 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44067 index 7fe1964..7016de0 100644
44068 --- a/drivers/net/wireless/airo.c
44069 +++ b/drivers/net/wireless/airo.c
44070 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44071 struct airo_info *ai = dev->ml_priv;
44072 int ridcode;
44073 int enabled;
44074 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44075 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44076 unsigned char *iobuf;
44077
44078 /* Only super-user can write RIDs */
44079 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44080 index 34c8a33..3261fdc 100644
44081 --- a/drivers/net/wireless/at76c50x-usb.c
44082 +++ b/drivers/net/wireless/at76c50x-usb.c
44083 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44084 }
44085
44086 /* Convert timeout from the DFU status to jiffies */
44087 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44088 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44089 {
44090 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44091 | (s->poll_timeout[1] << 8)
44092 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44093 index ef3329e..c28ff5d 100644
44094 --- a/drivers/net/wireless/ath/ath10k/htc.c
44095 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44096 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44097 /* registered target arrival callback from the HIF layer */
44098 int ath10k_htc_init(struct ath10k *ar)
44099 {
44100 - struct ath10k_hif_cb htc_callbacks;
44101 + static struct ath10k_hif_cb htc_callbacks = {
44102 + .rx_completion = ath10k_htc_rx_completion_handler,
44103 + .tx_completion = ath10k_htc_tx_completion_handler,
44104 + };
44105 struct ath10k_htc_ep *ep = NULL;
44106 struct ath10k_htc *htc = &ar->htc;
44107
44108 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44109 ath10k_htc_reset_endpoint_states(htc);
44110
44111 /* setup HIF layer callbacks */
44112 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44113 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44114 htc->ar = ar;
44115
44116 /* Get HIF default pipe for HTC message exchange */
44117 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44118 index e1dd8c7..9f91b3f 100644
44119 --- a/drivers/net/wireless/ath/ath10k/htc.h
44120 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44121 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44122
44123 struct ath10k_htc_ops {
44124 void (*target_send_suspend_complete)(struct ath10k *ar);
44125 -};
44126 +} __no_const;
44127
44128 struct ath10k_htc_ep_ops {
44129 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44130 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44131 -};
44132 +} __no_const;
44133
44134 /* service connection information */
44135 struct ath10k_htc_svc_conn_req {
44136 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44137 index 8d78253..bebbb68 100644
44138 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44139 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44140 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44141 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44142 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44143
44144 - ACCESS_ONCE(ads->ds_link) = i->link;
44145 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44146 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44147 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44148
44149 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44150 ctl6 = SM(i->keytype, AR_EncrType);
44151 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44152
44153 if ((i->is_first || i->is_last) &&
44154 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44155 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44156 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44157 | set11nTries(i->rates, 1)
44158 | set11nTries(i->rates, 2)
44159 | set11nTries(i->rates, 3)
44160 | (i->dur_update ? AR_DurUpdateEna : 0)
44161 | SM(0, AR_BurstDur);
44162
44163 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44164 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44165 | set11nRate(i->rates, 1)
44166 | set11nRate(i->rates, 2)
44167 | set11nRate(i->rates, 3);
44168 } else {
44169 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44170 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44171 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44172 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44173 }
44174
44175 if (!i->is_first) {
44176 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44177 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44178 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44179 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44180 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44181 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44182 return;
44183 }
44184
44185 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44186 break;
44187 }
44188
44189 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44190 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44191 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44192 | SM(i->txpower, AR_XmitPower)
44193 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44194 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44195 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44196 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44197
44198 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44199 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44200 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44201 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44202
44203 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44204 return;
44205
44206 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44207 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44208 | set11nPktDurRTSCTS(i->rates, 1);
44209
44210 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44211 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44212 | set11nPktDurRTSCTS(i->rates, 3);
44213
44214 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44215 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44216 | set11nRateFlags(i->rates, 1)
44217 | set11nRateFlags(i->rates, 2)
44218 | set11nRateFlags(i->rates, 3)
44219 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44220 index f6c5c1b..6058354 100644
44221 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44222 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44223 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44224 (i->qcu << AR_TxQcuNum_S) | desc_len;
44225
44226 checksum += val;
44227 - ACCESS_ONCE(ads->info) = val;
44228 + ACCESS_ONCE_RW(ads->info) = val;
44229
44230 checksum += i->link;
44231 - ACCESS_ONCE(ads->link) = i->link;
44232 + ACCESS_ONCE_RW(ads->link) = i->link;
44233
44234 checksum += i->buf_addr[0];
44235 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44236 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44237 checksum += i->buf_addr[1];
44238 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44239 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44240 checksum += i->buf_addr[2];
44241 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44242 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44243 checksum += i->buf_addr[3];
44244 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44245 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44246
44247 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44248 - ACCESS_ONCE(ads->ctl3) = val;
44249 + ACCESS_ONCE_RW(ads->ctl3) = val;
44250 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44251 - ACCESS_ONCE(ads->ctl5) = val;
44252 + ACCESS_ONCE_RW(ads->ctl5) = val;
44253 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44254 - ACCESS_ONCE(ads->ctl7) = val;
44255 + ACCESS_ONCE_RW(ads->ctl7) = val;
44256 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44257 - ACCESS_ONCE(ads->ctl9) = val;
44258 + ACCESS_ONCE_RW(ads->ctl9) = val;
44259
44260 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44261 - ACCESS_ONCE(ads->ctl10) = checksum;
44262 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44263
44264 if (i->is_first || i->is_last) {
44265 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44266 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44267 | set11nTries(i->rates, 1)
44268 | set11nTries(i->rates, 2)
44269 | set11nTries(i->rates, 3)
44270 | (i->dur_update ? AR_DurUpdateEna : 0)
44271 | SM(0, AR_BurstDur);
44272
44273 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44274 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44275 | set11nRate(i->rates, 1)
44276 | set11nRate(i->rates, 2)
44277 | set11nRate(i->rates, 3);
44278 } else {
44279 - ACCESS_ONCE(ads->ctl13) = 0;
44280 - ACCESS_ONCE(ads->ctl14) = 0;
44281 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44282 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44283 }
44284
44285 ads->ctl20 = 0;
44286 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44287
44288 ctl17 = SM(i->keytype, AR_EncrType);
44289 if (!i->is_first) {
44290 - ACCESS_ONCE(ads->ctl11) = 0;
44291 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44292 - ACCESS_ONCE(ads->ctl15) = 0;
44293 - ACCESS_ONCE(ads->ctl16) = 0;
44294 - ACCESS_ONCE(ads->ctl17) = ctl17;
44295 - ACCESS_ONCE(ads->ctl18) = 0;
44296 - ACCESS_ONCE(ads->ctl19) = 0;
44297 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44298 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44299 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44300 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44301 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44302 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44303 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44304 return;
44305 }
44306
44307 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44308 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44309 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44310 | SM(i->txpower, AR_XmitPower)
44311 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44312 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44313 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44314 ctl12 |= SM(val, AR_PAPRDChainMask);
44315
44316 - ACCESS_ONCE(ads->ctl12) = ctl12;
44317 - ACCESS_ONCE(ads->ctl17) = ctl17;
44318 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44319 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44320
44321 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44322 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44323 | set11nPktDurRTSCTS(i->rates, 1);
44324
44325 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44326 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44327 | set11nPktDurRTSCTS(i->rates, 3);
44328
44329 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44330 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44331 | set11nRateFlags(i->rates, 1)
44332 | set11nRateFlags(i->rates, 2)
44333 | set11nRateFlags(i->rates, 3)
44334 | SM(i->rtscts_rate, AR_RTSCTSRate);
44335
44336 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44337 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44338 }
44339
44340 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44341 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44342 index 69a907b..91e071c 100644
44343 --- a/drivers/net/wireless/ath/ath9k/hw.h
44344 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44345 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
44346
44347 /* ANI */
44348 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44349 -};
44350 +} __no_const;
44351
44352 /**
44353 * struct ath_spec_scan - parameters for Atheros spectral scan
44354 @@ -729,7 +729,7 @@ struct ath_hw_ops {
44355 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
44356 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
44357 #endif
44358 -};
44359 +} __no_const;
44360
44361 struct ath_nf_limits {
44362 s16 max;
44363 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44364 index 92190da..f3a4c4c 100644
44365 --- a/drivers/net/wireless/b43/phy_lp.c
44366 +++ b/drivers/net/wireless/b43/phy_lp.c
44367 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44368 {
44369 struct ssb_bus *bus = dev->dev->sdev->bus;
44370
44371 - static const struct b206x_channel *chandata = NULL;
44372 + const struct b206x_channel *chandata = NULL;
44373 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44374 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44375 u16 old_comm15, scale;
44376 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44377 index 9581d07..84f6a76 100644
44378 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44379 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44380 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44381 */
44382 if (il3945_mod_params.disable_hw_scan) {
44383 D_INFO("Disabling hw_scan\n");
44384 - il3945_mac_ops.hw_scan = NULL;
44385 + pax_open_kernel();
44386 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44387 + pax_close_kernel();
44388 }
44389
44390 D_INFO("*** LOAD DRIVER ***\n");
44391 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44392 index d94f8ab..5b568c8 100644
44393 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44394 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44395 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44396 {
44397 struct iwl_priv *priv = file->private_data;
44398 char buf[64];
44399 - int buf_size;
44400 + size_t buf_size;
44401 u32 offset, len;
44402
44403 memset(buf, 0, sizeof(buf));
44404 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44405 struct iwl_priv *priv = file->private_data;
44406
44407 char buf[8];
44408 - int buf_size;
44409 + size_t buf_size;
44410 u32 reset_flag;
44411
44412 memset(buf, 0, sizeof(buf));
44413 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44414 {
44415 struct iwl_priv *priv = file->private_data;
44416 char buf[8];
44417 - int buf_size;
44418 + size_t buf_size;
44419 int ht40;
44420
44421 memset(buf, 0, sizeof(buf));
44422 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44423 {
44424 struct iwl_priv *priv = file->private_data;
44425 char buf[8];
44426 - int buf_size;
44427 + size_t buf_size;
44428 int value;
44429
44430 memset(buf, 0, sizeof(buf));
44431 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44432 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44433 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44434
44435 -static const char *fmt_value = " %-30s %10u\n";
44436 -static const char *fmt_hex = " %-30s 0x%02X\n";
44437 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44438 -static const char *fmt_header =
44439 +static const char fmt_value[] = " %-30s %10u\n";
44440 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44441 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44442 +static const char fmt_header[] =
44443 "%-32s current cumulative delta max\n";
44444
44445 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44446 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44447 {
44448 struct iwl_priv *priv = file->private_data;
44449 char buf[8];
44450 - int buf_size;
44451 + size_t buf_size;
44452 int clear;
44453
44454 memset(buf, 0, sizeof(buf));
44455 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44456 {
44457 struct iwl_priv *priv = file->private_data;
44458 char buf[8];
44459 - int buf_size;
44460 + size_t buf_size;
44461 int trace;
44462
44463 memset(buf, 0, sizeof(buf));
44464 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44465 {
44466 struct iwl_priv *priv = file->private_data;
44467 char buf[8];
44468 - int buf_size;
44469 + size_t buf_size;
44470 int missed;
44471
44472 memset(buf, 0, sizeof(buf));
44473 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44474
44475 struct iwl_priv *priv = file->private_data;
44476 char buf[8];
44477 - int buf_size;
44478 + size_t buf_size;
44479 int plcp;
44480
44481 memset(buf, 0, sizeof(buf));
44482 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44483
44484 struct iwl_priv *priv = file->private_data;
44485 char buf[8];
44486 - int buf_size;
44487 + size_t buf_size;
44488 int flush;
44489
44490 memset(buf, 0, sizeof(buf));
44491 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44492
44493 struct iwl_priv *priv = file->private_data;
44494 char buf[8];
44495 - int buf_size;
44496 + size_t buf_size;
44497 int rts;
44498
44499 if (!priv->cfg->ht_params)
44500 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44501 {
44502 struct iwl_priv *priv = file->private_data;
44503 char buf[8];
44504 - int buf_size;
44505 + size_t buf_size;
44506
44507 memset(buf, 0, sizeof(buf));
44508 buf_size = min(count, sizeof(buf) - 1);
44509 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44510 struct iwl_priv *priv = file->private_data;
44511 u32 event_log_flag;
44512 char buf[8];
44513 - int buf_size;
44514 + size_t buf_size;
44515
44516 /* check that the interface is up */
44517 if (!iwl_is_ready(priv))
44518 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44519 struct iwl_priv *priv = file->private_data;
44520 char buf[8];
44521 u32 calib_disabled;
44522 - int buf_size;
44523 + size_t buf_size;
44524
44525 memset(buf, 0, sizeof(buf));
44526 buf_size = min(count, sizeof(buf) - 1);
44527 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44528 index 7aad766..06addb4 100644
44529 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44530 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44531 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44532 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44533 {
44534 struct iwl_nvm_data *data = priv->nvm_data;
44535 - char *debug_msg;
44536 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44537
44538 if (data->sku_cap_11n_enable &&
44539 !priv->cfg->ht_params) {
44540 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44541 return -EINVAL;
44542 }
44543
44544 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44545 IWL_DEBUG_INFO(priv, debug_msg,
44546 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44547 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44548 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44549 index c3f904d..4cadf83 100644
44550 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44551 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44552 @@ -1252,7 +1252,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44553 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44554
44555 char buf[8];
44556 - int buf_size;
44557 + size_t buf_size;
44558 u32 reset_flag;
44559
44560 memset(buf, 0, sizeof(buf));
44561 @@ -1273,7 +1273,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44562 {
44563 struct iwl_trans *trans = file->private_data;
44564 char buf[8];
44565 - int buf_size;
44566 + size_t buf_size;
44567 int csr;
44568
44569 memset(buf, 0, sizeof(buf));
44570 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44571 index 2cd3f54..e936f90 100644
44572 --- a/drivers/net/wireless/mac80211_hwsim.c
44573 +++ b/drivers/net/wireless/mac80211_hwsim.c
44574 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
44575
44576 if (channels > 1) {
44577 hwsim_if_comb.num_different_channels = channels;
44578 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44579 - mac80211_hwsim_ops.cancel_hw_scan =
44580 - mac80211_hwsim_cancel_hw_scan;
44581 - mac80211_hwsim_ops.sw_scan_start = NULL;
44582 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44583 - mac80211_hwsim_ops.remain_on_channel =
44584 - mac80211_hwsim_roc;
44585 - mac80211_hwsim_ops.cancel_remain_on_channel =
44586 - mac80211_hwsim_croc;
44587 - mac80211_hwsim_ops.add_chanctx =
44588 - mac80211_hwsim_add_chanctx;
44589 - mac80211_hwsim_ops.remove_chanctx =
44590 - mac80211_hwsim_remove_chanctx;
44591 - mac80211_hwsim_ops.change_chanctx =
44592 - mac80211_hwsim_change_chanctx;
44593 - mac80211_hwsim_ops.assign_vif_chanctx =
44594 - mac80211_hwsim_assign_vif_chanctx;
44595 - mac80211_hwsim_ops.unassign_vif_chanctx =
44596 - mac80211_hwsim_unassign_vif_chanctx;
44597 + pax_open_kernel();
44598 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44599 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
44600 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
44601 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
44602 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
44603 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
44604 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
44605 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
44606 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
44607 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
44608 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
44609 + pax_close_kernel();
44610 }
44611
44612 spin_lock_init(&hwsim_radio_lock);
44613 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
44614 index 8169a85..7fa3b47 100644
44615 --- a/drivers/net/wireless/rndis_wlan.c
44616 +++ b/drivers/net/wireless/rndis_wlan.c
44617 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
44618
44619 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
44620
44621 - if (rts_threshold < 0 || rts_threshold > 2347)
44622 + if (rts_threshold > 2347)
44623 rts_threshold = 2347;
44624
44625 tmp = cpu_to_le32(rts_threshold);
44626 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
44627 index fe4c572..99dedfa 100644
44628 --- a/drivers/net/wireless/rt2x00/rt2x00.h
44629 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
44630 @@ -387,7 +387,7 @@ struct rt2x00_intf {
44631 * for hardware which doesn't support hardware
44632 * sequence counting.
44633 */
44634 - atomic_t seqno;
44635 + atomic_unchecked_t seqno;
44636 };
44637
44638 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
44639 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
44640 index 6c8a33b..78212fa 100644
44641 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
44642 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
44643 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
44644 * sequence counter given by mac80211.
44645 */
44646 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
44647 - seqno = atomic_add_return(0x10, &intf->seqno);
44648 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
44649 else
44650 - seqno = atomic_read(&intf->seqno);
44651 + seqno = atomic_read_unchecked(&intf->seqno);
44652
44653 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
44654 hdr->seq_ctrl |= cpu_to_le16(seqno);
44655 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
44656 index e2b3d9c..67a5184 100644
44657 --- a/drivers/net/wireless/ti/wl1251/sdio.c
44658 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
44659 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
44660
44661 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
44662
44663 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44664 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44665 + pax_open_kernel();
44666 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44667 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44668 + pax_close_kernel();
44669
44670 wl1251_info("using dedicated interrupt line");
44671 } else {
44672 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44673 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44674 + pax_open_kernel();
44675 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44676 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44677 + pax_close_kernel();
44678
44679 wl1251_info("using SDIO interrupt");
44680 }
44681 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
44682 index 1c627da..69f7d17 100644
44683 --- a/drivers/net/wireless/ti/wl12xx/main.c
44684 +++ b/drivers/net/wireless/ti/wl12xx/main.c
44685 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44686 sizeof(wl->conf.mem));
44687
44688 /* read data preparation is only needed by wl127x */
44689 - wl->ops->prepare_read = wl127x_prepare_read;
44690 + pax_open_kernel();
44691 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44692 + pax_close_kernel();
44693
44694 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44695 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44696 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44697 sizeof(wl->conf.mem));
44698
44699 /* read data preparation is only needed by wl127x */
44700 - wl->ops->prepare_read = wl127x_prepare_read;
44701 + pax_open_kernel();
44702 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44703 + pax_close_kernel();
44704
44705 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44706 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44707 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
44708 index 7aa0eb8..5a9ef38 100644
44709 --- a/drivers/net/wireless/ti/wl18xx/main.c
44710 +++ b/drivers/net/wireless/ti/wl18xx/main.c
44711 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
44712 }
44713
44714 if (!checksum_param) {
44715 - wl18xx_ops.set_rx_csum = NULL;
44716 - wl18xx_ops.init_vif = NULL;
44717 + pax_open_kernel();
44718 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
44719 + *(void **)&wl18xx_ops.init_vif = NULL;
44720 + pax_close_kernel();
44721 }
44722
44723 /* Enable 11a Band only if we have 5G antennas */
44724 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
44725 index 7ef0b4a..ff65c28 100644
44726 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
44727 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
44728 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
44729 {
44730 struct zd_usb *usb = urb->context;
44731 struct zd_usb_interrupt *intr = &usb->intr;
44732 - int len;
44733 + unsigned int len;
44734 u16 int_num;
44735
44736 ZD_ASSERT(in_interrupt());
44737 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
44738 index 59f95d8..53e0e7f 100644
44739 --- a/drivers/nfc/nfcwilink.c
44740 +++ b/drivers/nfc/nfcwilink.c
44741 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
44742
44743 static int nfcwilink_probe(struct platform_device *pdev)
44744 {
44745 - static struct nfcwilink *drv;
44746 + struct nfcwilink *drv;
44747 int rc;
44748 __u32 protocols;
44749
44750 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
44751 index d93b2b6..ae50401 100644
44752 --- a/drivers/oprofile/buffer_sync.c
44753 +++ b/drivers/oprofile/buffer_sync.c
44754 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
44755 if (cookie == NO_COOKIE)
44756 offset = pc;
44757 if (cookie == INVALID_COOKIE) {
44758 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44759 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44760 offset = pc;
44761 }
44762 if (cookie != last_cookie) {
44763 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
44764 /* add userspace sample */
44765
44766 if (!mm) {
44767 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
44768 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
44769 return 0;
44770 }
44771
44772 cookie = lookup_dcookie(mm, s->eip, &offset);
44773
44774 if (cookie == INVALID_COOKIE) {
44775 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44776 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44777 return 0;
44778 }
44779
44780 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
44781 /* ignore backtraces if failed to add a sample */
44782 if (state == sb_bt_start) {
44783 state = sb_bt_ignore;
44784 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
44785 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
44786 }
44787 }
44788 release_mm(mm);
44789 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
44790 index c0cc4e7..44d4e54 100644
44791 --- a/drivers/oprofile/event_buffer.c
44792 +++ b/drivers/oprofile/event_buffer.c
44793 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
44794 }
44795
44796 if (buffer_pos == buffer_size) {
44797 - atomic_inc(&oprofile_stats.event_lost_overflow);
44798 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
44799 return;
44800 }
44801
44802 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
44803 index ed2c3ec..deda85a 100644
44804 --- a/drivers/oprofile/oprof.c
44805 +++ b/drivers/oprofile/oprof.c
44806 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
44807 if (oprofile_ops.switch_events())
44808 return;
44809
44810 - atomic_inc(&oprofile_stats.multiplex_counter);
44811 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
44812 start_switch_worker();
44813 }
44814
44815 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
44816 index ee2cfce..7f8f699 100644
44817 --- a/drivers/oprofile/oprofile_files.c
44818 +++ b/drivers/oprofile/oprofile_files.c
44819 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
44820
44821 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
44822
44823 -static ssize_t timeout_read(struct file *file, char __user *buf,
44824 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
44825 size_t count, loff_t *offset)
44826 {
44827 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
44828 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
44829 index 59659ce..6c860a0 100644
44830 --- a/drivers/oprofile/oprofile_stats.c
44831 +++ b/drivers/oprofile/oprofile_stats.c
44832 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
44833 cpu_buf->sample_invalid_eip = 0;
44834 }
44835
44836 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
44837 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
44838 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
44839 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
44840 - atomic_set(&oprofile_stats.multiplex_counter, 0);
44841 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
44842 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
44843 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
44844 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
44845 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
44846 }
44847
44848
44849 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
44850 index 1fc622b..8c48fc3 100644
44851 --- a/drivers/oprofile/oprofile_stats.h
44852 +++ b/drivers/oprofile/oprofile_stats.h
44853 @@ -13,11 +13,11 @@
44854 #include <linux/atomic.h>
44855
44856 struct oprofile_stat_struct {
44857 - atomic_t sample_lost_no_mm;
44858 - atomic_t sample_lost_no_mapping;
44859 - atomic_t bt_lost_no_mapping;
44860 - atomic_t event_lost_overflow;
44861 - atomic_t multiplex_counter;
44862 + atomic_unchecked_t sample_lost_no_mm;
44863 + atomic_unchecked_t sample_lost_no_mapping;
44864 + atomic_unchecked_t bt_lost_no_mapping;
44865 + atomic_unchecked_t event_lost_overflow;
44866 + atomic_unchecked_t multiplex_counter;
44867 };
44868
44869 extern struct oprofile_stat_struct oprofile_stats;
44870 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
44871 index 3f49345..c750d0b 100644
44872 --- a/drivers/oprofile/oprofilefs.c
44873 +++ b/drivers/oprofile/oprofilefs.c
44874 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
44875
44876 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
44877 {
44878 - atomic_t *val = file->private_data;
44879 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
44880 + atomic_unchecked_t *val = file->private_data;
44881 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
44882 }
44883
44884
44885 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
44886
44887
44888 int oprofilefs_create_ro_atomic(struct dentry *root,
44889 - char const *name, atomic_t *val)
44890 + char const *name, atomic_unchecked_t *val)
44891 {
44892 return __oprofilefs_create_file(root, name,
44893 &atomic_ro_fops, 0444, val);
44894 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
44895 index 61be1d9..dec05d7 100644
44896 --- a/drivers/oprofile/timer_int.c
44897 +++ b/drivers/oprofile/timer_int.c
44898 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
44899 return NOTIFY_OK;
44900 }
44901
44902 -static struct notifier_block __refdata oprofile_cpu_notifier = {
44903 +static struct notifier_block oprofile_cpu_notifier = {
44904 .notifier_call = oprofile_cpu_notify,
44905 };
44906
44907 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
44908 index 92ed045..62d39bd7 100644
44909 --- a/drivers/parport/procfs.c
44910 +++ b/drivers/parport/procfs.c
44911 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
44912
44913 *ppos += len;
44914
44915 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
44916 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
44917 }
44918
44919 #ifdef CONFIG_PARPORT_1284
44920 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
44921
44922 *ppos += len;
44923
44924 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
44925 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
44926 }
44927 #endif /* IEEE1284.3 support. */
44928
44929 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
44930 index 2f5786c..61ab4d1 100644
44931 --- a/drivers/pci/hotplug/acpiphp_ibm.c
44932 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
44933 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
44934 goto init_cleanup;
44935 }
44936
44937 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
44938 + pax_open_kernel();
44939 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
44940 + pax_close_kernel();
44941 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
44942
44943 return retval;
44944 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
44945 index a6a71c4..c91097b 100644
44946 --- a/drivers/pci/hotplug/cpcihp_generic.c
44947 +++ b/drivers/pci/hotplug/cpcihp_generic.c
44948 @@ -73,7 +73,6 @@ static u16 port;
44949 static unsigned int enum_bit;
44950 static u8 enum_mask;
44951
44952 -static struct cpci_hp_controller_ops generic_hpc_ops;
44953 static struct cpci_hp_controller generic_hpc;
44954
44955 static int __init validate_parameters(void)
44956 @@ -139,6 +138,10 @@ static int query_enum(void)
44957 return ((value & enum_mask) == enum_mask);
44958 }
44959
44960 +static struct cpci_hp_controller_ops generic_hpc_ops = {
44961 + .query_enum = query_enum,
44962 +};
44963 +
44964 static int __init cpcihp_generic_init(void)
44965 {
44966 int status;
44967 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
44968 pci_dev_put(dev);
44969
44970 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
44971 - generic_hpc_ops.query_enum = query_enum;
44972 generic_hpc.ops = &generic_hpc_ops;
44973
44974 status = cpci_hp_register_controller(&generic_hpc);
44975 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
44976 index 449b4bb..257e2e8 100644
44977 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
44978 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
44979 @@ -59,7 +59,6 @@
44980 /* local variables */
44981 static bool debug;
44982 static bool poll;
44983 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
44984 static struct cpci_hp_controller zt5550_hpc;
44985
44986 /* Primary cPCI bus bridge device */
44987 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
44988 return 0;
44989 }
44990
44991 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
44992 + .query_enum = zt5550_hc_query_enum,
44993 +};
44994 +
44995 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
44996 {
44997 int status;
44998 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
44999 dbg("returned from zt5550_hc_config");
45000
45001 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45002 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45003 zt5550_hpc.ops = &zt5550_hpc_ops;
45004 if(!poll) {
45005 zt5550_hpc.irq = hc_dev->irq;
45006 zt5550_hpc.irq_flags = IRQF_SHARED;
45007 zt5550_hpc.dev_id = hc_dev;
45008
45009 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45010 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45011 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45012 + pax_open_kernel();
45013 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45014 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45015 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45016 + pax_open_kernel();
45017 } else {
45018 info("using ENUM# polling mode");
45019 }
45020 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45021 index 76ba8a1..20ca857 100644
45022 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45023 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45024 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45025
45026 void compaq_nvram_init (void __iomem *rom_start)
45027 {
45028 +
45029 +#ifndef CONFIG_PAX_KERNEXEC
45030 if (rom_start) {
45031 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45032 }
45033 +#endif
45034 +
45035 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45036
45037 /* initialize our int15 lock */
45038 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45039 index ec20f74..c1d961e 100644
45040 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45041 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45042 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45043 return -EINVAL;
45044 }
45045
45046 - slot->ops->owner = owner;
45047 - slot->ops->mod_name = mod_name;
45048 + pax_open_kernel();
45049 + *(struct module **)&slot->ops->owner = owner;
45050 + *(const char **)&slot->ops->mod_name = mod_name;
45051 + pax_close_kernel();
45052
45053 mutex_lock(&pci_hp_mutex);
45054 /*
45055 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45056 index f4a18f5..ff2463c 100644
45057 --- a/drivers/pci/hotplug/pciehp_core.c
45058 +++ b/drivers/pci/hotplug/pciehp_core.c
45059 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45060 struct slot *slot = ctrl->slot;
45061 struct hotplug_slot *hotplug = NULL;
45062 struct hotplug_slot_info *info = NULL;
45063 - struct hotplug_slot_ops *ops = NULL;
45064 + hotplug_slot_ops_no_const *ops = NULL;
45065 char name[SLOT_NAME_SIZE];
45066 int retval = -ENOMEM;
45067
45068 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45069 index 7128cfd..a0640d6 100644
45070 --- a/drivers/pci/pci-sysfs.c
45071 +++ b/drivers/pci/pci-sysfs.c
45072 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45073 {
45074 /* allocate attribute structure, piggyback attribute name */
45075 int name_len = write_combine ? 13 : 10;
45076 - struct bin_attribute *res_attr;
45077 + bin_attribute_no_const *res_attr;
45078 int retval;
45079
45080 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45081 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45082 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45083 {
45084 int retval;
45085 - struct bin_attribute *attr;
45086 + bin_attribute_no_const *attr;
45087
45088 /* If the device has VPD, try to expose it in sysfs. */
45089 if (dev->vpd) {
45090 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45091 {
45092 int retval;
45093 int rom_size = 0;
45094 - struct bin_attribute *attr;
45095 + bin_attribute_no_const *attr;
45096
45097 if (!sysfs_initialized)
45098 return -EACCES;
45099 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45100 index 8a00c06..18a9715 100644
45101 --- a/drivers/pci/pci.h
45102 +++ b/drivers/pci/pci.h
45103 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45104 struct pci_vpd {
45105 unsigned int len;
45106 const struct pci_vpd_ops *ops;
45107 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45108 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45109 };
45110
45111 int pci_vpd_pci22_init(struct pci_dev *dev);
45112 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45113 index 403a443..034e050 100644
45114 --- a/drivers/pci/pcie/aspm.c
45115 +++ b/drivers/pci/pcie/aspm.c
45116 @@ -27,9 +27,9 @@
45117 #define MODULE_PARAM_PREFIX "pcie_aspm."
45118
45119 /* Note: those are not register definitions */
45120 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45121 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45122 -#define ASPM_STATE_L1 (4) /* L1 state */
45123 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45124 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45125 +#define ASPM_STATE_L1 (4U) /* L1 state */
45126 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45127 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45128
45129 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45130 index 7ef0f86..17b710f 100644
45131 --- a/drivers/pci/probe.c
45132 +++ b/drivers/pci/probe.c
45133 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45134 struct pci_bus_region region, inverted_region;
45135 bool bar_too_big = false, bar_disabled = false;
45136
45137 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45138 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45139
45140 /* No printks while decoding is disabled! */
45141 if (!dev->mmio_always_on) {
45142 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45143 index cdc7836..528635c 100644
45144 --- a/drivers/pci/proc.c
45145 +++ b/drivers/pci/proc.c
45146 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45147 static int __init pci_proc_init(void)
45148 {
45149 struct pci_dev *dev = NULL;
45150 +
45151 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45152 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45153 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45154 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45155 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45156 +#endif
45157 +#else
45158 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45159 +#endif
45160 proc_create("devices", 0, proc_bus_pci_dir,
45161 &proc_bus_pci_dev_operations);
45162 proc_initialized = 1;
45163 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45164 index 3e5b4497..dcdfb70 100644
45165 --- a/drivers/platform/x86/chromeos_laptop.c
45166 +++ b/drivers/platform/x86/chromeos_laptop.c
45167 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45168 return 0;
45169 }
45170
45171 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45172 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45173 {
45174 .ident = "Samsung Series 5 550 - Touchpad",
45175 .matches = {
45176 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45177 index 62f8030..c7f2a45 100644
45178 --- a/drivers/platform/x86/msi-laptop.c
45179 +++ b/drivers/platform/x86/msi-laptop.c
45180 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45181
45182 if (!quirks->ec_read_only) {
45183 /* allow userland write sysfs file */
45184 - dev_attr_bluetooth.store = store_bluetooth;
45185 - dev_attr_wlan.store = store_wlan;
45186 - dev_attr_threeg.store = store_threeg;
45187 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45188 - dev_attr_wlan.attr.mode |= S_IWUSR;
45189 - dev_attr_threeg.attr.mode |= S_IWUSR;
45190 + pax_open_kernel();
45191 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45192 + *(void **)&dev_attr_wlan.store = store_wlan;
45193 + *(void **)&dev_attr_threeg.store = store_threeg;
45194 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45195 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45196 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45197 + pax_close_kernel();
45198 }
45199
45200 /* disable hardware control by fn key */
45201 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45202 index 70222f2..8c8ce66 100644
45203 --- a/drivers/platform/x86/msi-wmi.c
45204 +++ b/drivers/platform/x86/msi-wmi.c
45205 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45206 static void msi_wmi_notify(u32 value, void *context)
45207 {
45208 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45209 - static struct key_entry *key;
45210 + struct key_entry *key;
45211 union acpi_object *obj;
45212 acpi_status status;
45213
45214 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45215 index 13ec195..6af61af 100644
45216 --- a/drivers/platform/x86/sony-laptop.c
45217 +++ b/drivers/platform/x86/sony-laptop.c
45218 @@ -2475,7 +2475,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45219 }
45220
45221 /* High speed charging function */
45222 -static struct device_attribute *hsc_handle;
45223 +static device_attribute_no_const *hsc_handle;
45224
45225 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45226 struct device_attribute *attr,
45227 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45228 index 03ca6c1..1ef2ddd 100644
45229 --- a/drivers/platform/x86/thinkpad_acpi.c
45230 +++ b/drivers/platform/x86/thinkpad_acpi.c
45231 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
45232 return 0;
45233 }
45234
45235 -void static hotkey_mask_warn_incomplete_mask(void)
45236 +static void hotkey_mask_warn_incomplete_mask(void)
45237 {
45238 /* log only what the user can fix... */
45239 const u32 wantedmask = hotkey_driver_mask &
45240 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45241 }
45242 }
45243
45244 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45245 - struct tp_nvram_state *newn,
45246 - const u32 event_mask)
45247 -{
45248 -
45249 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45250 do { \
45251 if ((event_mask & (1 << __scancode)) && \
45252 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45253 tpacpi_hotkey_send_key(__scancode); \
45254 } while (0)
45255
45256 - void issue_volchange(const unsigned int oldvol,
45257 - const unsigned int newvol)
45258 - {
45259 - unsigned int i = oldvol;
45260 +static void issue_volchange(const unsigned int oldvol,
45261 + const unsigned int newvol,
45262 + const u32 event_mask)
45263 +{
45264 + unsigned int i = oldvol;
45265
45266 - while (i > newvol) {
45267 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45268 - i--;
45269 - }
45270 - while (i < newvol) {
45271 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45272 - i++;
45273 - }
45274 + while (i > newvol) {
45275 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45276 + i--;
45277 }
45278 + while (i < newvol) {
45279 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45280 + i++;
45281 + }
45282 +}
45283
45284 - void issue_brightnesschange(const unsigned int oldbrt,
45285 - const unsigned int newbrt)
45286 - {
45287 - unsigned int i = oldbrt;
45288 +static void issue_brightnesschange(const unsigned int oldbrt,
45289 + const unsigned int newbrt,
45290 + const u32 event_mask)
45291 +{
45292 + unsigned int i = oldbrt;
45293
45294 - while (i > newbrt) {
45295 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45296 - i--;
45297 - }
45298 - while (i < newbrt) {
45299 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45300 - i++;
45301 - }
45302 + while (i > newbrt) {
45303 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45304 + i--;
45305 + }
45306 + while (i < newbrt) {
45307 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45308 + i++;
45309 }
45310 +}
45311
45312 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45313 + struct tp_nvram_state *newn,
45314 + const u32 event_mask)
45315 +{
45316 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45317 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45318 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45319 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45320 oldn->volume_level != newn->volume_level) {
45321 /* recently muted, or repeated mute keypress, or
45322 * multiple presses ending in mute */
45323 - issue_volchange(oldn->volume_level, newn->volume_level);
45324 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45325 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45326 }
45327 } else {
45328 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45329 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45330 }
45331 if (oldn->volume_level != newn->volume_level) {
45332 - issue_volchange(oldn->volume_level, newn->volume_level);
45333 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45334 } else if (oldn->volume_toggle != newn->volume_toggle) {
45335 /* repeated vol up/down keypress at end of scale ? */
45336 if (newn->volume_level == 0)
45337 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45338 /* handle brightness */
45339 if (oldn->brightness_level != newn->brightness_level) {
45340 issue_brightnesschange(oldn->brightness_level,
45341 - newn->brightness_level);
45342 + newn->brightness_level,
45343 + event_mask);
45344 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45345 /* repeated key presses that didn't change state */
45346 if (newn->brightness_level == 0)
45347 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45348 && !tp_features.bright_unkfw)
45349 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45350 }
45351 +}
45352
45353 #undef TPACPI_COMPARE_KEY
45354 #undef TPACPI_MAY_SEND_KEY
45355 -}
45356
45357 /*
45358 * Polling driver
45359 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45360 index 769d265..a3a05ca 100644
45361 --- a/drivers/pnp/pnpbios/bioscalls.c
45362 +++ b/drivers/pnp/pnpbios/bioscalls.c
45363 @@ -58,7 +58,7 @@ do { \
45364 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45365 } while(0)
45366
45367 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45368 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45369 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45370
45371 /*
45372 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45373
45374 cpu = get_cpu();
45375 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45376 +
45377 + pax_open_kernel();
45378 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45379 + pax_close_kernel();
45380
45381 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45382 spin_lock_irqsave(&pnp_bios_lock, flags);
45383 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45384 :"memory");
45385 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45386
45387 + pax_open_kernel();
45388 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45389 + pax_close_kernel();
45390 +
45391 put_cpu();
45392
45393 /* If we get here and this is set then the PnP BIOS faulted on us. */
45394 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45395 return status;
45396 }
45397
45398 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45399 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45400 {
45401 int i;
45402
45403 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45404 pnp_bios_callpoint.offset = header->fields.pm16offset;
45405 pnp_bios_callpoint.segment = PNP_CS16;
45406
45407 + pax_open_kernel();
45408 +
45409 for_each_possible_cpu(i) {
45410 struct desc_struct *gdt = get_cpu_gdt_table(i);
45411 if (!gdt)
45412 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45413 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45414 (unsigned long)__va(header->fields.pm16dseg));
45415 }
45416 +
45417 + pax_close_kernel();
45418 }
45419 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45420 index d95e101..67f0c3f 100644
45421 --- a/drivers/pnp/resource.c
45422 +++ b/drivers/pnp/resource.c
45423 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45424 return 1;
45425
45426 /* check if the resource is valid */
45427 - if (*irq < 0 || *irq > 15)
45428 + if (*irq > 15)
45429 return 0;
45430
45431 /* check if the resource is reserved */
45432 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45433 return 1;
45434
45435 /* check if the resource is valid */
45436 - if (*dma < 0 || *dma == 4 || *dma > 7)
45437 + if (*dma == 4 || *dma > 7)
45438 return 0;
45439
45440 /* check if the resource is reserved */
45441 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45442 index 0c52e2a..3421ab7 100644
45443 --- a/drivers/power/pda_power.c
45444 +++ b/drivers/power/pda_power.c
45445 @@ -37,7 +37,11 @@ static int polling;
45446
45447 #if IS_ENABLED(CONFIG_USB_PHY)
45448 static struct usb_phy *transceiver;
45449 -static struct notifier_block otg_nb;
45450 +static int otg_handle_notification(struct notifier_block *nb,
45451 + unsigned long event, void *unused);
45452 +static struct notifier_block otg_nb = {
45453 + .notifier_call = otg_handle_notification
45454 +};
45455 #endif
45456
45457 static struct regulator *ac_draw;
45458 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45459
45460 #if IS_ENABLED(CONFIG_USB_PHY)
45461 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45462 - otg_nb.notifier_call = otg_handle_notification;
45463 ret = usb_register_notifier(transceiver, &otg_nb);
45464 if (ret) {
45465 dev_err(dev, "failure to register otg notifier\n");
45466 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45467 index cc439fd..8fa30df 100644
45468 --- a/drivers/power/power_supply.h
45469 +++ b/drivers/power/power_supply.h
45470 @@ -16,12 +16,12 @@ struct power_supply;
45471
45472 #ifdef CONFIG_SYSFS
45473
45474 -extern void power_supply_init_attrs(struct device_type *dev_type);
45475 +extern void power_supply_init_attrs(void);
45476 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45477
45478 #else
45479
45480 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45481 +static inline void power_supply_init_attrs(void) {}
45482 #define power_supply_uevent NULL
45483
45484 #endif /* CONFIG_SYSFS */
45485 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45486 index 00e6672..2642c08 100644
45487 --- a/drivers/power/power_supply_core.c
45488 +++ b/drivers/power/power_supply_core.c
45489 @@ -24,7 +24,10 @@
45490 struct class *power_supply_class;
45491 EXPORT_SYMBOL_GPL(power_supply_class);
45492
45493 -static struct device_type power_supply_dev_type;
45494 +extern const struct attribute_group *power_supply_attr_groups[];
45495 +static struct device_type power_supply_dev_type = {
45496 + .groups = power_supply_attr_groups,
45497 +};
45498
45499 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45500 struct power_supply *supply)
45501 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
45502 return PTR_ERR(power_supply_class);
45503
45504 power_supply_class->dev_uevent = power_supply_uevent;
45505 - power_supply_init_attrs(&power_supply_dev_type);
45506 + power_supply_init_attrs();
45507
45508 return 0;
45509 }
45510 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45511 index 44420d1..967126e 100644
45512 --- a/drivers/power/power_supply_sysfs.c
45513 +++ b/drivers/power/power_supply_sysfs.c
45514 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45515 .is_visible = power_supply_attr_is_visible,
45516 };
45517
45518 -static const struct attribute_group *power_supply_attr_groups[] = {
45519 +const struct attribute_group *power_supply_attr_groups[] = {
45520 &power_supply_attr_group,
45521 NULL,
45522 };
45523
45524 -void power_supply_init_attrs(struct device_type *dev_type)
45525 +void power_supply_init_attrs(void)
45526 {
45527 int i;
45528
45529 - dev_type->groups = power_supply_attr_groups;
45530 -
45531 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45532 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45533 }
45534 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45535 index a01b8b3..37c2afe 100644
45536 --- a/drivers/regulator/core.c
45537 +++ b/drivers/regulator/core.c
45538 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45539 {
45540 const struct regulation_constraints *constraints = NULL;
45541 const struct regulator_init_data *init_data;
45542 - static atomic_t regulator_no = ATOMIC_INIT(0);
45543 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45544 struct regulator_dev *rdev;
45545 struct device *dev;
45546 int ret, i;
45547 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45548 rdev->dev.of_node = config->of_node;
45549 rdev->dev.parent = dev;
45550 dev_set_name(&rdev->dev, "regulator.%d",
45551 - atomic_inc_return(&regulator_no) - 1);
45552 + atomic_inc_return_unchecked(&regulator_no) - 1);
45553 ret = device_register(&rdev->dev);
45554 if (ret != 0) {
45555 put_device(&rdev->dev);
45556 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45557 index 144bcac..d20e7db 100644
45558 --- a/drivers/regulator/max8660.c
45559 +++ b/drivers/regulator/max8660.c
45560 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
45561 max8660->shadow_regs[MAX8660_OVER1] = 5;
45562 } else {
45563 /* Otherwise devices can be toggled via software */
45564 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45565 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45566 + pax_open_kernel();
45567 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45568 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45569 + pax_close_kernel();
45570 }
45571
45572 /*
45573 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45574 index 5b77ab7..a62f061 100644
45575 --- a/drivers/regulator/max8973-regulator.c
45576 +++ b/drivers/regulator/max8973-regulator.c
45577 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45578 if (!pdata || !pdata->enable_ext_control) {
45579 max->desc.enable_reg = MAX8973_VOUT;
45580 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45581 - max->ops.enable = regulator_enable_regmap;
45582 - max->ops.disable = regulator_disable_regmap;
45583 - max->ops.is_enabled = regulator_is_enabled_regmap;
45584 + pax_open_kernel();
45585 + *(void **)&max->ops.enable = regulator_enable_regmap;
45586 + *(void **)&max->ops.disable = regulator_disable_regmap;
45587 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45588 + pax_close_kernel();
45589 }
45590
45591 if (pdata) {
45592 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45593 index 1037e07..e64dea1 100644
45594 --- a/drivers/regulator/mc13892-regulator.c
45595 +++ b/drivers/regulator/mc13892-regulator.c
45596 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45597 }
45598 mc13xxx_unlock(mc13892);
45599
45600 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45601 + pax_open_kernel();
45602 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45603 = mc13892_vcam_set_mode;
45604 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45605 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45606 = mc13892_vcam_get_mode;
45607 + pax_close_kernel();
45608
45609 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
45610 ARRAY_SIZE(mc13892_regulators));
45611 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
45612 index 24e733c..bfbaa3e 100644
45613 --- a/drivers/rtc/rtc-cmos.c
45614 +++ b/drivers/rtc/rtc-cmos.c
45615 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
45616 hpet_rtc_timer_init();
45617
45618 /* export at least the first block of NVRAM */
45619 - nvram.size = address_space - NVRAM_OFFSET;
45620 + pax_open_kernel();
45621 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
45622 + pax_close_kernel();
45623 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
45624 if (retval < 0) {
45625 dev_dbg(dev, "can't create nvram file? %d\n", retval);
45626 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
45627 index d049393..bb20be0 100644
45628 --- a/drivers/rtc/rtc-dev.c
45629 +++ b/drivers/rtc/rtc-dev.c
45630 @@ -16,6 +16,7 @@
45631 #include <linux/module.h>
45632 #include <linux/rtc.h>
45633 #include <linux/sched.h>
45634 +#include <linux/grsecurity.h>
45635 #include "rtc-core.h"
45636
45637 static dev_t rtc_devt;
45638 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
45639 if (copy_from_user(&tm, uarg, sizeof(tm)))
45640 return -EFAULT;
45641
45642 + gr_log_timechange();
45643 +
45644 return rtc_set_time(rtc, &tm);
45645
45646 case RTC_PIE_ON:
45647 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
45648 index ca18fd1..055e42d 100644
45649 --- a/drivers/rtc/rtc-ds1307.c
45650 +++ b/drivers/rtc/rtc-ds1307.c
45651 @@ -107,7 +107,7 @@ struct ds1307 {
45652 u8 offset; /* register's offset */
45653 u8 regs[11];
45654 u16 nvram_offset;
45655 - struct bin_attribute *nvram;
45656 + bin_attribute_no_const *nvram;
45657 enum ds_type type;
45658 unsigned long flags;
45659 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
45660 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
45661 index fcb0329..d77b7f2 100644
45662 --- a/drivers/rtc/rtc-m48t59.c
45663 +++ b/drivers/rtc/rtc-m48t59.c
45664 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
45665 if (IS_ERR(m48t59->rtc))
45666 return PTR_ERR(m48t59->rtc);
45667
45668 - m48t59_nvram_attr.size = pdata->offset;
45669 + pax_open_kernel();
45670 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
45671 + pax_close_kernel();
45672
45673 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
45674 if (ret)
45675 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
45676 index 14b5f8d..cc9bd26 100644
45677 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
45678 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
45679 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
45680 for (bit = 0; bit < 8; bit++) {
45681
45682 if ((pci_status[i] & (0x1 << bit)) != 0) {
45683 - static const char *s;
45684 + const char *s;
45685
45686 s = pci_status_strings[bit];
45687 if (i == 7/*TARG*/ && bit == 3)
45688 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
45689
45690 for (bit = 0; bit < 8; bit++) {
45691
45692 - if ((split_status[i] & (0x1 << bit)) != 0) {
45693 - static const char *s;
45694 -
45695 - s = split_status_strings[bit];
45696 - printk(s, ahd_name(ahd),
45697 + if ((split_status[i] & (0x1 << bit)) != 0)
45698 + printk(split_status_strings[bit], ahd_name(ahd),
45699 split_status_source[i]);
45700 - }
45701
45702 if (i > 1)
45703 continue;
45704
45705 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
45706 - static const char *s;
45707 -
45708 - s = split_status_strings[bit];
45709 - printk(s, ahd_name(ahd), "SG");
45710 - }
45711 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
45712 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
45713 }
45714 }
45715 /*
45716 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
45717 index e693af6..2e525b6 100644
45718 --- a/drivers/scsi/bfa/bfa_fcpim.h
45719 +++ b/drivers/scsi/bfa/bfa_fcpim.h
45720 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
45721
45722 struct bfa_itn_s {
45723 bfa_isr_func_t isr;
45724 -};
45725 +} __no_const;
45726
45727 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
45728 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
45729 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
45730 index 90814fe..4384138 100644
45731 --- a/drivers/scsi/bfa/bfa_ioc.h
45732 +++ b/drivers/scsi/bfa/bfa_ioc.h
45733 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
45734 bfa_ioc_disable_cbfn_t disable_cbfn;
45735 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
45736 bfa_ioc_reset_cbfn_t reset_cbfn;
45737 -};
45738 +} __no_const;
45739
45740 /*
45741 * IOC event notification mechanism.
45742 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
45743 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
45744 enum bfi_ioc_state fwstate);
45745 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
45746 -};
45747 +} __no_const;
45748
45749 /*
45750 * Queue element to wait for room in request queue. FIFO order is
45751 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
45752 index c9382d6..6619864 100644
45753 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
45754 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
45755 @@ -33,8 +33,8 @@
45756 */
45757 #include "libfcoe.h"
45758
45759 -static atomic_t ctlr_num;
45760 -static atomic_t fcf_num;
45761 +static atomic_unchecked_t ctlr_num;
45762 +static atomic_unchecked_t fcf_num;
45763
45764 /*
45765 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
45766 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
45767 if (!ctlr)
45768 goto out;
45769
45770 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
45771 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
45772 ctlr->f = f;
45773 ctlr->mode = FIP_CONN_TYPE_FABRIC;
45774 INIT_LIST_HEAD(&ctlr->fcfs);
45775 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
45776 fcf->dev.parent = &ctlr->dev;
45777 fcf->dev.bus = &fcoe_bus_type;
45778 fcf->dev.type = &fcoe_fcf_device_type;
45779 - fcf->id = atomic_inc_return(&fcf_num) - 1;
45780 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
45781 fcf->state = FCOE_FCF_STATE_UNKNOWN;
45782
45783 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
45784 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
45785 {
45786 int error;
45787
45788 - atomic_set(&ctlr_num, 0);
45789 - atomic_set(&fcf_num, 0);
45790 + atomic_set_unchecked(&ctlr_num, 0);
45791 + atomic_set_unchecked(&fcf_num, 0);
45792
45793 error = bus_register(&fcoe_bus_type);
45794 if (error)
45795 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
45796 index df0c3c7..b00e1d0 100644
45797 --- a/drivers/scsi/hosts.c
45798 +++ b/drivers/scsi/hosts.c
45799 @@ -42,7 +42,7 @@
45800 #include "scsi_logging.h"
45801
45802
45803 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45804 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45805
45806
45807 static void scsi_host_cls_release(struct device *dev)
45808 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
45809 * subtract one because we increment first then return, but we need to
45810 * know what the next host number was before increment
45811 */
45812 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
45813 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
45814 shost->dma_channel = 0xff;
45815
45816 /* These three are default values which can be overridden */
45817 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
45818 index 891c86b..dd1224a0 100644
45819 --- a/drivers/scsi/hpsa.c
45820 +++ b/drivers/scsi/hpsa.c
45821 @@ -578,7 +578,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
45822 unsigned long flags;
45823
45824 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
45825 - return h->access.command_completed(h, q);
45826 + return h->access->command_completed(h, q);
45827
45828 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
45829 a = rq->head[rq->current_entry];
45830 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
45831 while (!list_empty(&h->reqQ)) {
45832 c = list_entry(h->reqQ.next, struct CommandList, list);
45833 /* can't do anything if fifo is full */
45834 - if ((h->access.fifo_full(h))) {
45835 + if ((h->access->fifo_full(h))) {
45836 dev_warn(&h->pdev->dev, "fifo full\n");
45837 break;
45838 }
45839 @@ -3466,7 +3466,7 @@ static void start_io(struct ctlr_info *h)
45840
45841 /* Tell the controller execute command */
45842 spin_unlock_irqrestore(&h->lock, flags);
45843 - h->access.submit_command(h, c);
45844 + h->access->submit_command(h, c);
45845 spin_lock_irqsave(&h->lock, flags);
45846 }
45847 spin_unlock_irqrestore(&h->lock, flags);
45848 @@ -3474,17 +3474,17 @@ static void start_io(struct ctlr_info *h)
45849
45850 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
45851 {
45852 - return h->access.command_completed(h, q);
45853 + return h->access->command_completed(h, q);
45854 }
45855
45856 static inline bool interrupt_pending(struct ctlr_info *h)
45857 {
45858 - return h->access.intr_pending(h);
45859 + return h->access->intr_pending(h);
45860 }
45861
45862 static inline long interrupt_not_for_us(struct ctlr_info *h)
45863 {
45864 - return (h->access.intr_pending(h) == 0) ||
45865 + return (h->access->intr_pending(h) == 0) ||
45866 (h->interrupts_enabled == 0);
45867 }
45868
45869 @@ -4386,7 +4386,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
45870 if (prod_index < 0)
45871 return -ENODEV;
45872 h->product_name = products[prod_index].product_name;
45873 - h->access = *(products[prod_index].access);
45874 + h->access = products[prod_index].access;
45875
45876 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
45877 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
45878 @@ -4668,7 +4668,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
45879
45880 assert_spin_locked(&lockup_detector_lock);
45881 remove_ctlr_from_lockup_detector_list(h);
45882 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45883 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45884 spin_lock_irqsave(&h->lock, flags);
45885 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
45886 spin_unlock_irqrestore(&h->lock, flags);
45887 @@ -4845,7 +4845,7 @@ reinit_after_soft_reset:
45888 }
45889
45890 /* make sure the board interrupts are off */
45891 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45892 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45893
45894 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
45895 goto clean2;
45896 @@ -4879,7 +4879,7 @@ reinit_after_soft_reset:
45897 * fake ones to scoop up any residual completions.
45898 */
45899 spin_lock_irqsave(&h->lock, flags);
45900 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45901 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45902 spin_unlock_irqrestore(&h->lock, flags);
45903 free_irqs(h);
45904 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
45905 @@ -4898,9 +4898,9 @@ reinit_after_soft_reset:
45906 dev_info(&h->pdev->dev, "Board READY.\n");
45907 dev_info(&h->pdev->dev,
45908 "Waiting for stale completions to drain.\n");
45909 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45910 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45911 msleep(10000);
45912 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45913 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45914
45915 rc = controller_reset_failed(h->cfgtable);
45916 if (rc)
45917 @@ -4921,7 +4921,7 @@ reinit_after_soft_reset:
45918 }
45919
45920 /* Turn the interrupts on so we can service requests */
45921 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45922 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45923
45924 hpsa_hba_inquiry(h);
45925 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
45926 @@ -4976,7 +4976,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
45927 * To write all data in the battery backed cache to disks
45928 */
45929 hpsa_flush_cache(h);
45930 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45931 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45932 hpsa_free_irqs_and_disable_msix(h);
45933 }
45934
45935 @@ -5144,7 +5144,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
45936 return;
45937 }
45938 /* Change the access methods to the performant access methods */
45939 - h->access = SA5_performant_access;
45940 + h->access = &SA5_performant_access;
45941 h->transMethod = CFGTBL_Trans_Performant;
45942 }
45943
45944 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
45945 index bc85e72..ae04a39 100644
45946 --- a/drivers/scsi/hpsa.h
45947 +++ b/drivers/scsi/hpsa.h
45948 @@ -79,7 +79,7 @@ struct ctlr_info {
45949 unsigned int msix_vector;
45950 unsigned int msi_vector;
45951 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
45952 - struct access_method access;
45953 + struct access_method *access;
45954
45955 /* queue and queue Info */
45956 struct list_head reqQ;
45957 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
45958 index 5879929..32b241d 100644
45959 --- a/drivers/scsi/libfc/fc_exch.c
45960 +++ b/drivers/scsi/libfc/fc_exch.c
45961 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
45962 u16 pool_max_index;
45963
45964 struct {
45965 - atomic_t no_free_exch;
45966 - atomic_t no_free_exch_xid;
45967 - atomic_t xid_not_found;
45968 - atomic_t xid_busy;
45969 - atomic_t seq_not_found;
45970 - atomic_t non_bls_resp;
45971 + atomic_unchecked_t no_free_exch;
45972 + atomic_unchecked_t no_free_exch_xid;
45973 + atomic_unchecked_t xid_not_found;
45974 + atomic_unchecked_t xid_busy;
45975 + atomic_unchecked_t seq_not_found;
45976 + atomic_unchecked_t non_bls_resp;
45977 } stats;
45978 };
45979
45980 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
45981 /* allocate memory for exchange */
45982 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
45983 if (!ep) {
45984 - atomic_inc(&mp->stats.no_free_exch);
45985 + atomic_inc_unchecked(&mp->stats.no_free_exch);
45986 goto out;
45987 }
45988 memset(ep, 0, sizeof(*ep));
45989 @@ -797,7 +797,7 @@ out:
45990 return ep;
45991 err:
45992 spin_unlock_bh(&pool->lock);
45993 - atomic_inc(&mp->stats.no_free_exch_xid);
45994 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
45995 mempool_free(ep, mp->ep_pool);
45996 return NULL;
45997 }
45998 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
45999 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46000 ep = fc_exch_find(mp, xid);
46001 if (!ep) {
46002 - atomic_inc(&mp->stats.xid_not_found);
46003 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46004 reject = FC_RJT_OX_ID;
46005 goto out;
46006 }
46007 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46008 ep = fc_exch_find(mp, xid);
46009 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46010 if (ep) {
46011 - atomic_inc(&mp->stats.xid_busy);
46012 + atomic_inc_unchecked(&mp->stats.xid_busy);
46013 reject = FC_RJT_RX_ID;
46014 goto rel;
46015 }
46016 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46017 }
46018 xid = ep->xid; /* get our XID */
46019 } else if (!ep) {
46020 - atomic_inc(&mp->stats.xid_not_found);
46021 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46022 reject = FC_RJT_RX_ID; /* XID not found */
46023 goto out;
46024 }
46025 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46026 } else {
46027 sp = &ep->seq;
46028 if (sp->id != fh->fh_seq_id) {
46029 - atomic_inc(&mp->stats.seq_not_found);
46030 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46031 if (f_ctl & FC_FC_END_SEQ) {
46032 /*
46033 * Update sequence_id based on incoming last
46034 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46035
46036 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46037 if (!ep) {
46038 - atomic_inc(&mp->stats.xid_not_found);
46039 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46040 goto out;
46041 }
46042 if (ep->esb_stat & ESB_ST_COMPLETE) {
46043 - atomic_inc(&mp->stats.xid_not_found);
46044 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46045 goto rel;
46046 }
46047 if (ep->rxid == FC_XID_UNKNOWN)
46048 ep->rxid = ntohs(fh->fh_rx_id);
46049 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46050 - atomic_inc(&mp->stats.xid_not_found);
46051 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46052 goto rel;
46053 }
46054 if (ep->did != ntoh24(fh->fh_s_id) &&
46055 ep->did != FC_FID_FLOGI) {
46056 - atomic_inc(&mp->stats.xid_not_found);
46057 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46058 goto rel;
46059 }
46060 sof = fr_sof(fp);
46061 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46062 sp->ssb_stat |= SSB_ST_RESP;
46063 sp->id = fh->fh_seq_id;
46064 } else if (sp->id != fh->fh_seq_id) {
46065 - atomic_inc(&mp->stats.seq_not_found);
46066 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46067 goto rel;
46068 }
46069
46070 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46071 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46072
46073 if (!sp)
46074 - atomic_inc(&mp->stats.xid_not_found);
46075 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46076 else
46077 - atomic_inc(&mp->stats.non_bls_resp);
46078 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46079
46080 fc_frame_free(fp);
46081 }
46082 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46083
46084 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46085 mp = ema->mp;
46086 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46087 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46088 st->fc_no_free_exch_xid +=
46089 - atomic_read(&mp->stats.no_free_exch_xid);
46090 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46091 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46092 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46093 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46094 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46095 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46096 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46097 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46098 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46099 }
46100 }
46101 EXPORT_SYMBOL(fc_exch_update_stats);
46102 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46103 index 161c98e..6d563b3 100644
46104 --- a/drivers/scsi/libsas/sas_ata.c
46105 +++ b/drivers/scsi/libsas/sas_ata.c
46106 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46107 .postreset = ata_std_postreset,
46108 .error_handler = ata_std_error_handler,
46109 .post_internal_cmd = sas_ata_post_internal,
46110 - .qc_defer = ata_std_qc_defer,
46111 + .qc_defer = ata_std_qc_defer,
46112 .qc_prep = ata_noop_qc_prep,
46113 .qc_issue = sas_ata_qc_issue,
46114 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46115 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46116 index 4e1b75c..0bbdfa9 100644
46117 --- a/drivers/scsi/lpfc/lpfc.h
46118 +++ b/drivers/scsi/lpfc/lpfc.h
46119 @@ -432,7 +432,7 @@ struct lpfc_vport {
46120 struct dentry *debug_nodelist;
46121 struct dentry *vport_debugfs_root;
46122 struct lpfc_debugfs_trc *disc_trc;
46123 - atomic_t disc_trc_cnt;
46124 + atomic_unchecked_t disc_trc_cnt;
46125 #endif
46126 uint8_t stat_data_enabled;
46127 uint8_t stat_data_blocked;
46128 @@ -865,8 +865,8 @@ struct lpfc_hba {
46129 struct timer_list fabric_block_timer;
46130 unsigned long bit_flags;
46131 #define FABRIC_COMANDS_BLOCKED 0
46132 - atomic_t num_rsrc_err;
46133 - atomic_t num_cmd_success;
46134 + atomic_unchecked_t num_rsrc_err;
46135 + atomic_unchecked_t num_cmd_success;
46136 unsigned long last_rsrc_error_time;
46137 unsigned long last_ramp_down_time;
46138 unsigned long last_ramp_up_time;
46139 @@ -902,7 +902,7 @@ struct lpfc_hba {
46140
46141 struct dentry *debug_slow_ring_trc;
46142 struct lpfc_debugfs_trc *slow_ring_trc;
46143 - atomic_t slow_ring_trc_cnt;
46144 + atomic_unchecked_t slow_ring_trc_cnt;
46145 /* iDiag debugfs sub-directory */
46146 struct dentry *idiag_root;
46147 struct dentry *idiag_pci_cfg;
46148 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46149 index 60084e6..0e2e700 100644
46150 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46151 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46152 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46153
46154 #include <linux/debugfs.h>
46155
46156 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46157 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46158 static unsigned long lpfc_debugfs_start_time = 0L;
46159
46160 /* iDiag */
46161 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46162 lpfc_debugfs_enable = 0;
46163
46164 len = 0;
46165 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46166 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46167 (lpfc_debugfs_max_disc_trc - 1);
46168 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46169 dtp = vport->disc_trc + i;
46170 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46171 lpfc_debugfs_enable = 0;
46172
46173 len = 0;
46174 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46175 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46176 (lpfc_debugfs_max_slow_ring_trc - 1);
46177 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46178 dtp = phba->slow_ring_trc + i;
46179 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46180 !vport || !vport->disc_trc)
46181 return;
46182
46183 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46184 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46185 (lpfc_debugfs_max_disc_trc - 1);
46186 dtp = vport->disc_trc + index;
46187 dtp->fmt = fmt;
46188 dtp->data1 = data1;
46189 dtp->data2 = data2;
46190 dtp->data3 = data3;
46191 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46192 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46193 dtp->jif = jiffies;
46194 #endif
46195 return;
46196 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46197 !phba || !phba->slow_ring_trc)
46198 return;
46199
46200 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46201 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46202 (lpfc_debugfs_max_slow_ring_trc - 1);
46203 dtp = phba->slow_ring_trc + index;
46204 dtp->fmt = fmt;
46205 dtp->data1 = data1;
46206 dtp->data2 = data2;
46207 dtp->data3 = data3;
46208 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46209 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46210 dtp->jif = jiffies;
46211 #endif
46212 return;
46213 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46214 "slow_ring buffer\n");
46215 goto debug_failed;
46216 }
46217 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46218 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46219 memset(phba->slow_ring_trc, 0,
46220 (sizeof(struct lpfc_debugfs_trc) *
46221 lpfc_debugfs_max_slow_ring_trc));
46222 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46223 "buffer\n");
46224 goto debug_failed;
46225 }
46226 - atomic_set(&vport->disc_trc_cnt, 0);
46227 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46228
46229 snprintf(name, sizeof(name), "discovery_trace");
46230 vport->debug_disc_trc =
46231 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46232 index 647f5bf..d0068b9 100644
46233 --- a/drivers/scsi/lpfc/lpfc_init.c
46234 +++ b/drivers/scsi/lpfc/lpfc_init.c
46235 @@ -10952,8 +10952,10 @@ lpfc_init(void)
46236 "misc_register returned with status %d", error);
46237
46238 if (lpfc_enable_npiv) {
46239 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46240 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46241 + pax_open_kernel();
46242 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46243 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46244 + pax_close_kernel();
46245 }
46246 lpfc_transport_template =
46247 fc_attach_transport(&lpfc_transport_functions);
46248 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46249 index c913e8c..d34a119 100644
46250 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46251 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46252 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46253 uint32_t evt_posted;
46254
46255 spin_lock_irqsave(&phba->hbalock, flags);
46256 - atomic_inc(&phba->num_rsrc_err);
46257 + atomic_inc_unchecked(&phba->num_rsrc_err);
46258 phba->last_rsrc_error_time = jiffies;
46259
46260 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46261 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46262 unsigned long flags;
46263 struct lpfc_hba *phba = vport->phba;
46264 uint32_t evt_posted;
46265 - atomic_inc(&phba->num_cmd_success);
46266 + atomic_inc_unchecked(&phba->num_cmd_success);
46267
46268 if (vport->cfg_lun_queue_depth <= queue_depth)
46269 return;
46270 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46271 unsigned long num_rsrc_err, num_cmd_success;
46272 int i;
46273
46274 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46275 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46276 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46277 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46278
46279 /*
46280 * The error and success command counters are global per
46281 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46282 }
46283 }
46284 lpfc_destroy_vport_work_array(phba, vports);
46285 - atomic_set(&phba->num_rsrc_err, 0);
46286 - atomic_set(&phba->num_cmd_success, 0);
46287 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46288 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46289 }
46290
46291 /**
46292 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46293 }
46294 }
46295 lpfc_destroy_vport_work_array(phba, vports);
46296 - atomic_set(&phba->num_rsrc_err, 0);
46297 - atomic_set(&phba->num_cmd_success, 0);
46298 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46299 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46300 }
46301
46302 /**
46303 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46304 index 7f0af4f..193ac3e 100644
46305 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46306 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46307 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
46308 {
46309 struct scsi_device *sdev = to_scsi_device(dev);
46310 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46311 - static struct _raid_device *raid_device;
46312 + struct _raid_device *raid_device;
46313 unsigned long flags;
46314 Mpi2RaidVolPage0_t vol_pg0;
46315 Mpi2ConfigReply_t mpi_reply;
46316 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
46317 {
46318 struct scsi_device *sdev = to_scsi_device(dev);
46319 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46320 - static struct _raid_device *raid_device;
46321 + struct _raid_device *raid_device;
46322 unsigned long flags;
46323 Mpi2RaidVolPage0_t vol_pg0;
46324 Mpi2ConfigReply_t mpi_reply;
46325 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46326 struct fw_event_work *fw_event)
46327 {
46328 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46329 - static struct _raid_device *raid_device;
46330 + struct _raid_device *raid_device;
46331 unsigned long flags;
46332 u16 handle;
46333
46334 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46335 u64 sas_address;
46336 struct _sas_device *sas_device;
46337 struct _sas_node *expander_device;
46338 - static struct _raid_device *raid_device;
46339 + struct _raid_device *raid_device;
46340 u8 retry_count;
46341 unsigned long flags;
46342
46343 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46344 index 1eb7b028..b2a6080 100644
46345 --- a/drivers/scsi/pmcraid.c
46346 +++ b/drivers/scsi/pmcraid.c
46347 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46348 res->scsi_dev = scsi_dev;
46349 scsi_dev->hostdata = res;
46350 res->change_detected = 0;
46351 - atomic_set(&res->read_failures, 0);
46352 - atomic_set(&res->write_failures, 0);
46353 + atomic_set_unchecked(&res->read_failures, 0);
46354 + atomic_set_unchecked(&res->write_failures, 0);
46355 rc = 0;
46356 }
46357 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46358 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46359
46360 /* If this was a SCSI read/write command keep count of errors */
46361 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46362 - atomic_inc(&res->read_failures);
46363 + atomic_inc_unchecked(&res->read_failures);
46364 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46365 - atomic_inc(&res->write_failures);
46366 + atomic_inc_unchecked(&res->write_failures);
46367
46368 if (!RES_IS_GSCSI(res->cfg_entry) &&
46369 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46370 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46371 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46372 * hrrq_id assigned here in queuecommand
46373 */
46374 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46375 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46376 pinstance->num_hrrq;
46377 cmd->cmd_done = pmcraid_io_done;
46378
46379 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46380 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46381 * hrrq_id assigned here in queuecommand
46382 */
46383 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46384 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46385 pinstance->num_hrrq;
46386
46387 if (request_size) {
46388 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46389
46390 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46391 /* add resources only after host is added into system */
46392 - if (!atomic_read(&pinstance->expose_resources))
46393 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46394 return;
46395
46396 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46397 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46398 init_waitqueue_head(&pinstance->reset_wait_q);
46399
46400 atomic_set(&pinstance->outstanding_cmds, 0);
46401 - atomic_set(&pinstance->last_message_id, 0);
46402 - atomic_set(&pinstance->expose_resources, 0);
46403 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46404 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46405
46406 INIT_LIST_HEAD(&pinstance->free_res_q);
46407 INIT_LIST_HEAD(&pinstance->used_res_q);
46408 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46409 /* Schedule worker thread to handle CCN and take care of adding and
46410 * removing devices to OS
46411 */
46412 - atomic_set(&pinstance->expose_resources, 1);
46413 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46414 schedule_work(&pinstance->worker_q);
46415 return rc;
46416
46417 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46418 index e1d150f..6c6df44 100644
46419 --- a/drivers/scsi/pmcraid.h
46420 +++ b/drivers/scsi/pmcraid.h
46421 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46422 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46423
46424 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46425 - atomic_t last_message_id;
46426 + atomic_unchecked_t last_message_id;
46427
46428 /* configuration table */
46429 struct pmcraid_config_table *cfg_table;
46430 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46431 atomic_t outstanding_cmds;
46432
46433 /* should add/delete resources to mid-layer now ?*/
46434 - atomic_t expose_resources;
46435 + atomic_unchecked_t expose_resources;
46436
46437
46438
46439 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46440 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46441 };
46442 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46443 - atomic_t read_failures; /* count of failed READ commands */
46444 - atomic_t write_failures; /* count of failed WRITE commands */
46445 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46446 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46447
46448 /* To indicate add/delete/modify during CCN */
46449 u8 change_detected;
46450 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46451 index 5f174b8..98d32b0 100644
46452 --- a/drivers/scsi/qla2xxx/qla_attr.c
46453 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46454 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46455 return 0;
46456 }
46457
46458 -struct fc_function_template qla2xxx_transport_functions = {
46459 +fc_function_template_no_const qla2xxx_transport_functions = {
46460
46461 .show_host_node_name = 1,
46462 .show_host_port_name = 1,
46463 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46464 .bsg_timeout = qla24xx_bsg_timeout,
46465 };
46466
46467 -struct fc_function_template qla2xxx_transport_vport_functions = {
46468 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46469
46470 .show_host_node_name = 1,
46471 .show_host_port_name = 1,
46472 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46473 index 4446bf5..9a3574d 100644
46474 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46475 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46476 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46477 struct device_attribute;
46478 extern struct device_attribute *qla2x00_host_attrs[];
46479 struct fc_function_template;
46480 -extern struct fc_function_template qla2xxx_transport_functions;
46481 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46482 +extern fc_function_template_no_const qla2xxx_transport_functions;
46483 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46484 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46485 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46486 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46487 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46488 index 9f01bbb..5e1dcee 100644
46489 --- a/drivers/scsi/qla2xxx/qla_os.c
46490 +++ b/drivers/scsi/qla2xxx/qla_os.c
46491 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46492 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46493 /* Ok, a 64bit DMA mask is applicable. */
46494 ha->flags.enable_64bit_addressing = 1;
46495 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46496 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46497 + pax_open_kernel();
46498 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46499 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46500 + pax_close_kernel();
46501 return;
46502 }
46503 }
46504 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46505 index 41327d4..feb03d479 100644
46506 --- a/drivers/scsi/qla4xxx/ql4_def.h
46507 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46508 @@ -296,7 +296,7 @@ struct ddb_entry {
46509 * (4000 only) */
46510 atomic_t relogin_timer; /* Max Time to wait for
46511 * relogin to complete */
46512 - atomic_t relogin_retry_count; /* Num of times relogin has been
46513 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46514 * retried */
46515 uint32_t default_time2wait; /* Default Min time between
46516 * relogins (+aens) */
46517 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46518 index f8a0a26..ec03cee 100644
46519 --- a/drivers/scsi/qla4xxx/ql4_os.c
46520 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46521 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46522 */
46523 if (!iscsi_is_session_online(cls_sess)) {
46524 /* Reset retry relogin timer */
46525 - atomic_inc(&ddb_entry->relogin_retry_count);
46526 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46527 DEBUG2(ql4_printk(KERN_INFO, ha,
46528 "%s: index[%d] relogin timed out-retrying"
46529 " relogin (%d), retry (%d)\n", __func__,
46530 ddb_entry->fw_ddb_index,
46531 - atomic_read(&ddb_entry->relogin_retry_count),
46532 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46533 ddb_entry->default_time2wait + 4));
46534 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46535 atomic_set(&ddb_entry->retry_relogin_timer,
46536 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46537
46538 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46539 atomic_set(&ddb_entry->relogin_timer, 0);
46540 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46541 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46542 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46543 ddb_entry->default_relogin_timeout =
46544 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46545 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46546 index eaa808e..95f8841 100644
46547 --- a/drivers/scsi/scsi.c
46548 +++ b/drivers/scsi/scsi.c
46549 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46550 unsigned long timeout;
46551 int rtn = 0;
46552
46553 - atomic_inc(&cmd->device->iorequest_cnt);
46554 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46555
46556 /* check if the device is still usable */
46557 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46558 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46559 index d1549b7..2f60767 100644
46560 --- a/drivers/scsi/scsi_lib.c
46561 +++ b/drivers/scsi/scsi_lib.c
46562 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46563 shost = sdev->host;
46564 scsi_init_cmd_errh(cmd);
46565 cmd->result = DID_NO_CONNECT << 16;
46566 - atomic_inc(&cmd->device->iorequest_cnt);
46567 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46568
46569 /*
46570 * SCSI request completion path will do scsi_device_unbusy(),
46571 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46572
46573 INIT_LIST_HEAD(&cmd->eh_entry);
46574
46575 - atomic_inc(&cmd->device->iodone_cnt);
46576 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46577 if (cmd->result)
46578 - atomic_inc(&cmd->device->ioerr_cnt);
46579 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46580
46581 disposition = scsi_decide_disposition(cmd);
46582 if (disposition != SUCCESS &&
46583 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46584 index 40c6394..62356c2 100644
46585 --- a/drivers/scsi/scsi_sysfs.c
46586 +++ b/drivers/scsi/scsi_sysfs.c
46587 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46588 char *buf) \
46589 { \
46590 struct scsi_device *sdev = to_scsi_device(dev); \
46591 - unsigned long long count = atomic_read(&sdev->field); \
46592 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46593 return snprintf(buf, 20, "0x%llx\n", count); \
46594 } \
46595 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46596 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46597 index 84a1fdf..693b0d6 100644
46598 --- a/drivers/scsi/scsi_tgt_lib.c
46599 +++ b/drivers/scsi/scsi_tgt_lib.c
46600 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46601 int err;
46602
46603 dprintk("%lx %u\n", uaddr, len);
46604 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46605 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46606 if (err) {
46607 /*
46608 * TODO: need to fixup sg_tablesize, max_segment_size,
46609 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46610 index 4628fd5..a94a1c2 100644
46611 --- a/drivers/scsi/scsi_transport_fc.c
46612 +++ b/drivers/scsi/scsi_transport_fc.c
46613 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46614 * Netlink Infrastructure
46615 */
46616
46617 -static atomic_t fc_event_seq;
46618 +static atomic_unchecked_t fc_event_seq;
46619
46620 /**
46621 * fc_get_event_number - Obtain the next sequential FC event number
46622 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46623 u32
46624 fc_get_event_number(void)
46625 {
46626 - return atomic_add_return(1, &fc_event_seq);
46627 + return atomic_add_return_unchecked(1, &fc_event_seq);
46628 }
46629 EXPORT_SYMBOL(fc_get_event_number);
46630
46631 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46632 {
46633 int error;
46634
46635 - atomic_set(&fc_event_seq, 0);
46636 + atomic_set_unchecked(&fc_event_seq, 0);
46637
46638 error = transport_class_register(&fc_host_class);
46639 if (error)
46640 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46641 char *cp;
46642
46643 *val = simple_strtoul(buf, &cp, 0);
46644 - if ((*cp && (*cp != '\n')) || (*val < 0))
46645 + if (*cp && (*cp != '\n'))
46646 return -EINVAL;
46647 /*
46648 * Check for overflow; dev_loss_tmo is u32
46649 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
46650 index e4a989f..293090c 100644
46651 --- a/drivers/scsi/scsi_transport_iscsi.c
46652 +++ b/drivers/scsi/scsi_transport_iscsi.c
46653 @@ -79,7 +79,7 @@ struct iscsi_internal {
46654 struct transport_container session_cont;
46655 };
46656
46657 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
46658 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
46659 static struct workqueue_struct *iscsi_eh_timer_workq;
46660
46661 static DEFINE_IDA(iscsi_sess_ida);
46662 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
46663 int err;
46664
46665 ihost = shost->shost_data;
46666 - session->sid = atomic_add_return(1, &iscsi_session_nr);
46667 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
46668
46669 if (target_id == ISCSI_MAX_TARGET) {
46670 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
46671 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
46672 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
46673 ISCSI_TRANSPORT_VERSION);
46674
46675 - atomic_set(&iscsi_session_nr, 0);
46676 + atomic_set_unchecked(&iscsi_session_nr, 0);
46677
46678 err = class_register(&iscsi_transport_class);
46679 if (err)
46680 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
46681 index f379c7f..e8fc69c 100644
46682 --- a/drivers/scsi/scsi_transport_srp.c
46683 +++ b/drivers/scsi/scsi_transport_srp.c
46684 @@ -33,7 +33,7 @@
46685 #include "scsi_transport_srp_internal.h"
46686
46687 struct srp_host_attrs {
46688 - atomic_t next_port_id;
46689 + atomic_unchecked_t next_port_id;
46690 };
46691 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
46692
46693 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
46694 struct Scsi_Host *shost = dev_to_shost(dev);
46695 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
46696
46697 - atomic_set(&srp_host->next_port_id, 0);
46698 + atomic_set_unchecked(&srp_host->next_port_id, 0);
46699 return 0;
46700 }
46701
46702 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
46703 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
46704 rport->roles = ids->roles;
46705
46706 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
46707 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
46708 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
46709
46710 transport_setup_device(&rport->dev);
46711 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
46712 index 5693f6d7..b0bf05a 100644
46713 --- a/drivers/scsi/sd.c
46714 +++ b/drivers/scsi/sd.c
46715 @@ -2934,7 +2934,7 @@ static int sd_probe(struct device *dev)
46716 sdkp->disk = gd;
46717 sdkp->index = index;
46718 atomic_set(&sdkp->openers, 0);
46719 - atomic_set(&sdkp->device->ioerr_cnt, 0);
46720 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
46721
46722 if (!sdp->request_queue->rq_timeout) {
46723 if (sdp->type != TYPE_MOD)
46724 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
46725 index df5e961..df6b97f 100644
46726 --- a/drivers/scsi/sg.c
46727 +++ b/drivers/scsi/sg.c
46728 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
46729 sdp->disk->disk_name,
46730 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
46731 NULL,
46732 - (char *)arg);
46733 + (char __user *)arg);
46734 case BLKTRACESTART:
46735 return blk_trace_startstop(sdp->device->request_queue, 1);
46736 case BLKTRACESTOP:
46737 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
46738 index 9e039c6..ae9e800 100644
46739 --- a/drivers/spi/spi.c
46740 +++ b/drivers/spi/spi.c
46741 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
46742 EXPORT_SYMBOL_GPL(spi_bus_unlock);
46743
46744 /* portable code must never pass more than 32 bytes */
46745 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
46746 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
46747
46748 static u8 *buf;
46749
46750 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
46751 index 2c61783..4d49e4e 100644
46752 --- a/drivers/staging/android/timed_output.c
46753 +++ b/drivers/staging/android/timed_output.c
46754 @@ -25,7 +25,7 @@
46755 #include "timed_output.h"
46756
46757 static struct class *timed_output_class;
46758 -static atomic_t device_count;
46759 +static atomic_unchecked_t device_count;
46760
46761 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
46762 char *buf)
46763 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
46764 timed_output_class = class_create(THIS_MODULE, "timed_output");
46765 if (IS_ERR(timed_output_class))
46766 return PTR_ERR(timed_output_class);
46767 - atomic_set(&device_count, 0);
46768 + atomic_set_unchecked(&device_count, 0);
46769 timed_output_class->dev_groups = timed_output_groups;
46770 }
46771
46772 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
46773 if (ret < 0)
46774 return ret;
46775
46776 - tdev->index = atomic_inc_return(&device_count);
46777 + tdev->index = atomic_inc_return_unchecked(&device_count);
46778 tdev->dev = device_create(timed_output_class, NULL,
46779 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
46780 if (IS_ERR(tdev->dev))
46781 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
46782 index 0247a20..cb9595c 100644
46783 --- a/drivers/staging/gdm724x/gdm_tty.c
46784 +++ b/drivers/staging/gdm724x/gdm_tty.c
46785 @@ -45,7 +45,7 @@
46786 #define gdm_tty_send_control(n, r, v, d, l) (\
46787 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
46788
46789 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
46790 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
46791
46792 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
46793 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
46794 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
46795 index ef5064e..fce01db 100644
46796 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
46797 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
46798 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
46799 return 0;
46800 }
46801
46802 -sfw_test_client_ops_t brw_test_client;
46803 -void brw_init_test_client(void)
46804 -{
46805 - brw_test_client.tso_init = brw_client_init;
46806 - brw_test_client.tso_fini = brw_client_fini;
46807 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
46808 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
46809 +sfw_test_client_ops_t brw_test_client = {
46810 + .tso_init = brw_client_init,
46811 + .tso_fini = brw_client_fini,
46812 + .tso_prep_rpc = brw_client_prep_rpc,
46813 + .tso_done_rpc = brw_client_done_rpc,
46814 };
46815
46816 srpc_service_t brw_test_service;
46817 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
46818 index 483c785..e1a2a7b 100644
46819 --- a/drivers/staging/lustre/lnet/selftest/framework.c
46820 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
46821 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
46822
46823 extern sfw_test_client_ops_t ping_test_client;
46824 extern srpc_service_t ping_test_service;
46825 -extern void ping_init_test_client(void);
46826 extern void ping_init_test_service(void);
46827
46828 extern sfw_test_client_ops_t brw_test_client;
46829 extern srpc_service_t brw_test_service;
46830 -extern void brw_init_test_client(void);
46831 extern void brw_init_test_service(void);
46832
46833
46834 @@ -1684,12 +1682,10 @@ sfw_startup (void)
46835 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
46836 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
46837
46838 - brw_init_test_client();
46839 brw_init_test_service();
46840 rc = sfw_register_test(&brw_test_service, &brw_test_client);
46841 LASSERT (rc == 0);
46842
46843 - ping_init_test_client();
46844 ping_init_test_service();
46845 rc = sfw_register_test(&ping_test_service, &ping_test_client);
46846 LASSERT (rc == 0);
46847 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
46848 index f0f9194..b589047 100644
46849 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
46850 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
46851 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
46852 return 0;
46853 }
46854
46855 -sfw_test_client_ops_t ping_test_client;
46856 -void ping_init_test_client(void)
46857 -{
46858 - ping_test_client.tso_init = ping_client_init;
46859 - ping_test_client.tso_fini = ping_client_fini;
46860 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
46861 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
46862 -}
46863 +sfw_test_client_ops_t ping_test_client = {
46864 + .tso_init = ping_client_init,
46865 + .tso_fini = ping_client_fini,
46866 + .tso_prep_rpc = ping_client_prep_rpc,
46867 + .tso_done_rpc = ping_client_done_rpc,
46868 +};
46869
46870 srpc_service_t ping_test_service;
46871 void ping_init_test_service(void)
46872 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46873 index 7020d9c..0d3b580 100644
46874 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
46875 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46876 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
46877 ldlm_completion_callback lcs_completion;
46878 ldlm_blocking_callback lcs_blocking;
46879 ldlm_glimpse_callback lcs_glimpse;
46880 -};
46881 +} __no_const;
46882
46883 /* ldlm_lockd.c */
46884 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
46885 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
46886 index a612255..9a9e2dd 100644
46887 --- a/drivers/staging/lustre/lustre/include/obd.h
46888 +++ b/drivers/staging/lustre/lustre/include/obd.h
46889 @@ -1417,7 +1417,7 @@ struct md_ops {
46890 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
46891 * wrapper function in include/linux/obd_class.h.
46892 */
46893 -};
46894 +} __no_const;
46895
46896 struct lsm_operations {
46897 void (*lsm_free)(struct lov_stripe_md *);
46898 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46899 index fc6c977..df1f956 100644
46900 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46901 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46902 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
46903 int LL_PROC_PROTO(proc_console_max_delay_cs)
46904 {
46905 int rc, max_delay_cs;
46906 - ctl_table_t dummy = *table;
46907 + ctl_table_no_const dummy = *table;
46908 cfs_duration_t d;
46909
46910 dummy.data = &max_delay_cs;
46911 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
46912 int LL_PROC_PROTO(proc_console_min_delay_cs)
46913 {
46914 int rc, min_delay_cs;
46915 - ctl_table_t dummy = *table;
46916 + ctl_table_no_const dummy = *table;
46917 cfs_duration_t d;
46918
46919 dummy.data = &min_delay_cs;
46920 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
46921 int LL_PROC_PROTO(proc_console_backoff)
46922 {
46923 int rc, backoff;
46924 - ctl_table_t dummy = *table;
46925 + ctl_table_no_const dummy = *table;
46926
46927 dummy.data = &backoff;
46928 dummy.proc_handler = &proc_dointvec;
46929 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
46930 index 3675020..e80d92c 100644
46931 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
46932 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
46933 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
46934
46935 static int solo_sysfs_init(struct solo_dev *solo_dev)
46936 {
46937 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
46938 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
46939 struct device *dev = &solo_dev->dev;
46940 const char *driver;
46941 int i;
46942 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46943 index 3335941..2b26186 100644
46944 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
46945 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46946 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
46947
46948 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
46949 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
46950 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
46951 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
46952 if (p2m_id < 0)
46953 p2m_id = -p2m_id;
46954 }
46955 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
46956 index 6f91d2e..3f011d2 100644
46957 --- a/drivers/staging/media/solo6x10/solo6x10.h
46958 +++ b/drivers/staging/media/solo6x10/solo6x10.h
46959 @@ -238,7 +238,7 @@ struct solo_dev {
46960
46961 /* P2M DMA Engine */
46962 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
46963 - atomic_t p2m_count;
46964 + atomic_unchecked_t p2m_count;
46965 int p2m_jiffies;
46966 unsigned int p2m_timeouts;
46967
46968 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
46969 index e14a1bb..9cb9bbe 100644
46970 --- a/drivers/staging/octeon/ethernet-rx.c
46971 +++ b/drivers/staging/octeon/ethernet-rx.c
46972 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
46973 /* Increment RX stats for virtual ports */
46974 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
46975 #ifdef CONFIG_64BIT
46976 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
46977 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
46978 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
46979 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
46980 #else
46981 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
46982 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
46983 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
46984 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
46985 #endif
46986 }
46987 netif_receive_skb(skb);
46988 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
46989 dev->name);
46990 */
46991 #ifdef CONFIG_64BIT
46992 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
46993 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
46994 #else
46995 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
46996 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
46997 #endif
46998 dev_kfree_skb_irq(skb);
46999 }
47000 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47001 index c3a90e7..023619a 100644
47002 --- a/drivers/staging/octeon/ethernet.c
47003 +++ b/drivers/staging/octeon/ethernet.c
47004 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47005 * since the RX tasklet also increments it.
47006 */
47007 #ifdef CONFIG_64BIT
47008 - atomic64_add(rx_status.dropped_packets,
47009 - (atomic64_t *)&priv->stats.rx_dropped);
47010 + atomic64_add_unchecked(rx_status.dropped_packets,
47011 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47012 #else
47013 - atomic_add(rx_status.dropped_packets,
47014 - (atomic_t *)&priv->stats.rx_dropped);
47015 + atomic_add_unchecked(rx_status.dropped_packets,
47016 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47017 #endif
47018 }
47019
47020 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47021 index 439c3c9..2d74293 100644
47022 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47023 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47024 @@ -271,7 +271,7 @@ struct hal_ops {
47025 s32 (*c2h_handler)(struct adapter *padapter,
47026 struct c2h_evt_hdr *c2h_evt);
47027 c2h_id_filter c2h_id_filter_ccx;
47028 -};
47029 +} __no_const;
47030
47031 enum rt_eeprom_type {
47032 EEPROM_93C46,
47033 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47034 index eb6f0e5..e6a0958 100644
47035 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47036 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47037 @@ -126,7 +126,7 @@ struct _io_ops {
47038 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47039 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47040 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47041 -};
47042 +} __no_const;
47043
47044 struct io_req {
47045 struct list_head list;
47046 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47047 index dc23395..cf7e9b1 100644
47048 --- a/drivers/staging/rtl8712/rtl871x_io.h
47049 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47050 @@ -108,7 +108,7 @@ struct _io_ops {
47051 u8 *pmem);
47052 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47053 u8 *pmem);
47054 -};
47055 +} __no_const;
47056
47057 struct io_req {
47058 struct list_head list;
47059 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47060 index 1f5088b..0e59820 100644
47061 --- a/drivers/staging/sbe-2t3e3/netdev.c
47062 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47063 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47064 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47065
47066 if (rlen)
47067 - if (copy_to_user(data, &resp, rlen))
47068 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47069 return -EFAULT;
47070
47071 return 0;
47072 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47073 index a863a98..d272795 100644
47074 --- a/drivers/staging/usbip/vhci.h
47075 +++ b/drivers/staging/usbip/vhci.h
47076 @@ -83,7 +83,7 @@ struct vhci_hcd {
47077 unsigned resuming:1;
47078 unsigned long re_timeout;
47079
47080 - atomic_t seqnum;
47081 + atomic_unchecked_t seqnum;
47082
47083 /*
47084 * NOTE:
47085 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47086 index d7974cb..d78076b 100644
47087 --- a/drivers/staging/usbip/vhci_hcd.c
47088 +++ b/drivers/staging/usbip/vhci_hcd.c
47089 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47090
47091 spin_lock(&vdev->priv_lock);
47092
47093 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47094 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47095 if (priv->seqnum == 0xffff)
47096 dev_info(&urb->dev->dev, "seqnum max\n");
47097
47098 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47099 return -ENOMEM;
47100 }
47101
47102 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47103 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47104 if (unlink->seqnum == 0xffff)
47105 pr_info("seqnum max\n");
47106
47107 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47108 vdev->rhport = rhport;
47109 }
47110
47111 - atomic_set(&vhci->seqnum, 0);
47112 + atomic_set_unchecked(&vhci->seqnum, 0);
47113 spin_lock_init(&vhci->lock);
47114
47115 hcd->power_budget = 0; /* no limit */
47116 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47117 index d07fcb5..358e1e1 100644
47118 --- a/drivers/staging/usbip/vhci_rx.c
47119 +++ b/drivers/staging/usbip/vhci_rx.c
47120 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47121 if (!urb) {
47122 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47123 pr_info("max seqnum %d\n",
47124 - atomic_read(&the_controller->seqnum));
47125 + atomic_read_unchecked(&the_controller->seqnum));
47126 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47127 return;
47128 }
47129 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47130 index 8acff44..bdb2fca 100644
47131 --- a/drivers/staging/vt6655/hostap.c
47132 +++ b/drivers/staging/vt6655/hostap.c
47133 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47134 *
47135 */
47136
47137 +static net_device_ops_no_const apdev_netdev_ops;
47138 +
47139 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47140 {
47141 PSDevice apdev_priv;
47142 struct net_device *dev = pDevice->dev;
47143 int ret;
47144 - const struct net_device_ops apdev_netdev_ops = {
47145 - .ndo_start_xmit = pDevice->tx_80211,
47146 - };
47147
47148 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47149
47150 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47151 *apdev_priv = *pDevice;
47152 eth_hw_addr_inherit(pDevice->apdev, dev);
47153
47154 + /* only half broken now */
47155 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47156 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47157
47158 pDevice->apdev->type = ARPHRD_IEEE80211;
47159 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47160 index c699a30..b90a5fd 100644
47161 --- a/drivers/staging/vt6656/hostap.c
47162 +++ b/drivers/staging/vt6656/hostap.c
47163 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47164 *
47165 */
47166
47167 +static net_device_ops_no_const apdev_netdev_ops;
47168 +
47169 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47170 {
47171 struct vnt_private *apdev_priv;
47172 struct net_device *dev = pDevice->dev;
47173 int ret;
47174 - const struct net_device_ops apdev_netdev_ops = {
47175 - .ndo_start_xmit = pDevice->tx_80211,
47176 - };
47177
47178 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47179
47180 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47181 *apdev_priv = *pDevice;
47182 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47183
47184 + /* only half broken now */
47185 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47186 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47187
47188 pDevice->apdev->type = ARPHRD_IEEE80211;
47189 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47190 index e51b09a..5ebac31 100644
47191 --- a/drivers/target/sbp/sbp_target.c
47192 +++ b/drivers/target/sbp/sbp_target.c
47193 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47194
47195 #define SESSION_MAINTENANCE_INTERVAL HZ
47196
47197 -static atomic_t login_id = ATOMIC_INIT(0);
47198 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47199
47200 static void session_maintenance_work(struct work_struct *);
47201 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47202 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47203 login->lun = se_lun;
47204 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47205 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47206 - login->login_id = atomic_inc_return(&login_id);
47207 + login->login_id = atomic_inc_return_unchecked(&login_id);
47208
47209 login->tgt_agt = sbp_target_agent_register(login);
47210 if (IS_ERR(login->tgt_agt)) {
47211 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47212 index d90dbb0..6cbe585 100644
47213 --- a/drivers/target/target_core_device.c
47214 +++ b/drivers/target/target_core_device.c
47215 @@ -1431,7 +1431,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47216 spin_lock_init(&dev->se_tmr_lock);
47217 spin_lock_init(&dev->qf_cmd_lock);
47218 sema_init(&dev->caw_sem, 1);
47219 - atomic_set(&dev->dev_ordered_id, 0);
47220 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47221 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47222 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47223 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47224 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47225 index 81e945e..e40c92f 100644
47226 --- a/drivers/target/target_core_transport.c
47227 +++ b/drivers/target/target_core_transport.c
47228 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47229 * Used to determine when ORDERED commands should go from
47230 * Dormant to Active status.
47231 */
47232 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47233 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47234 smp_mb__after_atomic_inc();
47235 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47236 cmd->se_ordered_id, cmd->sam_task_attr,
47237 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47238 index 33f83fe..d80f8e1 100644
47239 --- a/drivers/tty/cyclades.c
47240 +++ b/drivers/tty/cyclades.c
47241 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47242 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47243 info->port.count);
47244 #endif
47245 - info->port.count++;
47246 + atomic_inc(&info->port.count);
47247 #ifdef CY_DEBUG_COUNT
47248 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47249 - current->pid, info->port.count);
47250 + current->pid, atomic_read(&info->port.count));
47251 #endif
47252
47253 /*
47254 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47255 for (j = 0; j < cy_card[i].nports; j++) {
47256 info = &cy_card[i].ports[j];
47257
47258 - if (info->port.count) {
47259 + if (atomic_read(&info->port.count)) {
47260 /* XXX is the ldisc num worth this? */
47261 struct tty_struct *tty;
47262 struct tty_ldisc *ld;
47263 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47264 index 9eba119..5070303 100644
47265 --- a/drivers/tty/hvc/hvc_console.c
47266 +++ b/drivers/tty/hvc/hvc_console.c
47267 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47268
47269 spin_lock_irqsave(&hp->port.lock, flags);
47270 /* Check and then increment for fast path open. */
47271 - if (hp->port.count++ > 0) {
47272 + if (atomic_inc_return(&hp->port.count) > 1) {
47273 spin_unlock_irqrestore(&hp->port.lock, flags);
47274 hvc_kick();
47275 return 0;
47276 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47277
47278 spin_lock_irqsave(&hp->port.lock, flags);
47279
47280 - if (--hp->port.count == 0) {
47281 + if (atomic_dec_return(&hp->port.count) == 0) {
47282 spin_unlock_irqrestore(&hp->port.lock, flags);
47283 /* We are done with the tty pointer now. */
47284 tty_port_tty_set(&hp->port, NULL);
47285 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47286 */
47287 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47288 } else {
47289 - if (hp->port.count < 0)
47290 + if (atomic_read(&hp->port.count) < 0)
47291 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47292 - hp->vtermno, hp->port.count);
47293 + hp->vtermno, atomic_read(&hp->port.count));
47294 spin_unlock_irqrestore(&hp->port.lock, flags);
47295 }
47296 }
47297 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
47298 * open->hangup case this can be called after the final close so prevent
47299 * that from happening for now.
47300 */
47301 - if (hp->port.count <= 0) {
47302 + if (atomic_read(&hp->port.count) <= 0) {
47303 spin_unlock_irqrestore(&hp->port.lock, flags);
47304 return;
47305 }
47306
47307 - hp->port.count = 0;
47308 + atomic_set(&hp->port.count, 0);
47309 spin_unlock_irqrestore(&hp->port.lock, flags);
47310 tty_port_tty_set(&hp->port, NULL);
47311
47312 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47313 return -EPIPE;
47314
47315 /* FIXME what's this (unprotected) check for? */
47316 - if (hp->port.count <= 0)
47317 + if (atomic_read(&hp->port.count) <= 0)
47318 return -EIO;
47319
47320 spin_lock_irqsave(&hp->lock, flags);
47321 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47322 index 81e939e..95ead10 100644
47323 --- a/drivers/tty/hvc/hvcs.c
47324 +++ b/drivers/tty/hvc/hvcs.c
47325 @@ -83,6 +83,7 @@
47326 #include <asm/hvcserver.h>
47327 #include <asm/uaccess.h>
47328 #include <asm/vio.h>
47329 +#include <asm/local.h>
47330
47331 /*
47332 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47333 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47334
47335 spin_lock_irqsave(&hvcsd->lock, flags);
47336
47337 - if (hvcsd->port.count > 0) {
47338 + if (atomic_read(&hvcsd->port.count) > 0) {
47339 spin_unlock_irqrestore(&hvcsd->lock, flags);
47340 printk(KERN_INFO "HVCS: vterm state unchanged. "
47341 "The hvcs device node is still in use.\n");
47342 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47343 }
47344 }
47345
47346 - hvcsd->port.count = 0;
47347 + atomic_set(&hvcsd->port.count, 0);
47348 hvcsd->port.tty = tty;
47349 tty->driver_data = hvcsd;
47350
47351 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47352 unsigned long flags;
47353
47354 spin_lock_irqsave(&hvcsd->lock, flags);
47355 - hvcsd->port.count++;
47356 + atomic_inc(&hvcsd->port.count);
47357 hvcsd->todo_mask |= HVCS_SCHED_READ;
47358 spin_unlock_irqrestore(&hvcsd->lock, flags);
47359
47360 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47361 hvcsd = tty->driver_data;
47362
47363 spin_lock_irqsave(&hvcsd->lock, flags);
47364 - if (--hvcsd->port.count == 0) {
47365 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47366
47367 vio_disable_interrupts(hvcsd->vdev);
47368
47369 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47370
47371 free_irq(irq, hvcsd);
47372 return;
47373 - } else if (hvcsd->port.count < 0) {
47374 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47375 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47376 " is missmanaged.\n",
47377 - hvcsd->vdev->unit_address, hvcsd->port.count);
47378 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47379 }
47380
47381 spin_unlock_irqrestore(&hvcsd->lock, flags);
47382 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47383
47384 spin_lock_irqsave(&hvcsd->lock, flags);
47385 /* Preserve this so that we know how many kref refs to put */
47386 - temp_open_count = hvcsd->port.count;
47387 + temp_open_count = atomic_read(&hvcsd->port.count);
47388
47389 /*
47390 * Don't kref put inside the spinlock because the destruction
47391 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47392 tty->driver_data = NULL;
47393 hvcsd->port.tty = NULL;
47394
47395 - hvcsd->port.count = 0;
47396 + atomic_set(&hvcsd->port.count, 0);
47397
47398 /* This will drop any buffered data on the floor which is OK in a hangup
47399 * scenario. */
47400 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47401 * the middle of a write operation? This is a crummy place to do this
47402 * but we want to keep it all in the spinlock.
47403 */
47404 - if (hvcsd->port.count <= 0) {
47405 + if (atomic_read(&hvcsd->port.count) <= 0) {
47406 spin_unlock_irqrestore(&hvcsd->lock, flags);
47407 return -ENODEV;
47408 }
47409 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47410 {
47411 struct hvcs_struct *hvcsd = tty->driver_data;
47412
47413 - if (!hvcsd || hvcsd->port.count <= 0)
47414 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47415 return 0;
47416
47417 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47418 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47419 index 4190199..48f2920 100644
47420 --- a/drivers/tty/hvc/hvsi.c
47421 +++ b/drivers/tty/hvc/hvsi.c
47422 @@ -85,7 +85,7 @@ struct hvsi_struct {
47423 int n_outbuf;
47424 uint32_t vtermno;
47425 uint32_t virq;
47426 - atomic_t seqno; /* HVSI packet sequence number */
47427 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47428 uint16_t mctrl;
47429 uint8_t state; /* HVSI protocol state */
47430 uint8_t flags;
47431 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47432
47433 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47434 packet.hdr.len = sizeof(struct hvsi_query_response);
47435 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47436 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47437 packet.verb = VSV_SEND_VERSION_NUMBER;
47438 packet.u.version = HVSI_VERSION;
47439 packet.query_seqno = query_seqno+1;
47440 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47441
47442 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47443 packet.hdr.len = sizeof(struct hvsi_query);
47444 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47445 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47446 packet.verb = verb;
47447
47448 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47449 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47450 int wrote;
47451
47452 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47453 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47454 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47455 packet.hdr.len = sizeof(struct hvsi_control);
47456 packet.verb = VSV_SET_MODEM_CTL;
47457 packet.mask = HVSI_TSDTR;
47458 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47459 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47460
47461 packet.hdr.type = VS_DATA_PACKET_HEADER;
47462 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47463 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47464 packet.hdr.len = count + sizeof(struct hvsi_header);
47465 memcpy(&packet.data, buf, count);
47466
47467 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47468 struct hvsi_control packet __ALIGNED__;
47469
47470 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47471 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47472 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47473 packet.hdr.len = 6;
47474 packet.verb = VSV_CLOSE_PROTOCOL;
47475
47476 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47477 index ac27671..0f627ee 100644
47478 --- a/drivers/tty/hvc/hvsi_lib.c
47479 +++ b/drivers/tty/hvc/hvsi_lib.c
47480 @@ -9,7 +9,7 @@
47481
47482 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47483 {
47484 - packet->seqno = atomic_inc_return(&pv->seqno);
47485 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47486
47487 /* Assumes that always succeeds, works in practice */
47488 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47489 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47490
47491 /* Reset state */
47492 pv->established = 0;
47493 - atomic_set(&pv->seqno, 0);
47494 + atomic_set_unchecked(&pv->seqno, 0);
47495
47496 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47497
47498 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47499 pv->mctrl_update = 0;
47500 q.hdr.type = VS_QUERY_PACKET_HEADER;
47501 q.hdr.len = sizeof(struct hvsi_query);
47502 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47503 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47504 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47505 rc = hvsi_send_packet(pv, &q.hdr);
47506 if (rc <= 0) {
47507 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47508 index 8fd72ff..34a0bed 100644
47509 --- a/drivers/tty/ipwireless/tty.c
47510 +++ b/drivers/tty/ipwireless/tty.c
47511 @@ -29,6 +29,7 @@
47512 #include <linux/tty_driver.h>
47513 #include <linux/tty_flip.h>
47514 #include <linux/uaccess.h>
47515 +#include <asm/local.h>
47516
47517 #include "tty.h"
47518 #include "network.h"
47519 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47520 mutex_unlock(&tty->ipw_tty_mutex);
47521 return -ENODEV;
47522 }
47523 - if (tty->port.count == 0)
47524 + if (atomic_read(&tty->port.count) == 0)
47525 tty->tx_bytes_queued = 0;
47526
47527 - tty->port.count++;
47528 + atomic_inc(&tty->port.count);
47529
47530 tty->port.tty = linux_tty;
47531 linux_tty->driver_data = tty;
47532 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47533
47534 static void do_ipw_close(struct ipw_tty *tty)
47535 {
47536 - tty->port.count--;
47537 -
47538 - if (tty->port.count == 0) {
47539 + if (atomic_dec_return(&tty->port.count) == 0) {
47540 struct tty_struct *linux_tty = tty->port.tty;
47541
47542 if (linux_tty != NULL) {
47543 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47544 return;
47545
47546 mutex_lock(&tty->ipw_tty_mutex);
47547 - if (tty->port.count == 0) {
47548 + if (atomic_read(&tty->port.count) == 0) {
47549 mutex_unlock(&tty->ipw_tty_mutex);
47550 return;
47551 }
47552 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47553
47554 mutex_lock(&tty->ipw_tty_mutex);
47555
47556 - if (!tty->port.count) {
47557 + if (!atomic_read(&tty->port.count)) {
47558 mutex_unlock(&tty->ipw_tty_mutex);
47559 return;
47560 }
47561 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47562 return -ENODEV;
47563
47564 mutex_lock(&tty->ipw_tty_mutex);
47565 - if (!tty->port.count) {
47566 + if (!atomic_read(&tty->port.count)) {
47567 mutex_unlock(&tty->ipw_tty_mutex);
47568 return -EINVAL;
47569 }
47570 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47571 if (!tty)
47572 return -ENODEV;
47573
47574 - if (!tty->port.count)
47575 + if (!atomic_read(&tty->port.count))
47576 return -EINVAL;
47577
47578 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47579 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47580 if (!tty)
47581 return 0;
47582
47583 - if (!tty->port.count)
47584 + if (!atomic_read(&tty->port.count))
47585 return 0;
47586
47587 return tty->tx_bytes_queued;
47588 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47589 if (!tty)
47590 return -ENODEV;
47591
47592 - if (!tty->port.count)
47593 + if (!atomic_read(&tty->port.count))
47594 return -EINVAL;
47595
47596 return get_control_lines(tty);
47597 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47598 if (!tty)
47599 return -ENODEV;
47600
47601 - if (!tty->port.count)
47602 + if (!atomic_read(&tty->port.count))
47603 return -EINVAL;
47604
47605 return set_control_lines(tty, set, clear);
47606 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47607 if (!tty)
47608 return -ENODEV;
47609
47610 - if (!tty->port.count)
47611 + if (!atomic_read(&tty->port.count))
47612 return -EINVAL;
47613
47614 /* FIXME: Exactly how is the tty object locked here .. */
47615 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47616 * are gone */
47617 mutex_lock(&ttyj->ipw_tty_mutex);
47618 }
47619 - while (ttyj->port.count)
47620 + while (atomic_read(&ttyj->port.count))
47621 do_ipw_close(ttyj);
47622 ipwireless_disassociate_network_ttys(network,
47623 ttyj->channel_idx);
47624 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47625 index 1deaca4..c8582d4 100644
47626 --- a/drivers/tty/moxa.c
47627 +++ b/drivers/tty/moxa.c
47628 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47629 }
47630
47631 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47632 - ch->port.count++;
47633 + atomic_inc(&ch->port.count);
47634 tty->driver_data = ch;
47635 tty_port_tty_set(&ch->port, tty);
47636 mutex_lock(&ch->port.mutex);
47637 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47638 index c0f76da..d974c32 100644
47639 --- a/drivers/tty/n_gsm.c
47640 +++ b/drivers/tty/n_gsm.c
47641 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47642 spin_lock_init(&dlci->lock);
47643 mutex_init(&dlci->mutex);
47644 dlci->fifo = &dlci->_fifo;
47645 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47646 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47647 kfree(dlci);
47648 return NULL;
47649 }
47650 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47651 struct gsm_dlci *dlci = tty->driver_data;
47652 struct tty_port *port = &dlci->port;
47653
47654 - port->count++;
47655 + atomic_inc(&port->count);
47656 dlci_get(dlci);
47657 dlci_get(dlci->gsm->dlci[0]);
47658 mux_get(dlci->gsm);
47659 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47660 index 7a744b6..6aa4aa9 100644
47661 --- a/drivers/tty/n_tty.c
47662 +++ b/drivers/tty/n_tty.c
47663 @@ -2498,6 +2498,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47664 {
47665 *ops = tty_ldisc_N_TTY;
47666 ops->owner = NULL;
47667 - ops->refcount = ops->flags = 0;
47668 + atomic_set(&ops->refcount, 0);
47669 + ops->flags = 0;
47670 }
47671 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47672 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47673 index 25c9bc7..24077b7 100644
47674 --- a/drivers/tty/pty.c
47675 +++ b/drivers/tty/pty.c
47676 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
47677 panic("Couldn't register Unix98 pts driver");
47678
47679 /* Now create the /dev/ptmx special device */
47680 + pax_open_kernel();
47681 tty_default_fops(&ptmx_fops);
47682 - ptmx_fops.open = ptmx_open;
47683 + *(void **)&ptmx_fops.open = ptmx_open;
47684 + pax_close_kernel();
47685
47686 cdev_init(&ptmx_cdev, &ptmx_fops);
47687 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47688 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47689 index 354564e..fe50d9a 100644
47690 --- a/drivers/tty/rocket.c
47691 +++ b/drivers/tty/rocket.c
47692 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47693 tty->driver_data = info;
47694 tty_port_tty_set(port, tty);
47695
47696 - if (port->count++ == 0) {
47697 + if (atomic_inc_return(&port->count) == 1) {
47698 atomic_inc(&rp_num_ports_open);
47699
47700 #ifdef ROCKET_DEBUG_OPEN
47701 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47702 #endif
47703 }
47704 #ifdef ROCKET_DEBUG_OPEN
47705 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47706 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47707 #endif
47708
47709 /*
47710 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47711 spin_unlock_irqrestore(&info->port.lock, flags);
47712 return;
47713 }
47714 - if (info->port.count)
47715 + if (atomic_read(&info->port.count))
47716 atomic_dec(&rp_num_ports_open);
47717 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47718 spin_unlock_irqrestore(&info->port.lock, flags);
47719 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47720 index 1274499..f541382 100644
47721 --- a/drivers/tty/serial/ioc4_serial.c
47722 +++ b/drivers/tty/serial/ioc4_serial.c
47723 @@ -437,7 +437,7 @@ struct ioc4_soft {
47724 } is_intr_info[MAX_IOC4_INTR_ENTS];
47725
47726 /* Number of entries active in the above array */
47727 - atomic_t is_num_intrs;
47728 + atomic_unchecked_t is_num_intrs;
47729 } is_intr_type[IOC4_NUM_INTR_TYPES];
47730
47731 /* is_ir_lock must be held while
47732 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47733 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47734 || (type == IOC4_OTHER_INTR_TYPE)));
47735
47736 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47737 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47738 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47739
47740 /* Save off the lower level interrupt handler */
47741 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47742
47743 soft = arg;
47744 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47745 - num_intrs = (int)atomic_read(
47746 + num_intrs = (int)atomic_read_unchecked(
47747 &soft->is_intr_type[intr_type].is_num_intrs);
47748
47749 this_mir = this_ir = pending_intrs(soft, intr_type);
47750 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47751 index a260cde..6b2b5ce 100644
47752 --- a/drivers/tty/serial/kgdboc.c
47753 +++ b/drivers/tty/serial/kgdboc.c
47754 @@ -24,8 +24,9 @@
47755 #define MAX_CONFIG_LEN 40
47756
47757 static struct kgdb_io kgdboc_io_ops;
47758 +static struct kgdb_io kgdboc_io_ops_console;
47759
47760 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47761 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47762 static int configured = -1;
47763
47764 static char config[MAX_CONFIG_LEN];
47765 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
47766 kgdboc_unregister_kbd();
47767 if (configured == 1)
47768 kgdb_unregister_io_module(&kgdboc_io_ops);
47769 + else if (configured == 2)
47770 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
47771 }
47772
47773 static int configure_kgdboc(void)
47774 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
47775 int err;
47776 char *cptr = config;
47777 struct console *cons;
47778 + int is_console = 0;
47779
47780 err = kgdboc_option_setup(config);
47781 if (err || !strlen(config) || isspace(config[0]))
47782 goto noconfig;
47783
47784 err = -ENODEV;
47785 - kgdboc_io_ops.is_console = 0;
47786 kgdb_tty_driver = NULL;
47787
47788 kgdboc_use_kms = 0;
47789 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
47790 int idx;
47791 if (cons->device && cons->device(cons, &idx) == p &&
47792 idx == tty_line) {
47793 - kgdboc_io_ops.is_console = 1;
47794 + is_console = 1;
47795 break;
47796 }
47797 cons = cons->next;
47798 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
47799 kgdb_tty_line = tty_line;
47800
47801 do_register:
47802 - err = kgdb_register_io_module(&kgdboc_io_ops);
47803 + if (is_console) {
47804 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
47805 + configured = 2;
47806 + } else {
47807 + err = kgdb_register_io_module(&kgdboc_io_ops);
47808 + configured = 1;
47809 + }
47810 if (err)
47811 goto noconfig;
47812
47813 @@ -205,8 +214,6 @@ do_register:
47814 if (err)
47815 goto nmi_con_failed;
47816
47817 - configured = 1;
47818 -
47819 return 0;
47820
47821 nmi_con_failed:
47822 @@ -223,7 +230,7 @@ noconfig:
47823 static int __init init_kgdboc(void)
47824 {
47825 /* Already configured? */
47826 - if (configured == 1)
47827 + if (configured >= 1)
47828 return 0;
47829
47830 return configure_kgdboc();
47831 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
47832 if (config[len - 1] == '\n')
47833 config[len - 1] = '\0';
47834
47835 - if (configured == 1)
47836 + if (configured >= 1)
47837 cleanup_kgdboc();
47838
47839 /* Go and configure with the new params. */
47840 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
47841 .post_exception = kgdboc_post_exp_handler,
47842 };
47843
47844 +static struct kgdb_io kgdboc_io_ops_console = {
47845 + .name = "kgdboc",
47846 + .read_char = kgdboc_get_char,
47847 + .write_char = kgdboc_put_char,
47848 + .pre_exception = kgdboc_pre_exp_handler,
47849 + .post_exception = kgdboc_post_exp_handler,
47850 + .is_console = 1
47851 +};
47852 +
47853 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
47854 /* This is only available if kgdboc is a built in for early debugging */
47855 static int __init kgdboc_early_init(char *opt)
47856 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
47857 index b5d779c..3622cfe 100644
47858 --- a/drivers/tty/serial/msm_serial.c
47859 +++ b/drivers/tty/serial/msm_serial.c
47860 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
47861 .cons = MSM_CONSOLE,
47862 };
47863
47864 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
47865 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
47866
47867 static const struct of_device_id msm_uartdm_table[] = {
47868 { .compatible = "qcom,msm-uartdm" },
47869 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
47870 int irq;
47871
47872 if (pdev->id == -1)
47873 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
47874 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
47875
47876 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
47877 return -ENXIO;
47878 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
47879 index f3dfa19..342f2ff 100644
47880 --- a/drivers/tty/serial/samsung.c
47881 +++ b/drivers/tty/serial/samsung.c
47882 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
47883 }
47884 }
47885
47886 +static int s3c64xx_serial_startup(struct uart_port *port);
47887 static int s3c24xx_serial_startup(struct uart_port *port)
47888 {
47889 struct s3c24xx_uart_port *ourport = to_ourport(port);
47890 int ret;
47891
47892 + /* Startup sequence is different for s3c64xx and higher SoC's */
47893 + if (s3c24xx_serial_has_interrupt_mask(port))
47894 + return s3c64xx_serial_startup(port);
47895 +
47896 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
47897 port->mapbase, port->membase);
47898
47899 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
47900 /* setup info for port */
47901 port->dev = &platdev->dev;
47902
47903 - /* Startup sequence is different for s3c64xx and higher SoC's */
47904 - if (s3c24xx_serial_has_interrupt_mask(port))
47905 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
47906 -
47907 port->uartclk = 1;
47908
47909 if (cfg->uart_flags & UPF_CONS_FLOW) {
47910 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
47911 index 0f02351..07c59c5 100644
47912 --- a/drivers/tty/serial/serial_core.c
47913 +++ b/drivers/tty/serial/serial_core.c
47914 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
47915 uart_flush_buffer(tty);
47916 uart_shutdown(tty, state);
47917 spin_lock_irqsave(&port->lock, flags);
47918 - port->count = 0;
47919 + atomic_set(&port->count, 0);
47920 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
47921 spin_unlock_irqrestore(&port->lock, flags);
47922 tty_port_tty_set(port, NULL);
47923 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47924 goto end;
47925 }
47926
47927 - port->count++;
47928 + atomic_inc(&port->count);
47929 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
47930 retval = -ENXIO;
47931 goto err_dec_count;
47932 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47933 /*
47934 * Make sure the device is in D0 state.
47935 */
47936 - if (port->count == 1)
47937 + if (atomic_read(&port->count) == 1)
47938 uart_change_pm(state, UART_PM_STATE_ON);
47939
47940 /*
47941 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47942 end:
47943 return retval;
47944 err_dec_count:
47945 - port->count--;
47946 + atomic_inc(&port->count);
47947 mutex_unlock(&port->mutex);
47948 goto end;
47949 }
47950 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
47951 index e1ce141..6d4ed80 100644
47952 --- a/drivers/tty/synclink.c
47953 +++ b/drivers/tty/synclink.c
47954 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47955
47956 if (debug_level >= DEBUG_LEVEL_INFO)
47957 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
47958 - __FILE__,__LINE__, info->device_name, info->port.count);
47959 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
47960
47961 if (tty_port_close_start(&info->port, tty, filp) == 0)
47962 goto cleanup;
47963 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47964 cleanup:
47965 if (debug_level >= DEBUG_LEVEL_INFO)
47966 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
47967 - tty->driver->name, info->port.count);
47968 + tty->driver->name, atomic_read(&info->port.count));
47969
47970 } /* end of mgsl_close() */
47971
47972 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
47973
47974 mgsl_flush_buffer(tty);
47975 shutdown(info);
47976 -
47977 - info->port.count = 0;
47978 +
47979 + atomic_set(&info->port.count, 0);
47980 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
47981 info->port.tty = NULL;
47982
47983 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
47984
47985 if (debug_level >= DEBUG_LEVEL_INFO)
47986 printk("%s(%d):block_til_ready before block on %s count=%d\n",
47987 - __FILE__,__LINE__, tty->driver->name, port->count );
47988 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
47989
47990 spin_lock_irqsave(&info->irq_spinlock, flags);
47991 if (!tty_hung_up_p(filp)) {
47992 extra_count = true;
47993 - port->count--;
47994 + atomic_dec(&port->count);
47995 }
47996 spin_unlock_irqrestore(&info->irq_spinlock, flags);
47997 port->blocked_open++;
47998 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
47999
48000 if (debug_level >= DEBUG_LEVEL_INFO)
48001 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48002 - __FILE__,__LINE__, tty->driver->name, port->count );
48003 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48004
48005 tty_unlock(tty);
48006 schedule();
48007 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48008
48009 /* FIXME: Racy on hangup during close wait */
48010 if (extra_count)
48011 - port->count++;
48012 + atomic_inc(&port->count);
48013 port->blocked_open--;
48014
48015 if (debug_level >= DEBUG_LEVEL_INFO)
48016 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48017 - __FILE__,__LINE__, tty->driver->name, port->count );
48018 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48019
48020 if (!retval)
48021 port->flags |= ASYNC_NORMAL_ACTIVE;
48022 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48023
48024 if (debug_level >= DEBUG_LEVEL_INFO)
48025 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48026 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48027 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48028
48029 /* If port is closing, signal caller to try again */
48030 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48031 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48032 spin_unlock_irqrestore(&info->netlock, flags);
48033 goto cleanup;
48034 }
48035 - info->port.count++;
48036 + atomic_inc(&info->port.count);
48037 spin_unlock_irqrestore(&info->netlock, flags);
48038
48039 - if (info->port.count == 1) {
48040 + if (atomic_read(&info->port.count) == 1) {
48041 /* 1st open on this device, init hardware */
48042 retval = startup(info);
48043 if (retval < 0)
48044 @@ -3446,8 +3446,8 @@ cleanup:
48045 if (retval) {
48046 if (tty->count == 1)
48047 info->port.tty = NULL; /* tty layer will release tty struct */
48048 - if(info->port.count)
48049 - info->port.count--;
48050 + if (atomic_read(&info->port.count))
48051 + atomic_dec(&info->port.count);
48052 }
48053
48054 return retval;
48055 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48056 unsigned short new_crctype;
48057
48058 /* return error if TTY interface open */
48059 - if (info->port.count)
48060 + if (atomic_read(&info->port.count))
48061 return -EBUSY;
48062
48063 switch (encoding)
48064 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48065
48066 /* arbitrate between network and tty opens */
48067 spin_lock_irqsave(&info->netlock, flags);
48068 - if (info->port.count != 0 || info->netcount != 0) {
48069 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48070 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48071 spin_unlock_irqrestore(&info->netlock, flags);
48072 return -EBUSY;
48073 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48074 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48075
48076 /* return error if TTY interface open */
48077 - if (info->port.count)
48078 + if (atomic_read(&info->port.count))
48079 return -EBUSY;
48080
48081 if (cmd != SIOCWANDEV)
48082 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48083 index 1abf946..1ee34fc 100644
48084 --- a/drivers/tty/synclink_gt.c
48085 +++ b/drivers/tty/synclink_gt.c
48086 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48087 tty->driver_data = info;
48088 info->port.tty = tty;
48089
48090 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48091 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48092
48093 /* If port is closing, signal caller to try again */
48094 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48095 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48096 mutex_unlock(&info->port.mutex);
48097 goto cleanup;
48098 }
48099 - info->port.count++;
48100 + atomic_inc(&info->port.count);
48101 spin_unlock_irqrestore(&info->netlock, flags);
48102
48103 - if (info->port.count == 1) {
48104 + if (atomic_read(&info->port.count) == 1) {
48105 /* 1st open on this device, init hardware */
48106 retval = startup(info);
48107 if (retval < 0) {
48108 @@ -715,8 +715,8 @@ cleanup:
48109 if (retval) {
48110 if (tty->count == 1)
48111 info->port.tty = NULL; /* tty layer will release tty struct */
48112 - if(info->port.count)
48113 - info->port.count--;
48114 + if(atomic_read(&info->port.count))
48115 + atomic_dec(&info->port.count);
48116 }
48117
48118 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48119 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48120
48121 if (sanity_check(info, tty->name, "close"))
48122 return;
48123 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48124 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48125
48126 if (tty_port_close_start(&info->port, tty, filp) == 0)
48127 goto cleanup;
48128 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48129 tty_port_close_end(&info->port, tty);
48130 info->port.tty = NULL;
48131 cleanup:
48132 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48133 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48134 }
48135
48136 static void hangup(struct tty_struct *tty)
48137 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48138 shutdown(info);
48139
48140 spin_lock_irqsave(&info->port.lock, flags);
48141 - info->port.count = 0;
48142 + atomic_set(&info->port.count, 0);
48143 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48144 info->port.tty = NULL;
48145 spin_unlock_irqrestore(&info->port.lock, flags);
48146 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48147 unsigned short new_crctype;
48148
48149 /* return error if TTY interface open */
48150 - if (info->port.count)
48151 + if (atomic_read(&info->port.count))
48152 return -EBUSY;
48153
48154 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48155 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48156
48157 /* arbitrate between network and tty opens */
48158 spin_lock_irqsave(&info->netlock, flags);
48159 - if (info->port.count != 0 || info->netcount != 0) {
48160 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48161 DBGINFO(("%s hdlc_open busy\n", dev->name));
48162 spin_unlock_irqrestore(&info->netlock, flags);
48163 return -EBUSY;
48164 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48165 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48166
48167 /* return error if TTY interface open */
48168 - if (info->port.count)
48169 + if (atomic_read(&info->port.count))
48170 return -EBUSY;
48171
48172 if (cmd != SIOCWANDEV)
48173 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48174 if (port == NULL)
48175 continue;
48176 spin_lock(&port->lock);
48177 - if ((port->port.count || port->netcount) &&
48178 + if ((atomic_read(&port->port.count) || port->netcount) &&
48179 port->pending_bh && !port->bh_running &&
48180 !port->bh_requested) {
48181 DBGISR(("%s bh queued\n", port->device_name));
48182 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48183 spin_lock_irqsave(&info->lock, flags);
48184 if (!tty_hung_up_p(filp)) {
48185 extra_count = true;
48186 - port->count--;
48187 + atomic_dec(&port->count);
48188 }
48189 spin_unlock_irqrestore(&info->lock, flags);
48190 port->blocked_open++;
48191 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48192 remove_wait_queue(&port->open_wait, &wait);
48193
48194 if (extra_count)
48195 - port->count++;
48196 + atomic_inc(&port->count);
48197 port->blocked_open--;
48198
48199 if (!retval)
48200 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48201 index dc6e969..5dc8786 100644
48202 --- a/drivers/tty/synclinkmp.c
48203 +++ b/drivers/tty/synclinkmp.c
48204 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48205
48206 if (debug_level >= DEBUG_LEVEL_INFO)
48207 printk("%s(%d):%s open(), old ref count = %d\n",
48208 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48209 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48210
48211 /* If port is closing, signal caller to try again */
48212 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48213 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48214 spin_unlock_irqrestore(&info->netlock, flags);
48215 goto cleanup;
48216 }
48217 - info->port.count++;
48218 + atomic_inc(&info->port.count);
48219 spin_unlock_irqrestore(&info->netlock, flags);
48220
48221 - if (info->port.count == 1) {
48222 + if (atomic_read(&info->port.count) == 1) {
48223 /* 1st open on this device, init hardware */
48224 retval = startup(info);
48225 if (retval < 0)
48226 @@ -796,8 +796,8 @@ cleanup:
48227 if (retval) {
48228 if (tty->count == 1)
48229 info->port.tty = NULL; /* tty layer will release tty struct */
48230 - if(info->port.count)
48231 - info->port.count--;
48232 + if(atomic_read(&info->port.count))
48233 + atomic_dec(&info->port.count);
48234 }
48235
48236 return retval;
48237 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48238
48239 if (debug_level >= DEBUG_LEVEL_INFO)
48240 printk("%s(%d):%s close() entry, count=%d\n",
48241 - __FILE__,__LINE__, info->device_name, info->port.count);
48242 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48243
48244 if (tty_port_close_start(&info->port, tty, filp) == 0)
48245 goto cleanup;
48246 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48247 cleanup:
48248 if (debug_level >= DEBUG_LEVEL_INFO)
48249 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48250 - tty->driver->name, info->port.count);
48251 + tty->driver->name, atomic_read(&info->port.count));
48252 }
48253
48254 /* Called by tty_hangup() when a hangup is signaled.
48255 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48256 shutdown(info);
48257
48258 spin_lock_irqsave(&info->port.lock, flags);
48259 - info->port.count = 0;
48260 + atomic_set(&info->port.count, 0);
48261 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48262 info->port.tty = NULL;
48263 spin_unlock_irqrestore(&info->port.lock, flags);
48264 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48265 unsigned short new_crctype;
48266
48267 /* return error if TTY interface open */
48268 - if (info->port.count)
48269 + if (atomic_read(&info->port.count))
48270 return -EBUSY;
48271
48272 switch (encoding)
48273 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48274
48275 /* arbitrate between network and tty opens */
48276 spin_lock_irqsave(&info->netlock, flags);
48277 - if (info->port.count != 0 || info->netcount != 0) {
48278 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48279 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48280 spin_unlock_irqrestore(&info->netlock, flags);
48281 return -EBUSY;
48282 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48283 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48284
48285 /* return error if TTY interface open */
48286 - if (info->port.count)
48287 + if (atomic_read(&info->port.count))
48288 return -EBUSY;
48289
48290 if (cmd != SIOCWANDEV)
48291 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48292 * do not request bottom half processing if the
48293 * device is not open in a normal mode.
48294 */
48295 - if ( port && (port->port.count || port->netcount) &&
48296 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48297 port->pending_bh && !port->bh_running &&
48298 !port->bh_requested ) {
48299 if ( debug_level >= DEBUG_LEVEL_ISR )
48300 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48301
48302 if (debug_level >= DEBUG_LEVEL_INFO)
48303 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48304 - __FILE__,__LINE__, tty->driver->name, port->count );
48305 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48306
48307 spin_lock_irqsave(&info->lock, flags);
48308 if (!tty_hung_up_p(filp)) {
48309 extra_count = true;
48310 - port->count--;
48311 + atomic_dec(&port->count);
48312 }
48313 spin_unlock_irqrestore(&info->lock, flags);
48314 port->blocked_open++;
48315 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48316
48317 if (debug_level >= DEBUG_LEVEL_INFO)
48318 printk("%s(%d):%s block_til_ready() count=%d\n",
48319 - __FILE__,__LINE__, tty->driver->name, port->count );
48320 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48321
48322 tty_unlock(tty);
48323 schedule();
48324 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48325 remove_wait_queue(&port->open_wait, &wait);
48326
48327 if (extra_count)
48328 - port->count++;
48329 + atomic_inc(&port->count);
48330 port->blocked_open--;
48331
48332 if (debug_level >= DEBUG_LEVEL_INFO)
48333 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48334 - __FILE__,__LINE__, tty->driver->name, port->count );
48335 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48336
48337 if (!retval)
48338 port->flags |= ASYNC_NORMAL_ACTIVE;
48339 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48340 index 40a9fe9..a3f10cc 100644
48341 --- a/drivers/tty/sysrq.c
48342 +++ b/drivers/tty/sysrq.c
48343 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48344 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48345 size_t count, loff_t *ppos)
48346 {
48347 - if (count) {
48348 + if (count && capable(CAP_SYS_ADMIN)) {
48349 char c;
48350
48351 if (get_user(c, buf))
48352 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48353 index 3a1a01a..b12cda2 100644
48354 --- a/drivers/tty/tty_io.c
48355 +++ b/drivers/tty/tty_io.c
48356 @@ -3473,7 +3473,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48357
48358 void tty_default_fops(struct file_operations *fops)
48359 {
48360 - *fops = tty_fops;
48361 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48362 }
48363
48364 /*
48365 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48366 index 6458e11..6cfc218 100644
48367 --- a/drivers/tty/tty_ldisc.c
48368 +++ b/drivers/tty/tty_ldisc.c
48369 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48370 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48371 tty_ldiscs[disc] = new_ldisc;
48372 new_ldisc->num = disc;
48373 - new_ldisc->refcount = 0;
48374 + atomic_set(&new_ldisc->refcount, 0);
48375 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48376
48377 return ret;
48378 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
48379 return -EINVAL;
48380
48381 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48382 - if (tty_ldiscs[disc]->refcount)
48383 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48384 ret = -EBUSY;
48385 else
48386 tty_ldiscs[disc] = NULL;
48387 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48388 if (ldops) {
48389 ret = ERR_PTR(-EAGAIN);
48390 if (try_module_get(ldops->owner)) {
48391 - ldops->refcount++;
48392 + atomic_inc(&ldops->refcount);
48393 ret = ldops;
48394 }
48395 }
48396 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48397 unsigned long flags;
48398
48399 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48400 - ldops->refcount--;
48401 + atomic_dec(&ldops->refcount);
48402 module_put(ldops->owner);
48403 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48404 }
48405 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48406 index f597e88..b7f68ed 100644
48407 --- a/drivers/tty/tty_port.c
48408 +++ b/drivers/tty/tty_port.c
48409 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48410 unsigned long flags;
48411
48412 spin_lock_irqsave(&port->lock, flags);
48413 - port->count = 0;
48414 + atomic_set(&port->count, 0);
48415 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48416 tty = port->tty;
48417 if (tty)
48418 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48419 /* The port lock protects the port counts */
48420 spin_lock_irqsave(&port->lock, flags);
48421 if (!tty_hung_up_p(filp))
48422 - port->count--;
48423 + atomic_dec(&port->count);
48424 port->blocked_open++;
48425 spin_unlock_irqrestore(&port->lock, flags);
48426
48427 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48428 we must not mess that up further */
48429 spin_lock_irqsave(&port->lock, flags);
48430 if (!tty_hung_up_p(filp))
48431 - port->count++;
48432 + atomic_inc(&port->count);
48433 port->blocked_open--;
48434 if (retval == 0)
48435 port->flags |= ASYNC_NORMAL_ACTIVE;
48436 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48437 return 0;
48438 }
48439
48440 - if (tty->count == 1 && port->count != 1) {
48441 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48442 printk(KERN_WARNING
48443 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48444 - port->count);
48445 - port->count = 1;
48446 + atomic_read(&port->count));
48447 + atomic_set(&port->count, 1);
48448 }
48449 - if (--port->count < 0) {
48450 + if (atomic_dec_return(&port->count) < 0) {
48451 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48452 - port->count);
48453 - port->count = 0;
48454 + atomic_read(&port->count));
48455 + atomic_set(&port->count, 0);
48456 }
48457
48458 - if (port->count) {
48459 + if (atomic_read(&port->count)) {
48460 spin_unlock_irqrestore(&port->lock, flags);
48461 if (port->ops->drop)
48462 port->ops->drop(port);
48463 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48464 {
48465 spin_lock_irq(&port->lock);
48466 if (!tty_hung_up_p(filp))
48467 - ++port->count;
48468 + atomic_inc(&port->count);
48469 spin_unlock_irq(&port->lock);
48470 tty_port_tty_set(port, tty);
48471
48472 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48473 index d0e3a44..5f8b754 100644
48474 --- a/drivers/tty/vt/keyboard.c
48475 +++ b/drivers/tty/vt/keyboard.c
48476 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48477 kbd->kbdmode == VC_OFF) &&
48478 value != KVAL(K_SAK))
48479 return; /* SAK is allowed even in raw mode */
48480 +
48481 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48482 + {
48483 + void *func = fn_handler[value];
48484 + if (func == fn_show_state || func == fn_show_ptregs ||
48485 + func == fn_show_mem)
48486 + return;
48487 + }
48488 +#endif
48489 +
48490 fn_handler[value](vc);
48491 }
48492
48493 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48494 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48495 return -EFAULT;
48496
48497 - if (!capable(CAP_SYS_TTY_CONFIG))
48498 - perm = 0;
48499 -
48500 switch (cmd) {
48501 case KDGKBENT:
48502 /* Ensure another thread doesn't free it under us */
48503 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48504 spin_unlock_irqrestore(&kbd_event_lock, flags);
48505 return put_user(val, &user_kbe->kb_value);
48506 case KDSKBENT:
48507 + if (!capable(CAP_SYS_TTY_CONFIG))
48508 + perm = 0;
48509 +
48510 if (!perm)
48511 return -EPERM;
48512 if (!i && v == K_NOSUCHMAP) {
48513 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48514 int i, j, k;
48515 int ret;
48516
48517 - if (!capable(CAP_SYS_TTY_CONFIG))
48518 - perm = 0;
48519 -
48520 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48521 if (!kbs) {
48522 ret = -ENOMEM;
48523 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48524 kfree(kbs);
48525 return ((p && *p) ? -EOVERFLOW : 0);
48526 case KDSKBSENT:
48527 + if (!capable(CAP_SYS_TTY_CONFIG))
48528 + perm = 0;
48529 +
48530 if (!perm) {
48531 ret = -EPERM;
48532 goto reterr;
48533 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48534 index 0e808cf..26c24ab 100644
48535 --- a/drivers/uio/uio.c
48536 +++ b/drivers/uio/uio.c
48537 @@ -25,6 +25,7 @@
48538 #include <linux/kobject.h>
48539 #include <linux/cdev.h>
48540 #include <linux/uio_driver.h>
48541 +#include <asm/local.h>
48542
48543 #define UIO_MAX_DEVICES (1U << MINORBITS)
48544
48545 @@ -32,7 +33,7 @@ struct uio_device {
48546 struct module *owner;
48547 struct device *dev;
48548 int minor;
48549 - atomic_t event;
48550 + atomic_unchecked_t event;
48551 struct fasync_struct *async_queue;
48552 wait_queue_head_t wait;
48553 struct uio_info *info;
48554 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
48555 struct device_attribute *attr, char *buf)
48556 {
48557 struct uio_device *idev = dev_get_drvdata(dev);
48558 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48559 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48560 }
48561 static DEVICE_ATTR_RO(event);
48562
48563 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
48564 {
48565 struct uio_device *idev = info->uio_dev;
48566
48567 - atomic_inc(&idev->event);
48568 + atomic_inc_unchecked(&idev->event);
48569 wake_up_interruptible(&idev->wait);
48570 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48571 }
48572 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48573 }
48574
48575 listener->dev = idev;
48576 - listener->event_count = atomic_read(&idev->event);
48577 + listener->event_count = atomic_read_unchecked(&idev->event);
48578 filep->private_data = listener;
48579
48580 if (idev->info->open) {
48581 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48582 return -EIO;
48583
48584 poll_wait(filep, &idev->wait, wait);
48585 - if (listener->event_count != atomic_read(&idev->event))
48586 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48587 return POLLIN | POLLRDNORM;
48588 return 0;
48589 }
48590 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48591 do {
48592 set_current_state(TASK_INTERRUPTIBLE);
48593
48594 - event_count = atomic_read(&idev->event);
48595 + event_count = atomic_read_unchecked(&idev->event);
48596 if (event_count != listener->event_count) {
48597 if (copy_to_user(buf, &event_count, count))
48598 retval = -EFAULT;
48599 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48600 static int uio_find_mem_index(struct vm_area_struct *vma)
48601 {
48602 struct uio_device *idev = vma->vm_private_data;
48603 + unsigned long size;
48604
48605 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48606 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48607 + size = idev->info->mem[vma->vm_pgoff].size;
48608 + if (size == 0)
48609 + return -1;
48610 + if (vma->vm_end - vma->vm_start > size)
48611 return -1;
48612 return (int)vma->vm_pgoff;
48613 }
48614 @@ -818,7 +823,7 @@ int __uio_register_device(struct module *owner,
48615 idev->owner = owner;
48616 idev->info = info;
48617 init_waitqueue_head(&idev->wait);
48618 - atomic_set(&idev->event, 0);
48619 + atomic_set_unchecked(&idev->event, 0);
48620
48621 ret = uio_get_minor(idev);
48622 if (ret)
48623 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48624 index 8a7eb77..c00402f 100644
48625 --- a/drivers/usb/atm/cxacru.c
48626 +++ b/drivers/usb/atm/cxacru.c
48627 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48628 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48629 if (ret < 2)
48630 return -EINVAL;
48631 - if (index < 0 || index > 0x7f)
48632 + if (index > 0x7f)
48633 return -EINVAL;
48634 pos += tmp;
48635
48636 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48637 index 25a7bfc..57f3cf5 100644
48638 --- a/drivers/usb/atm/usbatm.c
48639 +++ b/drivers/usb/atm/usbatm.c
48640 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48641 if (printk_ratelimit())
48642 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48643 __func__, vpi, vci);
48644 - atomic_inc(&vcc->stats->rx_err);
48645 + atomic_inc_unchecked(&vcc->stats->rx_err);
48646 return;
48647 }
48648
48649 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48650 if (length > ATM_MAX_AAL5_PDU) {
48651 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48652 __func__, length, vcc);
48653 - atomic_inc(&vcc->stats->rx_err);
48654 + atomic_inc_unchecked(&vcc->stats->rx_err);
48655 goto out;
48656 }
48657
48658 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48659 if (sarb->len < pdu_length) {
48660 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48661 __func__, pdu_length, sarb->len, vcc);
48662 - atomic_inc(&vcc->stats->rx_err);
48663 + atomic_inc_unchecked(&vcc->stats->rx_err);
48664 goto out;
48665 }
48666
48667 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48668 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48669 __func__, vcc);
48670 - atomic_inc(&vcc->stats->rx_err);
48671 + atomic_inc_unchecked(&vcc->stats->rx_err);
48672 goto out;
48673 }
48674
48675 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48676 if (printk_ratelimit())
48677 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48678 __func__, length);
48679 - atomic_inc(&vcc->stats->rx_drop);
48680 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48681 goto out;
48682 }
48683
48684 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48685
48686 vcc->push(vcc, skb);
48687
48688 - atomic_inc(&vcc->stats->rx);
48689 + atomic_inc_unchecked(&vcc->stats->rx);
48690 out:
48691 skb_trim(sarb, 0);
48692 }
48693 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
48694 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48695
48696 usbatm_pop(vcc, skb);
48697 - atomic_inc(&vcc->stats->tx);
48698 + atomic_inc_unchecked(&vcc->stats->tx);
48699
48700 skb = skb_dequeue(&instance->sndqueue);
48701 }
48702 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48703 if (!left--)
48704 return sprintf(page,
48705 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48706 - atomic_read(&atm_dev->stats.aal5.tx),
48707 - atomic_read(&atm_dev->stats.aal5.tx_err),
48708 - atomic_read(&atm_dev->stats.aal5.rx),
48709 - atomic_read(&atm_dev->stats.aal5.rx_err),
48710 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48711 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48712 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48713 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48714 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48715 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48716
48717 if (!left--) {
48718 if (instance->disconnected)
48719 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48720 index 2a3bbdf..91d72cf 100644
48721 --- a/drivers/usb/core/devices.c
48722 +++ b/drivers/usb/core/devices.c
48723 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48724 * time it gets called.
48725 */
48726 static struct device_connect_event {
48727 - atomic_t count;
48728 + atomic_unchecked_t count;
48729 wait_queue_head_t wait;
48730 } device_event = {
48731 .count = ATOMIC_INIT(1),
48732 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48733
48734 void usbfs_conn_disc_event(void)
48735 {
48736 - atomic_add(2, &device_event.count);
48737 + atomic_add_unchecked(2, &device_event.count);
48738 wake_up(&device_event.wait);
48739 }
48740
48741 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
48742
48743 poll_wait(file, &device_event.wait, wait);
48744
48745 - event_count = atomic_read(&device_event.count);
48746 + event_count = atomic_read_unchecked(&device_event.count);
48747 if (file->f_version != event_count) {
48748 file->f_version = event_count;
48749 return POLLIN | POLLRDNORM;
48750 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48751 index f20a044..d1059aa 100644
48752 --- a/drivers/usb/core/hcd.c
48753 +++ b/drivers/usb/core/hcd.c
48754 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48755 */
48756 usb_get_urb(urb);
48757 atomic_inc(&urb->use_count);
48758 - atomic_inc(&urb->dev->urbnum);
48759 + atomic_inc_unchecked(&urb->dev->urbnum);
48760 usbmon_urb_submit(&hcd->self, urb);
48761
48762 /* NOTE requirements on root-hub callers (usbfs and the hub
48763 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48764 urb->hcpriv = NULL;
48765 INIT_LIST_HEAD(&urb->urb_list);
48766 atomic_dec(&urb->use_count);
48767 - atomic_dec(&urb->dev->urbnum);
48768 + atomic_dec_unchecked(&urb->dev->urbnum);
48769 if (atomic_read(&urb->reject))
48770 wake_up(&usb_kill_urb_queue);
48771 usb_put_urb(urb);
48772 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
48773 index 879651c..87e0131 100644
48774 --- a/drivers/usb/core/hub.c
48775 +++ b/drivers/usb/core/hub.c
48776 @@ -27,6 +27,7 @@
48777 #include <linux/freezer.h>
48778 #include <linux/random.h>
48779 #include <linux/pm_qos.h>
48780 +#include <linux/grsecurity.h>
48781
48782 #include <asm/uaccess.h>
48783 #include <asm/byteorder.h>
48784 @@ -4435,6 +4436,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
48785 goto done;
48786 return;
48787 }
48788 +
48789 + if (gr_handle_new_usb())
48790 + goto done;
48791 +
48792 if (hub_is_superspeed(hub->hdev))
48793 unit_load = 150;
48794 else
48795 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
48796 index 82927e1..4993dbf 100644
48797 --- a/drivers/usb/core/message.c
48798 +++ b/drivers/usb/core/message.c
48799 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
48800 * Return: If successful, the number of bytes transferred. Otherwise, a negative
48801 * error number.
48802 */
48803 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48804 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48805 __u8 requesttype, __u16 value, __u16 index, void *data,
48806 __u16 size, int timeout)
48807 {
48808 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
48809 * If successful, 0. Otherwise a negative error number. The number of actual
48810 * bytes transferred will be stored in the @actual_length paramater.
48811 */
48812 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48813 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48814 void *data, int len, int *actual_length, int timeout)
48815 {
48816 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
48817 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
48818 * bytes transferred will be stored in the @actual_length paramater.
48819 *
48820 */
48821 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48822 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48823 void *data, int len, int *actual_length, int timeout)
48824 {
48825 struct urb *urb;
48826 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
48827 index 6d2c8ed..3a794ca 100644
48828 --- a/drivers/usb/core/sysfs.c
48829 +++ b/drivers/usb/core/sysfs.c
48830 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
48831 struct usb_device *udev;
48832
48833 udev = to_usb_device(dev);
48834 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
48835 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
48836 }
48837 static DEVICE_ATTR_RO(urbnum);
48838
48839 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
48840 index 0a6ee2e..6f8d7e8 100644
48841 --- a/drivers/usb/core/usb.c
48842 +++ b/drivers/usb/core/usb.c
48843 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
48844 set_dev_node(&dev->dev, dev_to_node(bus->controller));
48845 dev->state = USB_STATE_ATTACHED;
48846 dev->lpm_disable_count = 1;
48847 - atomic_set(&dev->urbnum, 0);
48848 + atomic_set_unchecked(&dev->urbnum, 0);
48849
48850 INIT_LIST_HEAD(&dev->ep0.urb_list);
48851 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
48852 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
48853 index 5452c0f..34c9145 100644
48854 --- a/drivers/usb/dwc3/gadget.c
48855 +++ b/drivers/usb/dwc3/gadget.c
48856 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
48857 if (!usb_endpoint_xfer_isoc(desc))
48858 return 0;
48859
48860 - memset(&trb_link, 0, sizeof(trb_link));
48861 -
48862 /* Link TRB for ISOC. The HWO bit is never reset */
48863 trb_st_hw = &dep->trb_pool[0];
48864
48865 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
48866 index 5e29dde..eca992f 100644
48867 --- a/drivers/usb/early/ehci-dbgp.c
48868 +++ b/drivers/usb/early/ehci-dbgp.c
48869 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
48870
48871 #ifdef CONFIG_KGDB
48872 static struct kgdb_io kgdbdbgp_io_ops;
48873 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
48874 +static struct kgdb_io kgdbdbgp_io_ops_console;
48875 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
48876 #else
48877 #define dbgp_kgdb_mode (0)
48878 #endif
48879 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
48880 .write_char = kgdbdbgp_write_char,
48881 };
48882
48883 +static struct kgdb_io kgdbdbgp_io_ops_console = {
48884 + .name = "kgdbdbgp",
48885 + .read_char = kgdbdbgp_read_char,
48886 + .write_char = kgdbdbgp_write_char,
48887 + .is_console = 1
48888 +};
48889 +
48890 static int kgdbdbgp_wait_time;
48891
48892 static int __init kgdbdbgp_parse_config(char *str)
48893 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
48894 ptr++;
48895 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
48896 }
48897 - kgdb_register_io_module(&kgdbdbgp_io_ops);
48898 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
48899 + if (early_dbgp_console.index != -1)
48900 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
48901 + else
48902 + kgdb_register_io_module(&kgdbdbgp_io_ops);
48903
48904 return 0;
48905 }
48906 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
48907 index b369292..9f3ba40 100644
48908 --- a/drivers/usb/gadget/u_serial.c
48909 +++ b/drivers/usb/gadget/u_serial.c
48910 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48911 spin_lock_irq(&port->port_lock);
48912
48913 /* already open? Great. */
48914 - if (port->port.count) {
48915 + if (atomic_read(&port->port.count)) {
48916 status = 0;
48917 - port->port.count++;
48918 + atomic_inc(&port->port.count);
48919
48920 /* currently opening/closing? wait ... */
48921 } else if (port->openclose) {
48922 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48923 tty->driver_data = port;
48924 port->port.tty = tty;
48925
48926 - port->port.count = 1;
48927 + atomic_set(&port->port.count, 1);
48928 port->openclose = false;
48929
48930 /* if connected, start the I/O stream */
48931 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48932
48933 spin_lock_irq(&port->port_lock);
48934
48935 - if (port->port.count != 1) {
48936 - if (port->port.count == 0)
48937 + if (atomic_read(&port->port.count) != 1) {
48938 + if (atomic_read(&port->port.count) == 0)
48939 WARN_ON(1);
48940 else
48941 - --port->port.count;
48942 + atomic_dec(&port->port.count);
48943 goto exit;
48944 }
48945
48946 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48947 * and sleep if necessary
48948 */
48949 port->openclose = true;
48950 - port->port.count = 0;
48951 + atomic_set(&port->port.count, 0);
48952
48953 gser = port->port_usb;
48954 if (gser && gser->disconnect)
48955 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
48956 int cond;
48957
48958 spin_lock_irq(&port->port_lock);
48959 - cond = (port->port.count == 0) && !port->openclose;
48960 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
48961 spin_unlock_irq(&port->port_lock);
48962 return cond;
48963 }
48964 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
48965 /* if it's already open, start I/O ... and notify the serial
48966 * protocol about open/close status (connect/disconnect).
48967 */
48968 - if (port->port.count) {
48969 + if (atomic_read(&port->port.count)) {
48970 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
48971 gs_start_io(port);
48972 if (gser->connect)
48973 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
48974
48975 port->port_usb = NULL;
48976 gser->ioport = NULL;
48977 - if (port->port.count > 0 || port->openclose) {
48978 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
48979 wake_up_interruptible(&port->drain_wait);
48980 if (port->port.tty)
48981 tty_hangup(port->port.tty);
48982 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
48983
48984 /* finally, free any unused/unusable I/O buffers */
48985 spin_lock_irqsave(&port->port_lock, flags);
48986 - if (port->port.count == 0 && !port->openclose)
48987 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
48988 gs_buf_free(&port->port_write_buf);
48989 gs_free_requests(gser->out, &port->read_pool, NULL);
48990 gs_free_requests(gser->out, &port->read_queue, NULL);
48991 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
48992 index 835fc08..f8b22bf 100644
48993 --- a/drivers/usb/host/ehci-hub.c
48994 +++ b/drivers/usb/host/ehci-hub.c
48995 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
48996 urb->transfer_flags = URB_DIR_IN;
48997 usb_get_urb(urb);
48998 atomic_inc(&urb->use_count);
48999 - atomic_inc(&urb->dev->urbnum);
49000 + atomic_inc_unchecked(&urb->dev->urbnum);
49001 urb->setup_dma = dma_map_single(
49002 hcd->self.controller,
49003 urb->setup_packet,
49004 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49005 urb->status = -EINPROGRESS;
49006 usb_get_urb(urb);
49007 atomic_inc(&urb->use_count);
49008 - atomic_inc(&urb->dev->urbnum);
49009 + atomic_inc_unchecked(&urb->dev->urbnum);
49010 retval = submit_single_step_set_feature(hcd, urb, 0);
49011 if (!retval && !wait_for_completion_timeout(&done,
49012 msecs_to_jiffies(2000))) {
49013 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49014 index ba6a5d6..f88f7f3 100644
49015 --- a/drivers/usb/misc/appledisplay.c
49016 +++ b/drivers/usb/misc/appledisplay.c
49017 @@ -83,7 +83,7 @@ struct appledisplay {
49018 spinlock_t lock;
49019 };
49020
49021 -static atomic_t count_displays = ATOMIC_INIT(0);
49022 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49023 static struct workqueue_struct *wq;
49024
49025 static void appledisplay_complete(struct urb *urb)
49026 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49027
49028 /* Register backlight device */
49029 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49030 - atomic_inc_return(&count_displays) - 1);
49031 + atomic_inc_return_unchecked(&count_displays) - 1);
49032 memset(&props, 0, sizeof(struct backlight_properties));
49033 props.type = BACKLIGHT_RAW;
49034 props.max_brightness = 0xff;
49035 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49036 index c69bb50..215ef37 100644
49037 --- a/drivers/usb/serial/console.c
49038 +++ b/drivers/usb/serial/console.c
49039 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49040
49041 info->port = port;
49042
49043 - ++port->port.count;
49044 + atomic_inc(&port->port.count);
49045 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49046 if (serial->type->set_termios) {
49047 /*
49048 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49049 }
49050 /* Now that any required fake tty operations are completed restore
49051 * the tty port count */
49052 - --port->port.count;
49053 + atomic_dec(&port->port.count);
49054 /* The console is special in terms of closing the device so
49055 * indicate this port is now acting as a system console. */
49056 port->port.console = 1;
49057 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49058 free_tty:
49059 kfree(tty);
49060 reset_open_count:
49061 - port->port.count = 0;
49062 + atomic_set(&port->port.count, 0);
49063 usb_autopm_put_interface(serial->interface);
49064 error_get_interface:
49065 usb_serial_put(serial);
49066 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49067 static void usb_console_write(struct console *co,
49068 const char *buf, unsigned count)
49069 {
49070 - static struct usbcons_info *info = &usbcons_info;
49071 + struct usbcons_info *info = &usbcons_info;
49072 struct usb_serial_port *port = info->port;
49073 struct usb_serial *serial;
49074 int retval = -ENODEV;
49075 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49076 index 75f70f0..d467e1a 100644
49077 --- a/drivers/usb/storage/usb.h
49078 +++ b/drivers/usb/storage/usb.h
49079 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49080 __u8 useProtocol;
49081 __u8 useTransport;
49082 int (*initFunction)(struct us_data *);
49083 -};
49084 +} __do_const;
49085
49086
49087 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49088 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49089 index cf250c2..ad9d904 100644
49090 --- a/drivers/usb/wusbcore/wa-hc.h
49091 +++ b/drivers/usb/wusbcore/wa-hc.h
49092 @@ -199,7 +199,7 @@ struct wahc {
49093 spinlock_t xfer_list_lock;
49094 struct work_struct xfer_enqueue_work;
49095 struct work_struct xfer_error_work;
49096 - atomic_t xfer_id_count;
49097 + atomic_unchecked_t xfer_id_count;
49098 };
49099
49100
49101 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
49102 spin_lock_init(&wa->xfer_list_lock);
49103 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
49104 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
49105 - atomic_set(&wa->xfer_id_count, 1);
49106 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49107 }
49108
49109 /**
49110 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49111 index 6ad02f5..cc52c8b 100644
49112 --- a/drivers/usb/wusbcore/wa-xfer.c
49113 +++ b/drivers/usb/wusbcore/wa-xfer.c
49114 @@ -299,7 +299,7 @@ out:
49115 */
49116 static void wa_xfer_id_init(struct wa_xfer *xfer)
49117 {
49118 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49119 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49120 }
49121
49122 /*
49123 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49124 index 1eab4ac..e21efc9 100644
49125 --- a/drivers/vfio/vfio.c
49126 +++ b/drivers/vfio/vfio.c
49127 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49128 return 0;
49129
49130 /* TODO Prevent device auto probing */
49131 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49132 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49133 iommu_group_id(group->iommu_group));
49134
49135 return 0;
49136 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49137 index 5174eba..86e764a 100644
49138 --- a/drivers/vhost/vringh.c
49139 +++ b/drivers/vhost/vringh.c
49140 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49141
49142 static inline int putu16_kern(u16 *p, u16 val)
49143 {
49144 - ACCESS_ONCE(*p) = val;
49145 + ACCESS_ONCE_RW(*p) = val;
49146 return 0;
49147 }
49148
49149 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49150 index e43401a..dd49b3f 100644
49151 --- a/drivers/video/arcfb.c
49152 +++ b/drivers/video/arcfb.c
49153 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49154 return -ENOSPC;
49155
49156 err = 0;
49157 - if ((count + p) > fbmemlength) {
49158 + if (count > (fbmemlength - p)) {
49159 count = fbmemlength - p;
49160 err = -ENOSPC;
49161 }
49162 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49163 index a4dfe8c..297ddd9 100644
49164 --- a/drivers/video/aty/aty128fb.c
49165 +++ b/drivers/video/aty/aty128fb.c
49166 @@ -149,7 +149,7 @@ enum {
49167 };
49168
49169 /* Must match above enum */
49170 -static char * const r128_family[] = {
49171 +static const char * const r128_family[] = {
49172 "AGP",
49173 "PCI",
49174 "PRO AGP",
49175 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49176 index 9b0f12c..024673d 100644
49177 --- a/drivers/video/aty/atyfb_base.c
49178 +++ b/drivers/video/aty/atyfb_base.c
49179 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49180 par->accel_flags = var->accel_flags; /* hack */
49181
49182 if (var->accel_flags) {
49183 - info->fbops->fb_sync = atyfb_sync;
49184 + pax_open_kernel();
49185 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49186 + pax_close_kernel();
49187 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49188 } else {
49189 - info->fbops->fb_sync = NULL;
49190 + pax_open_kernel();
49191 + *(void **)&info->fbops->fb_sync = NULL;
49192 + pax_close_kernel();
49193 info->flags |= FBINFO_HWACCEL_DISABLED;
49194 }
49195
49196 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49197 index 95ec042..e6affdd 100644
49198 --- a/drivers/video/aty/mach64_cursor.c
49199 +++ b/drivers/video/aty/mach64_cursor.c
49200 @@ -7,6 +7,7 @@
49201 #include <linux/string.h>
49202
49203 #include <asm/io.h>
49204 +#include <asm/pgtable.h>
49205
49206 #ifdef __sparc__
49207 #include <asm/fbio.h>
49208 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49209 info->sprite.buf_align = 16; /* and 64 lines tall. */
49210 info->sprite.flags = FB_PIXMAP_IO;
49211
49212 - info->fbops->fb_cursor = atyfb_cursor;
49213 + pax_open_kernel();
49214 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49215 + pax_close_kernel();
49216
49217 return 0;
49218 }
49219 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49220 index bca6ccc..252107e 100644
49221 --- a/drivers/video/backlight/kb3886_bl.c
49222 +++ b/drivers/video/backlight/kb3886_bl.c
49223 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49224 static unsigned long kb3886bl_flags;
49225 #define KB3886BL_SUSPENDED 0x01
49226
49227 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49228 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49229 {
49230 .ident = "Sahara Touch-iT",
49231 .matches = {
49232 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49233 index 900aa4e..6d49418 100644
49234 --- a/drivers/video/fb_defio.c
49235 +++ b/drivers/video/fb_defio.c
49236 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49237
49238 BUG_ON(!fbdefio);
49239 mutex_init(&fbdefio->lock);
49240 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49241 + pax_open_kernel();
49242 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49243 + pax_close_kernel();
49244 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49245 INIT_LIST_HEAD(&fbdefio->pagelist);
49246 if (fbdefio->delay == 0) /* set a default of 1 s */
49247 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49248 page->mapping = NULL;
49249 }
49250
49251 - info->fbops->fb_mmap = NULL;
49252 + *(void **)&info->fbops->fb_mmap = NULL;
49253 mutex_destroy(&fbdefio->lock);
49254 }
49255 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49256 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49257 index dacaf74..8478a46 100644
49258 --- a/drivers/video/fbmem.c
49259 +++ b/drivers/video/fbmem.c
49260 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49261 image->dx += image->width + 8;
49262 }
49263 } else if (rotate == FB_ROTATE_UD) {
49264 - for (x = 0; x < num && image->dx >= 0; x++) {
49265 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49266 info->fbops->fb_imageblit(info, image);
49267 image->dx -= image->width + 8;
49268 }
49269 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49270 image->dy += image->height + 8;
49271 }
49272 } else if (rotate == FB_ROTATE_CCW) {
49273 - for (x = 0; x < num && image->dy >= 0; x++) {
49274 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49275 info->fbops->fb_imageblit(info, image);
49276 image->dy -= image->height + 8;
49277 }
49278 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49279 return -EFAULT;
49280 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49281 return -EINVAL;
49282 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49283 + if (con2fb.framebuffer >= FB_MAX)
49284 return -EINVAL;
49285 if (!registered_fb[con2fb.framebuffer])
49286 request_module("fb%d", con2fb.framebuffer);
49287 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49288 index 8d456dc..b4fa44b 100644
49289 --- a/drivers/video/hyperv_fb.c
49290 +++ b/drivers/video/hyperv_fb.c
49291 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49292 static inline int synthvid_send(struct hv_device *hdev,
49293 struct synthvid_msg *msg)
49294 {
49295 - static atomic64_t request_id = ATOMIC64_INIT(0);
49296 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49297 int ret;
49298
49299 msg->pipe_hdr.type = PIPE_MSG_DATA;
49300 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49301
49302 ret = vmbus_sendpacket(hdev->channel, msg,
49303 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49304 - atomic64_inc_return(&request_id),
49305 + atomic64_inc_return_unchecked(&request_id),
49306 VM_PKT_DATA_INBAND, 0);
49307
49308 if (ret)
49309 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49310 index 7672d2e..b56437f 100644
49311 --- a/drivers/video/i810/i810_accel.c
49312 +++ b/drivers/video/i810/i810_accel.c
49313 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49314 }
49315 }
49316 printk("ringbuffer lockup!!!\n");
49317 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49318 i810_report_error(mmio);
49319 par->dev_flags |= LOCKUP;
49320 info->pixmap.scan_align = 1;
49321 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49322 index 3c14e43..2630570 100644
49323 --- a/drivers/video/logo/logo_linux_clut224.ppm
49324 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49325 @@ -2,1603 +2,1123 @@ P3
49326 # Standard 224-color Linux logo
49327 80 80
49328 255
49329 - 0 0 0 0 0 0 0 0 0 0 0 0
49330 - 0 0 0 0 0 0 0 0 0 0 0 0
49331 - 0 0 0 0 0 0 0 0 0 0 0 0
49332 - 0 0 0 0 0 0 0 0 0 0 0 0
49333 - 0 0 0 0 0 0 0 0 0 0 0 0
49334 - 0 0 0 0 0 0 0 0 0 0 0 0
49335 - 0 0 0 0 0 0 0 0 0 0 0 0
49336 - 0 0 0 0 0 0 0 0 0 0 0 0
49337 - 0 0 0 0 0 0 0 0 0 0 0 0
49338 - 6 6 6 6 6 6 10 10 10 10 10 10
49339 - 10 10 10 6 6 6 6 6 6 6 6 6
49340 - 0 0 0 0 0 0 0 0 0 0 0 0
49341 - 0 0 0 0 0 0 0 0 0 0 0 0
49342 - 0 0 0 0 0 0 0 0 0 0 0 0
49343 - 0 0 0 0 0 0 0 0 0 0 0 0
49344 - 0 0 0 0 0 0 0 0 0 0 0 0
49345 - 0 0 0 0 0 0 0 0 0 0 0 0
49346 - 0 0 0 0 0 0 0 0 0 0 0 0
49347 - 0 0 0 0 0 0 0 0 0 0 0 0
49348 - 0 0 0 0 0 0 0 0 0 0 0 0
49349 - 0 0 0 0 0 0 0 0 0 0 0 0
49350 - 0 0 0 0 0 0 0 0 0 0 0 0
49351 - 0 0 0 0 0 0 0 0 0 0 0 0
49352 - 0 0 0 0 0 0 0 0 0 0 0 0
49353 - 0 0 0 0 0 0 0 0 0 0 0 0
49354 - 0 0 0 0 0 0 0 0 0 0 0 0
49355 - 0 0 0 0 0 0 0 0 0 0 0 0
49356 - 0 0 0 0 0 0 0 0 0 0 0 0
49357 - 0 0 0 6 6 6 10 10 10 14 14 14
49358 - 22 22 22 26 26 26 30 30 30 34 34 34
49359 - 30 30 30 30 30 30 26 26 26 18 18 18
49360 - 14 14 14 10 10 10 6 6 6 0 0 0
49361 - 0 0 0 0 0 0 0 0 0 0 0 0
49362 - 0 0 0 0 0 0 0 0 0 0 0 0
49363 - 0 0 0 0 0 0 0 0 0 0 0 0
49364 - 0 0 0 0 0 0 0 0 0 0 0 0
49365 - 0 0 0 0 0 0 0 0 0 0 0 0
49366 - 0 0 0 0 0 0 0 0 0 0 0 0
49367 - 0 0 0 0 0 0 0 0 0 0 0 0
49368 - 0 0 0 0 0 0 0 0 0 0 0 0
49369 - 0 0 0 0 0 0 0 0 0 0 0 0
49370 - 0 0 0 0 0 1 0 0 1 0 0 0
49371 - 0 0 0 0 0 0 0 0 0 0 0 0
49372 - 0 0 0 0 0 0 0 0 0 0 0 0
49373 - 0 0 0 0 0 0 0 0 0 0 0 0
49374 - 0 0 0 0 0 0 0 0 0 0 0 0
49375 - 0 0 0 0 0 0 0 0 0 0 0 0
49376 - 0 0 0 0 0 0 0 0 0 0 0 0
49377 - 6 6 6 14 14 14 26 26 26 42 42 42
49378 - 54 54 54 66 66 66 78 78 78 78 78 78
49379 - 78 78 78 74 74 74 66 66 66 54 54 54
49380 - 42 42 42 26 26 26 18 18 18 10 10 10
49381 - 6 6 6 0 0 0 0 0 0 0 0 0
49382 - 0 0 0 0 0 0 0 0 0 0 0 0
49383 - 0 0 0 0 0 0 0 0 0 0 0 0
49384 - 0 0 0 0 0 0 0 0 0 0 0 0
49385 - 0 0 0 0 0 0 0 0 0 0 0 0
49386 - 0 0 0 0 0 0 0 0 0 0 0 0
49387 - 0 0 0 0 0 0 0 0 0 0 0 0
49388 - 0 0 0 0 0 0 0 0 0 0 0 0
49389 - 0 0 0 0 0 0 0 0 0 0 0 0
49390 - 0 0 1 0 0 0 0 0 0 0 0 0
49391 - 0 0 0 0 0 0 0 0 0 0 0 0
49392 - 0 0 0 0 0 0 0 0 0 0 0 0
49393 - 0 0 0 0 0 0 0 0 0 0 0 0
49394 - 0 0 0 0 0 0 0 0 0 0 0 0
49395 - 0 0 0 0 0 0 0 0 0 0 0 0
49396 - 0 0 0 0 0 0 0 0 0 10 10 10
49397 - 22 22 22 42 42 42 66 66 66 86 86 86
49398 - 66 66 66 38 38 38 38 38 38 22 22 22
49399 - 26 26 26 34 34 34 54 54 54 66 66 66
49400 - 86 86 86 70 70 70 46 46 46 26 26 26
49401 - 14 14 14 6 6 6 0 0 0 0 0 0
49402 - 0 0 0 0 0 0 0 0 0 0 0 0
49403 - 0 0 0 0 0 0 0 0 0 0 0 0
49404 - 0 0 0 0 0 0 0 0 0 0 0 0
49405 - 0 0 0 0 0 0 0 0 0 0 0 0
49406 - 0 0 0 0 0 0 0 0 0 0 0 0
49407 - 0 0 0 0 0 0 0 0 0 0 0 0
49408 - 0 0 0 0 0 0 0 0 0 0 0 0
49409 - 0 0 0 0 0 0 0 0 0 0 0 0
49410 - 0 0 1 0 0 1 0 0 1 0 0 0
49411 - 0 0 0 0 0 0 0 0 0 0 0 0
49412 - 0 0 0 0 0 0 0 0 0 0 0 0
49413 - 0 0 0 0 0 0 0 0 0 0 0 0
49414 - 0 0 0 0 0 0 0 0 0 0 0 0
49415 - 0 0 0 0 0 0 0 0 0 0 0 0
49416 - 0 0 0 0 0 0 10 10 10 26 26 26
49417 - 50 50 50 82 82 82 58 58 58 6 6 6
49418 - 2 2 6 2 2 6 2 2 6 2 2 6
49419 - 2 2 6 2 2 6 2 2 6 2 2 6
49420 - 6 6 6 54 54 54 86 86 86 66 66 66
49421 - 38 38 38 18 18 18 6 6 6 0 0 0
49422 - 0 0 0 0 0 0 0 0 0 0 0 0
49423 - 0 0 0 0 0 0 0 0 0 0 0 0
49424 - 0 0 0 0 0 0 0 0 0 0 0 0
49425 - 0 0 0 0 0 0 0 0 0 0 0 0
49426 - 0 0 0 0 0 0 0 0 0 0 0 0
49427 - 0 0 0 0 0 0 0 0 0 0 0 0
49428 - 0 0 0 0 0 0 0 0 0 0 0 0
49429 - 0 0 0 0 0 0 0 0 0 0 0 0
49430 - 0 0 0 0 0 0 0 0 0 0 0 0
49431 - 0 0 0 0 0 0 0 0 0 0 0 0
49432 - 0 0 0 0 0 0 0 0 0 0 0 0
49433 - 0 0 0 0 0 0 0 0 0 0 0 0
49434 - 0 0 0 0 0 0 0 0 0 0 0 0
49435 - 0 0 0 0 0 0 0 0 0 0 0 0
49436 - 0 0 0 6 6 6 22 22 22 50 50 50
49437 - 78 78 78 34 34 34 2 2 6 2 2 6
49438 - 2 2 6 2 2 6 2 2 6 2 2 6
49439 - 2 2 6 2 2 6 2 2 6 2 2 6
49440 - 2 2 6 2 2 6 6 6 6 70 70 70
49441 - 78 78 78 46 46 46 22 22 22 6 6 6
49442 - 0 0 0 0 0 0 0 0 0 0 0 0
49443 - 0 0 0 0 0 0 0 0 0 0 0 0
49444 - 0 0 0 0 0 0 0 0 0 0 0 0
49445 - 0 0 0 0 0 0 0 0 0 0 0 0
49446 - 0 0 0 0 0 0 0 0 0 0 0 0
49447 - 0 0 0 0 0 0 0 0 0 0 0 0
49448 - 0 0 0 0 0 0 0 0 0 0 0 0
49449 - 0 0 0 0 0 0 0 0 0 0 0 0
49450 - 0 0 1 0 0 1 0 0 1 0 0 0
49451 - 0 0 0 0 0 0 0 0 0 0 0 0
49452 - 0 0 0 0 0 0 0 0 0 0 0 0
49453 - 0 0 0 0 0 0 0 0 0 0 0 0
49454 - 0 0 0 0 0 0 0 0 0 0 0 0
49455 - 0 0 0 0 0 0 0 0 0 0 0 0
49456 - 6 6 6 18 18 18 42 42 42 82 82 82
49457 - 26 26 26 2 2 6 2 2 6 2 2 6
49458 - 2 2 6 2 2 6 2 2 6 2 2 6
49459 - 2 2 6 2 2 6 2 2 6 14 14 14
49460 - 46 46 46 34 34 34 6 6 6 2 2 6
49461 - 42 42 42 78 78 78 42 42 42 18 18 18
49462 - 6 6 6 0 0 0 0 0 0 0 0 0
49463 - 0 0 0 0 0 0 0 0 0 0 0 0
49464 - 0 0 0 0 0 0 0 0 0 0 0 0
49465 - 0 0 0 0 0 0 0 0 0 0 0 0
49466 - 0 0 0 0 0 0 0 0 0 0 0 0
49467 - 0 0 0 0 0 0 0 0 0 0 0 0
49468 - 0 0 0 0 0 0 0 0 0 0 0 0
49469 - 0 0 0 0 0 0 0 0 0 0 0 0
49470 - 0 0 1 0 0 0 0 0 1 0 0 0
49471 - 0 0 0 0 0 0 0 0 0 0 0 0
49472 - 0 0 0 0 0 0 0 0 0 0 0 0
49473 - 0 0 0 0 0 0 0 0 0 0 0 0
49474 - 0 0 0 0 0 0 0 0 0 0 0 0
49475 - 0 0 0 0 0 0 0 0 0 0 0 0
49476 - 10 10 10 30 30 30 66 66 66 58 58 58
49477 - 2 2 6 2 2 6 2 2 6 2 2 6
49478 - 2 2 6 2 2 6 2 2 6 2 2 6
49479 - 2 2 6 2 2 6 2 2 6 26 26 26
49480 - 86 86 86 101 101 101 46 46 46 10 10 10
49481 - 2 2 6 58 58 58 70 70 70 34 34 34
49482 - 10 10 10 0 0 0 0 0 0 0 0 0
49483 - 0 0 0 0 0 0 0 0 0 0 0 0
49484 - 0 0 0 0 0 0 0 0 0 0 0 0
49485 - 0 0 0 0 0 0 0 0 0 0 0 0
49486 - 0 0 0 0 0 0 0 0 0 0 0 0
49487 - 0 0 0 0 0 0 0 0 0 0 0 0
49488 - 0 0 0 0 0 0 0 0 0 0 0 0
49489 - 0 0 0 0 0 0 0 0 0 0 0 0
49490 - 0 0 1 0 0 1 0 0 1 0 0 0
49491 - 0 0 0 0 0 0 0 0 0 0 0 0
49492 - 0 0 0 0 0 0 0 0 0 0 0 0
49493 - 0 0 0 0 0 0 0 0 0 0 0 0
49494 - 0 0 0 0 0 0 0 0 0 0 0 0
49495 - 0 0 0 0 0 0 0 0 0 0 0 0
49496 - 14 14 14 42 42 42 86 86 86 10 10 10
49497 - 2 2 6 2 2 6 2 2 6 2 2 6
49498 - 2 2 6 2 2 6 2 2 6 2 2 6
49499 - 2 2 6 2 2 6 2 2 6 30 30 30
49500 - 94 94 94 94 94 94 58 58 58 26 26 26
49501 - 2 2 6 6 6 6 78 78 78 54 54 54
49502 - 22 22 22 6 6 6 0 0 0 0 0 0
49503 - 0 0 0 0 0 0 0 0 0 0 0 0
49504 - 0 0 0 0 0 0 0 0 0 0 0 0
49505 - 0 0 0 0 0 0 0 0 0 0 0 0
49506 - 0 0 0 0 0 0 0 0 0 0 0 0
49507 - 0 0 0 0 0 0 0 0 0 0 0 0
49508 - 0 0 0 0 0 0 0 0 0 0 0 0
49509 - 0 0 0 0 0 0 0 0 0 0 0 0
49510 - 0 0 0 0 0 0 0 0 0 0 0 0
49511 - 0 0 0 0 0 0 0 0 0 0 0 0
49512 - 0 0 0 0 0 0 0 0 0 0 0 0
49513 - 0 0 0 0 0 0 0 0 0 0 0 0
49514 - 0 0 0 0 0 0 0 0 0 0 0 0
49515 - 0 0 0 0 0 0 0 0 0 6 6 6
49516 - 22 22 22 62 62 62 62 62 62 2 2 6
49517 - 2 2 6 2 2 6 2 2 6 2 2 6
49518 - 2 2 6 2 2 6 2 2 6 2 2 6
49519 - 2 2 6 2 2 6 2 2 6 26 26 26
49520 - 54 54 54 38 38 38 18 18 18 10 10 10
49521 - 2 2 6 2 2 6 34 34 34 82 82 82
49522 - 38 38 38 14 14 14 0 0 0 0 0 0
49523 - 0 0 0 0 0 0 0 0 0 0 0 0
49524 - 0 0 0 0 0 0 0 0 0 0 0 0
49525 - 0 0 0 0 0 0 0 0 0 0 0 0
49526 - 0 0 0 0 0 0 0 0 0 0 0 0
49527 - 0 0 0 0 0 0 0 0 0 0 0 0
49528 - 0 0 0 0 0 0 0 0 0 0 0 0
49529 - 0 0 0 0 0 0 0 0 0 0 0 0
49530 - 0 0 0 0 0 1 0 0 1 0 0 0
49531 - 0 0 0 0 0 0 0 0 0 0 0 0
49532 - 0 0 0 0 0 0 0 0 0 0 0 0
49533 - 0 0 0 0 0 0 0 0 0 0 0 0
49534 - 0 0 0 0 0 0 0 0 0 0 0 0
49535 - 0 0 0 0 0 0 0 0 0 6 6 6
49536 - 30 30 30 78 78 78 30 30 30 2 2 6
49537 - 2 2 6 2 2 6 2 2 6 2 2 6
49538 - 2 2 6 2 2 6 2 2 6 2 2 6
49539 - 2 2 6 2 2 6 2 2 6 10 10 10
49540 - 10 10 10 2 2 6 2 2 6 2 2 6
49541 - 2 2 6 2 2 6 2 2 6 78 78 78
49542 - 50 50 50 18 18 18 6 6 6 0 0 0
49543 - 0 0 0 0 0 0 0 0 0 0 0 0
49544 - 0 0 0 0 0 0 0 0 0 0 0 0
49545 - 0 0 0 0 0 0 0 0 0 0 0 0
49546 - 0 0 0 0 0 0 0 0 0 0 0 0
49547 - 0 0 0 0 0 0 0 0 0 0 0 0
49548 - 0 0 0 0 0 0 0 0 0 0 0 0
49549 - 0 0 0 0 0 0 0 0 0 0 0 0
49550 - 0 0 1 0 0 0 0 0 0 0 0 0
49551 - 0 0 0 0 0 0 0 0 0 0 0 0
49552 - 0 0 0 0 0 0 0 0 0 0 0 0
49553 - 0 0 0 0 0 0 0 0 0 0 0 0
49554 - 0 0 0 0 0 0 0 0 0 0 0 0
49555 - 0 0 0 0 0 0 0 0 0 10 10 10
49556 - 38 38 38 86 86 86 14 14 14 2 2 6
49557 - 2 2 6 2 2 6 2 2 6 2 2 6
49558 - 2 2 6 2 2 6 2 2 6 2 2 6
49559 - 2 2 6 2 2 6 2 2 6 2 2 6
49560 - 2 2 6 2 2 6 2 2 6 2 2 6
49561 - 2 2 6 2 2 6 2 2 6 54 54 54
49562 - 66 66 66 26 26 26 6 6 6 0 0 0
49563 - 0 0 0 0 0 0 0 0 0 0 0 0
49564 - 0 0 0 0 0 0 0 0 0 0 0 0
49565 - 0 0 0 0 0 0 0 0 0 0 0 0
49566 - 0 0 0 0 0 0 0 0 0 0 0 0
49567 - 0 0 0 0 0 0 0 0 0 0 0 0
49568 - 0 0 0 0 0 0 0 0 0 0 0 0
49569 - 0 0 0 0 0 0 0 0 0 0 0 0
49570 - 0 0 0 0 0 1 0 0 1 0 0 0
49571 - 0 0 0 0 0 0 0 0 0 0 0 0
49572 - 0 0 0 0 0 0 0 0 0 0 0 0
49573 - 0 0 0 0 0 0 0 0 0 0 0 0
49574 - 0 0 0 0 0 0 0 0 0 0 0 0
49575 - 0 0 0 0 0 0 0 0 0 14 14 14
49576 - 42 42 42 82 82 82 2 2 6 2 2 6
49577 - 2 2 6 6 6 6 10 10 10 2 2 6
49578 - 2 2 6 2 2 6 2 2 6 2 2 6
49579 - 2 2 6 2 2 6 2 2 6 6 6 6
49580 - 14 14 14 10 10 10 2 2 6 2 2 6
49581 - 2 2 6 2 2 6 2 2 6 18 18 18
49582 - 82 82 82 34 34 34 10 10 10 0 0 0
49583 - 0 0 0 0 0 0 0 0 0 0 0 0
49584 - 0 0 0 0 0 0 0 0 0 0 0 0
49585 - 0 0 0 0 0 0 0 0 0 0 0 0
49586 - 0 0 0 0 0 0 0 0 0 0 0 0
49587 - 0 0 0 0 0 0 0 0 0 0 0 0
49588 - 0 0 0 0 0 0 0 0 0 0 0 0
49589 - 0 0 0 0 0 0 0 0 0 0 0 0
49590 - 0 0 1 0 0 0 0 0 0 0 0 0
49591 - 0 0 0 0 0 0 0 0 0 0 0 0
49592 - 0 0 0 0 0 0 0 0 0 0 0 0
49593 - 0 0 0 0 0 0 0 0 0 0 0 0
49594 - 0 0 0 0 0 0 0 0 0 0 0 0
49595 - 0 0 0 0 0 0 0 0 0 14 14 14
49596 - 46 46 46 86 86 86 2 2 6 2 2 6
49597 - 6 6 6 6 6 6 22 22 22 34 34 34
49598 - 6 6 6 2 2 6 2 2 6 2 2 6
49599 - 2 2 6 2 2 6 18 18 18 34 34 34
49600 - 10 10 10 50 50 50 22 22 22 2 2 6
49601 - 2 2 6 2 2 6 2 2 6 10 10 10
49602 - 86 86 86 42 42 42 14 14 14 0 0 0
49603 - 0 0 0 0 0 0 0 0 0 0 0 0
49604 - 0 0 0 0 0 0 0 0 0 0 0 0
49605 - 0 0 0 0 0 0 0 0 0 0 0 0
49606 - 0 0 0 0 0 0 0 0 0 0 0 0
49607 - 0 0 0 0 0 0 0 0 0 0 0 0
49608 - 0 0 0 0 0 0 0 0 0 0 0 0
49609 - 0 0 0 0 0 0 0 0 0 0 0 0
49610 - 0 0 1 0 0 1 0 0 1 0 0 0
49611 - 0 0 0 0 0 0 0 0 0 0 0 0
49612 - 0 0 0 0 0 0 0 0 0 0 0 0
49613 - 0 0 0 0 0 0 0 0 0 0 0 0
49614 - 0 0 0 0 0 0 0 0 0 0 0 0
49615 - 0 0 0 0 0 0 0 0 0 14 14 14
49616 - 46 46 46 86 86 86 2 2 6 2 2 6
49617 - 38 38 38 116 116 116 94 94 94 22 22 22
49618 - 22 22 22 2 2 6 2 2 6 2 2 6
49619 - 14 14 14 86 86 86 138 138 138 162 162 162
49620 -154 154 154 38 38 38 26 26 26 6 6 6
49621 - 2 2 6 2 2 6 2 2 6 2 2 6
49622 - 86 86 86 46 46 46 14 14 14 0 0 0
49623 - 0 0 0 0 0 0 0 0 0 0 0 0
49624 - 0 0 0 0 0 0 0 0 0 0 0 0
49625 - 0 0 0 0 0 0 0 0 0 0 0 0
49626 - 0 0 0 0 0 0 0 0 0 0 0 0
49627 - 0 0 0 0 0 0 0 0 0 0 0 0
49628 - 0 0 0 0 0 0 0 0 0 0 0 0
49629 - 0 0 0 0 0 0 0 0 0 0 0 0
49630 - 0 0 0 0 0 0 0 0 0 0 0 0
49631 - 0 0 0 0 0 0 0 0 0 0 0 0
49632 - 0 0 0 0 0 0 0 0 0 0 0 0
49633 - 0 0 0 0 0 0 0 0 0 0 0 0
49634 - 0 0 0 0 0 0 0 0 0 0 0 0
49635 - 0 0 0 0 0 0 0 0 0 14 14 14
49636 - 46 46 46 86 86 86 2 2 6 14 14 14
49637 -134 134 134 198 198 198 195 195 195 116 116 116
49638 - 10 10 10 2 2 6 2 2 6 6 6 6
49639 -101 98 89 187 187 187 210 210 210 218 218 218
49640 -214 214 214 134 134 134 14 14 14 6 6 6
49641 - 2 2 6 2 2 6 2 2 6 2 2 6
49642 - 86 86 86 50 50 50 18 18 18 6 6 6
49643 - 0 0 0 0 0 0 0 0 0 0 0 0
49644 - 0 0 0 0 0 0 0 0 0 0 0 0
49645 - 0 0 0 0 0 0 0 0 0 0 0 0
49646 - 0 0 0 0 0 0 0 0 0 0 0 0
49647 - 0 0 0 0 0 0 0 0 0 0 0 0
49648 - 0 0 0 0 0 0 0 0 0 0 0 0
49649 - 0 0 0 0 0 0 0 0 1 0 0 0
49650 - 0 0 1 0 0 1 0 0 1 0 0 0
49651 - 0 0 0 0 0 0 0 0 0 0 0 0
49652 - 0 0 0 0 0 0 0 0 0 0 0 0
49653 - 0 0 0 0 0 0 0 0 0 0 0 0
49654 - 0 0 0 0 0 0 0 0 0 0 0 0
49655 - 0 0 0 0 0 0 0 0 0 14 14 14
49656 - 46 46 46 86 86 86 2 2 6 54 54 54
49657 -218 218 218 195 195 195 226 226 226 246 246 246
49658 - 58 58 58 2 2 6 2 2 6 30 30 30
49659 -210 210 210 253 253 253 174 174 174 123 123 123
49660 -221 221 221 234 234 234 74 74 74 2 2 6
49661 - 2 2 6 2 2 6 2 2 6 2 2 6
49662 - 70 70 70 58 58 58 22 22 22 6 6 6
49663 - 0 0 0 0 0 0 0 0 0 0 0 0
49664 - 0 0 0 0 0 0 0 0 0 0 0 0
49665 - 0 0 0 0 0 0 0 0 0 0 0 0
49666 - 0 0 0 0 0 0 0 0 0 0 0 0
49667 - 0 0 0 0 0 0 0 0 0 0 0 0
49668 - 0 0 0 0 0 0 0 0 0 0 0 0
49669 - 0 0 0 0 0 0 0 0 0 0 0 0
49670 - 0 0 0 0 0 0 0 0 0 0 0 0
49671 - 0 0 0 0 0 0 0 0 0 0 0 0
49672 - 0 0 0 0 0 0 0 0 0 0 0 0
49673 - 0 0 0 0 0 0 0 0 0 0 0 0
49674 - 0 0 0 0 0 0 0 0 0 0 0 0
49675 - 0 0 0 0 0 0 0 0 0 14 14 14
49676 - 46 46 46 82 82 82 2 2 6 106 106 106
49677 -170 170 170 26 26 26 86 86 86 226 226 226
49678 -123 123 123 10 10 10 14 14 14 46 46 46
49679 -231 231 231 190 190 190 6 6 6 70 70 70
49680 - 90 90 90 238 238 238 158 158 158 2 2 6
49681 - 2 2 6 2 2 6 2 2 6 2 2 6
49682 - 70 70 70 58 58 58 22 22 22 6 6 6
49683 - 0 0 0 0 0 0 0 0 0 0 0 0
49684 - 0 0 0 0 0 0 0 0 0 0 0 0
49685 - 0 0 0 0 0 0 0 0 0 0 0 0
49686 - 0 0 0 0 0 0 0 0 0 0 0 0
49687 - 0 0 0 0 0 0 0 0 0 0 0 0
49688 - 0 0 0 0 0 0 0 0 0 0 0 0
49689 - 0 0 0 0 0 0 0 0 1 0 0 0
49690 - 0 0 1 0 0 1 0 0 1 0 0 0
49691 - 0 0 0 0 0 0 0 0 0 0 0 0
49692 - 0 0 0 0 0 0 0 0 0 0 0 0
49693 - 0 0 0 0 0 0 0 0 0 0 0 0
49694 - 0 0 0 0 0 0 0 0 0 0 0 0
49695 - 0 0 0 0 0 0 0 0 0 14 14 14
49696 - 42 42 42 86 86 86 6 6 6 116 116 116
49697 -106 106 106 6 6 6 70 70 70 149 149 149
49698 -128 128 128 18 18 18 38 38 38 54 54 54
49699 -221 221 221 106 106 106 2 2 6 14 14 14
49700 - 46 46 46 190 190 190 198 198 198 2 2 6
49701 - 2 2 6 2 2 6 2 2 6 2 2 6
49702 - 74 74 74 62 62 62 22 22 22 6 6 6
49703 - 0 0 0 0 0 0 0 0 0 0 0 0
49704 - 0 0 0 0 0 0 0 0 0 0 0 0
49705 - 0 0 0 0 0 0 0 0 0 0 0 0
49706 - 0 0 0 0 0 0 0 0 0 0 0 0
49707 - 0 0 0 0 0 0 0 0 0 0 0 0
49708 - 0 0 0 0 0 0 0 0 0 0 0 0
49709 - 0 0 0 0 0 0 0 0 1 0 0 0
49710 - 0 0 1 0 0 0 0 0 1 0 0 0
49711 - 0 0 0 0 0 0 0 0 0 0 0 0
49712 - 0 0 0 0 0 0 0 0 0 0 0 0
49713 - 0 0 0 0 0 0 0 0 0 0 0 0
49714 - 0 0 0 0 0 0 0 0 0 0 0 0
49715 - 0 0 0 0 0 0 0 0 0 14 14 14
49716 - 42 42 42 94 94 94 14 14 14 101 101 101
49717 -128 128 128 2 2 6 18 18 18 116 116 116
49718 -118 98 46 121 92 8 121 92 8 98 78 10
49719 -162 162 162 106 106 106 2 2 6 2 2 6
49720 - 2 2 6 195 195 195 195 195 195 6 6 6
49721 - 2 2 6 2 2 6 2 2 6 2 2 6
49722 - 74 74 74 62 62 62 22 22 22 6 6 6
49723 - 0 0 0 0 0 0 0 0 0 0 0 0
49724 - 0 0 0 0 0 0 0 0 0 0 0 0
49725 - 0 0 0 0 0 0 0 0 0 0 0 0
49726 - 0 0 0 0 0 0 0 0 0 0 0 0
49727 - 0 0 0 0 0 0 0 0 0 0 0 0
49728 - 0 0 0 0 0 0 0 0 0 0 0 0
49729 - 0 0 0 0 0 0 0 0 1 0 0 1
49730 - 0 0 1 0 0 0 0 0 1 0 0 0
49731 - 0 0 0 0 0 0 0 0 0 0 0 0
49732 - 0 0 0 0 0 0 0 0 0 0 0 0
49733 - 0 0 0 0 0 0 0 0 0 0 0 0
49734 - 0 0 0 0 0 0 0 0 0 0 0 0
49735 - 0 0 0 0 0 0 0 0 0 10 10 10
49736 - 38 38 38 90 90 90 14 14 14 58 58 58
49737 -210 210 210 26 26 26 54 38 6 154 114 10
49738 -226 170 11 236 186 11 225 175 15 184 144 12
49739 -215 174 15 175 146 61 37 26 9 2 2 6
49740 - 70 70 70 246 246 246 138 138 138 2 2 6
49741 - 2 2 6 2 2 6 2 2 6 2 2 6
49742 - 70 70 70 66 66 66 26 26 26 6 6 6
49743 - 0 0 0 0 0 0 0 0 0 0 0 0
49744 - 0 0 0 0 0 0 0 0 0 0 0 0
49745 - 0 0 0 0 0 0 0 0 0 0 0 0
49746 - 0 0 0 0 0 0 0 0 0 0 0 0
49747 - 0 0 0 0 0 0 0 0 0 0 0 0
49748 - 0 0 0 0 0 0 0 0 0 0 0 0
49749 - 0 0 0 0 0 0 0 0 0 0 0 0
49750 - 0 0 0 0 0 0 0 0 0 0 0 0
49751 - 0 0 0 0 0 0 0 0 0 0 0 0
49752 - 0 0 0 0 0 0 0 0 0 0 0 0
49753 - 0 0 0 0 0 0 0 0 0 0 0 0
49754 - 0 0 0 0 0 0 0 0 0 0 0 0
49755 - 0 0 0 0 0 0 0 0 0 10 10 10
49756 - 38 38 38 86 86 86 14 14 14 10 10 10
49757 -195 195 195 188 164 115 192 133 9 225 175 15
49758 -239 182 13 234 190 10 232 195 16 232 200 30
49759 -245 207 45 241 208 19 232 195 16 184 144 12
49760 -218 194 134 211 206 186 42 42 42 2 2 6
49761 - 2 2 6 2 2 6 2 2 6 2 2 6
49762 - 50 50 50 74 74 74 30 30 30 6 6 6
49763 - 0 0 0 0 0 0 0 0 0 0 0 0
49764 - 0 0 0 0 0 0 0 0 0 0 0 0
49765 - 0 0 0 0 0 0 0 0 0 0 0 0
49766 - 0 0 0 0 0 0 0 0 0 0 0 0
49767 - 0 0 0 0 0 0 0 0 0 0 0 0
49768 - 0 0 0 0 0 0 0 0 0 0 0 0
49769 - 0 0 0 0 0 0 0 0 0 0 0 0
49770 - 0 0 0 0 0 0 0 0 0 0 0 0
49771 - 0 0 0 0 0 0 0 0 0 0 0 0
49772 - 0 0 0 0 0 0 0 0 0 0 0 0
49773 - 0 0 0 0 0 0 0 0 0 0 0 0
49774 - 0 0 0 0 0 0 0 0 0 0 0 0
49775 - 0 0 0 0 0 0 0 0 0 10 10 10
49776 - 34 34 34 86 86 86 14 14 14 2 2 6
49777 -121 87 25 192 133 9 219 162 10 239 182 13
49778 -236 186 11 232 195 16 241 208 19 244 214 54
49779 -246 218 60 246 218 38 246 215 20 241 208 19
49780 -241 208 19 226 184 13 121 87 25 2 2 6
49781 - 2 2 6 2 2 6 2 2 6 2 2 6
49782 - 50 50 50 82 82 82 34 34 34 10 10 10
49783 - 0 0 0 0 0 0 0 0 0 0 0 0
49784 - 0 0 0 0 0 0 0 0 0 0 0 0
49785 - 0 0 0 0 0 0 0 0 0 0 0 0
49786 - 0 0 0 0 0 0 0 0 0 0 0 0
49787 - 0 0 0 0 0 0 0 0 0 0 0 0
49788 - 0 0 0 0 0 0 0 0 0 0 0 0
49789 - 0 0 0 0 0 0 0 0 0 0 0 0
49790 - 0 0 0 0 0 0 0 0 0 0 0 0
49791 - 0 0 0 0 0 0 0 0 0 0 0 0
49792 - 0 0 0 0 0 0 0 0 0 0 0 0
49793 - 0 0 0 0 0 0 0 0 0 0 0 0
49794 - 0 0 0 0 0 0 0 0 0 0 0 0
49795 - 0 0 0 0 0 0 0 0 0 10 10 10
49796 - 34 34 34 82 82 82 30 30 30 61 42 6
49797 -180 123 7 206 145 10 230 174 11 239 182 13
49798 -234 190 10 238 202 15 241 208 19 246 218 74
49799 -246 218 38 246 215 20 246 215 20 246 215 20
49800 -226 184 13 215 174 15 184 144 12 6 6 6
49801 - 2 2 6 2 2 6 2 2 6 2 2 6
49802 - 26 26 26 94 94 94 42 42 42 14 14 14
49803 - 0 0 0 0 0 0 0 0 0 0 0 0
49804 - 0 0 0 0 0 0 0 0 0 0 0 0
49805 - 0 0 0 0 0 0 0 0 0 0 0 0
49806 - 0 0 0 0 0 0 0 0 0 0 0 0
49807 - 0 0 0 0 0 0 0 0 0 0 0 0
49808 - 0 0 0 0 0 0 0 0 0 0 0 0
49809 - 0 0 0 0 0 0 0 0 0 0 0 0
49810 - 0 0 0 0 0 0 0 0 0 0 0 0
49811 - 0 0 0 0 0 0 0 0 0 0 0 0
49812 - 0 0 0 0 0 0 0 0 0 0 0 0
49813 - 0 0 0 0 0 0 0 0 0 0 0 0
49814 - 0 0 0 0 0 0 0 0 0 0 0 0
49815 - 0 0 0 0 0 0 0 0 0 10 10 10
49816 - 30 30 30 78 78 78 50 50 50 104 69 6
49817 -192 133 9 216 158 10 236 178 12 236 186 11
49818 -232 195 16 241 208 19 244 214 54 245 215 43
49819 -246 215 20 246 215 20 241 208 19 198 155 10
49820 -200 144 11 216 158 10 156 118 10 2 2 6
49821 - 2 2 6 2 2 6 2 2 6 2 2 6
49822 - 6 6 6 90 90 90 54 54 54 18 18 18
49823 - 6 6 6 0 0 0 0 0 0 0 0 0
49824 - 0 0 0 0 0 0 0 0 0 0 0 0
49825 - 0 0 0 0 0 0 0 0 0 0 0 0
49826 - 0 0 0 0 0 0 0 0 0 0 0 0
49827 - 0 0 0 0 0 0 0 0 0 0 0 0
49828 - 0 0 0 0 0 0 0 0 0 0 0 0
49829 - 0 0 0 0 0 0 0 0 0 0 0 0
49830 - 0 0 0 0 0 0 0 0 0 0 0 0
49831 - 0 0 0 0 0 0 0 0 0 0 0 0
49832 - 0 0 0 0 0 0 0 0 0 0 0 0
49833 - 0 0 0 0 0 0 0 0 0 0 0 0
49834 - 0 0 0 0 0 0 0 0 0 0 0 0
49835 - 0 0 0 0 0 0 0 0 0 10 10 10
49836 - 30 30 30 78 78 78 46 46 46 22 22 22
49837 -137 92 6 210 162 10 239 182 13 238 190 10
49838 -238 202 15 241 208 19 246 215 20 246 215 20
49839 -241 208 19 203 166 17 185 133 11 210 150 10
49840 -216 158 10 210 150 10 102 78 10 2 2 6
49841 - 6 6 6 54 54 54 14 14 14 2 2 6
49842 - 2 2 6 62 62 62 74 74 74 30 30 30
49843 - 10 10 10 0 0 0 0 0 0 0 0 0
49844 - 0 0 0 0 0 0 0 0 0 0 0 0
49845 - 0 0 0 0 0 0 0 0 0 0 0 0
49846 - 0 0 0 0 0 0 0 0 0 0 0 0
49847 - 0 0 0 0 0 0 0 0 0 0 0 0
49848 - 0 0 0 0 0 0 0 0 0 0 0 0
49849 - 0 0 0 0 0 0 0 0 0 0 0 0
49850 - 0 0 0 0 0 0 0 0 0 0 0 0
49851 - 0 0 0 0 0 0 0 0 0 0 0 0
49852 - 0 0 0 0 0 0 0 0 0 0 0 0
49853 - 0 0 0 0 0 0 0 0 0 0 0 0
49854 - 0 0 0 0 0 0 0 0 0 0 0 0
49855 - 0 0 0 0 0 0 0 0 0 10 10 10
49856 - 34 34 34 78 78 78 50 50 50 6 6 6
49857 - 94 70 30 139 102 15 190 146 13 226 184 13
49858 -232 200 30 232 195 16 215 174 15 190 146 13
49859 -168 122 10 192 133 9 210 150 10 213 154 11
49860 -202 150 34 182 157 106 101 98 89 2 2 6
49861 - 2 2 6 78 78 78 116 116 116 58 58 58
49862 - 2 2 6 22 22 22 90 90 90 46 46 46
49863 - 18 18 18 6 6 6 0 0 0 0 0 0
49864 - 0 0 0 0 0 0 0 0 0 0 0 0
49865 - 0 0 0 0 0 0 0 0 0 0 0 0
49866 - 0 0 0 0 0 0 0 0 0 0 0 0
49867 - 0 0 0 0 0 0 0 0 0 0 0 0
49868 - 0 0 0 0 0 0 0 0 0 0 0 0
49869 - 0 0 0 0 0 0 0 0 0 0 0 0
49870 - 0 0 0 0 0 0 0 0 0 0 0 0
49871 - 0 0 0 0 0 0 0 0 0 0 0 0
49872 - 0 0 0 0 0 0 0 0 0 0 0 0
49873 - 0 0 0 0 0 0 0 0 0 0 0 0
49874 - 0 0 0 0 0 0 0 0 0 0 0 0
49875 - 0 0 0 0 0 0 0 0 0 10 10 10
49876 - 38 38 38 86 86 86 50 50 50 6 6 6
49877 -128 128 128 174 154 114 156 107 11 168 122 10
49878 -198 155 10 184 144 12 197 138 11 200 144 11
49879 -206 145 10 206 145 10 197 138 11 188 164 115
49880 -195 195 195 198 198 198 174 174 174 14 14 14
49881 - 2 2 6 22 22 22 116 116 116 116 116 116
49882 - 22 22 22 2 2 6 74 74 74 70 70 70
49883 - 30 30 30 10 10 10 0 0 0 0 0 0
49884 - 0 0 0 0 0 0 0 0 0 0 0 0
49885 - 0 0 0 0 0 0 0 0 0 0 0 0
49886 - 0 0 0 0 0 0 0 0 0 0 0 0
49887 - 0 0 0 0 0 0 0 0 0 0 0 0
49888 - 0 0 0 0 0 0 0 0 0 0 0 0
49889 - 0 0 0 0 0 0 0 0 0 0 0 0
49890 - 0 0 0 0 0 0 0 0 0 0 0 0
49891 - 0 0 0 0 0 0 0 0 0 0 0 0
49892 - 0 0 0 0 0 0 0 0 0 0 0 0
49893 - 0 0 0 0 0 0 0 0 0 0 0 0
49894 - 0 0 0 0 0 0 0 0 0 0 0 0
49895 - 0 0 0 0 0 0 6 6 6 18 18 18
49896 - 50 50 50 101 101 101 26 26 26 10 10 10
49897 -138 138 138 190 190 190 174 154 114 156 107 11
49898 -197 138 11 200 144 11 197 138 11 192 133 9
49899 -180 123 7 190 142 34 190 178 144 187 187 187
49900 -202 202 202 221 221 221 214 214 214 66 66 66
49901 - 2 2 6 2 2 6 50 50 50 62 62 62
49902 - 6 6 6 2 2 6 10 10 10 90 90 90
49903 - 50 50 50 18 18 18 6 6 6 0 0 0
49904 - 0 0 0 0 0 0 0 0 0 0 0 0
49905 - 0 0 0 0 0 0 0 0 0 0 0 0
49906 - 0 0 0 0 0 0 0 0 0 0 0 0
49907 - 0 0 0 0 0 0 0 0 0 0 0 0
49908 - 0 0 0 0 0 0 0 0 0 0 0 0
49909 - 0 0 0 0 0 0 0 0 0 0 0 0
49910 - 0 0 0 0 0 0 0 0 0 0 0 0
49911 - 0 0 0 0 0 0 0 0 0 0 0 0
49912 - 0 0 0 0 0 0 0 0 0 0 0 0
49913 - 0 0 0 0 0 0 0 0 0 0 0 0
49914 - 0 0 0 0 0 0 0 0 0 0 0 0
49915 - 0 0 0 0 0 0 10 10 10 34 34 34
49916 - 74 74 74 74 74 74 2 2 6 6 6 6
49917 -144 144 144 198 198 198 190 190 190 178 166 146
49918 -154 121 60 156 107 11 156 107 11 168 124 44
49919 -174 154 114 187 187 187 190 190 190 210 210 210
49920 -246 246 246 253 253 253 253 253 253 182 182 182
49921 - 6 6 6 2 2 6 2 2 6 2 2 6
49922 - 2 2 6 2 2 6 2 2 6 62 62 62
49923 - 74 74 74 34 34 34 14 14 14 0 0 0
49924 - 0 0 0 0 0 0 0 0 0 0 0 0
49925 - 0 0 0 0 0 0 0 0 0 0 0 0
49926 - 0 0 0 0 0 0 0 0 0 0 0 0
49927 - 0 0 0 0 0 0 0 0 0 0 0 0
49928 - 0 0 0 0 0 0 0 0 0 0 0 0
49929 - 0 0 0 0 0 0 0 0 0 0 0 0
49930 - 0 0 0 0 0 0 0 0 0 0 0 0
49931 - 0 0 0 0 0 0 0 0 0 0 0 0
49932 - 0 0 0 0 0 0 0 0 0 0 0 0
49933 - 0 0 0 0 0 0 0 0 0 0 0 0
49934 - 0 0 0 0 0 0 0 0 0 0 0 0
49935 - 0 0 0 10 10 10 22 22 22 54 54 54
49936 - 94 94 94 18 18 18 2 2 6 46 46 46
49937 -234 234 234 221 221 221 190 190 190 190 190 190
49938 -190 190 190 187 187 187 187 187 187 190 190 190
49939 -190 190 190 195 195 195 214 214 214 242 242 242
49940 -253 253 253 253 253 253 253 253 253 253 253 253
49941 - 82 82 82 2 2 6 2 2 6 2 2 6
49942 - 2 2 6 2 2 6 2 2 6 14 14 14
49943 - 86 86 86 54 54 54 22 22 22 6 6 6
49944 - 0 0 0 0 0 0 0 0 0 0 0 0
49945 - 0 0 0 0 0 0 0 0 0 0 0 0
49946 - 0 0 0 0 0 0 0 0 0 0 0 0
49947 - 0 0 0 0 0 0 0 0 0 0 0 0
49948 - 0 0 0 0 0 0 0 0 0 0 0 0
49949 - 0 0 0 0 0 0 0 0 0 0 0 0
49950 - 0 0 0 0 0 0 0 0 0 0 0 0
49951 - 0 0 0 0 0 0 0 0 0 0 0 0
49952 - 0 0 0 0 0 0 0 0 0 0 0 0
49953 - 0 0 0 0 0 0 0 0 0 0 0 0
49954 - 0 0 0 0 0 0 0 0 0 0 0 0
49955 - 6 6 6 18 18 18 46 46 46 90 90 90
49956 - 46 46 46 18 18 18 6 6 6 182 182 182
49957 -253 253 253 246 246 246 206 206 206 190 190 190
49958 -190 190 190 190 190 190 190 190 190 190 190 190
49959 -206 206 206 231 231 231 250 250 250 253 253 253
49960 -253 253 253 253 253 253 253 253 253 253 253 253
49961 -202 202 202 14 14 14 2 2 6 2 2 6
49962 - 2 2 6 2 2 6 2 2 6 2 2 6
49963 - 42 42 42 86 86 86 42 42 42 18 18 18
49964 - 6 6 6 0 0 0 0 0 0 0 0 0
49965 - 0 0 0 0 0 0 0 0 0 0 0 0
49966 - 0 0 0 0 0 0 0 0 0 0 0 0
49967 - 0 0 0 0 0 0 0 0 0 0 0 0
49968 - 0 0 0 0 0 0 0 0 0 0 0 0
49969 - 0 0 0 0 0 0 0 0 0 0 0 0
49970 - 0 0 0 0 0 0 0 0 0 0 0 0
49971 - 0 0 0 0 0 0 0 0 0 0 0 0
49972 - 0 0 0 0 0 0 0 0 0 0 0 0
49973 - 0 0 0 0 0 0 0 0 0 0 0 0
49974 - 0 0 0 0 0 0 0 0 0 6 6 6
49975 - 14 14 14 38 38 38 74 74 74 66 66 66
49976 - 2 2 6 6 6 6 90 90 90 250 250 250
49977 -253 253 253 253 253 253 238 238 238 198 198 198
49978 -190 190 190 190 190 190 195 195 195 221 221 221
49979 -246 246 246 253 253 253 253 253 253 253 253 253
49980 -253 253 253 253 253 253 253 253 253 253 253 253
49981 -253 253 253 82 82 82 2 2 6 2 2 6
49982 - 2 2 6 2 2 6 2 2 6 2 2 6
49983 - 2 2 6 78 78 78 70 70 70 34 34 34
49984 - 14 14 14 6 6 6 0 0 0 0 0 0
49985 - 0 0 0 0 0 0 0 0 0 0 0 0
49986 - 0 0 0 0 0 0 0 0 0 0 0 0
49987 - 0 0 0 0 0 0 0 0 0 0 0 0
49988 - 0 0 0 0 0 0 0 0 0 0 0 0
49989 - 0 0 0 0 0 0 0 0 0 0 0 0
49990 - 0 0 0 0 0 0 0 0 0 0 0 0
49991 - 0 0 0 0 0 0 0 0 0 0 0 0
49992 - 0 0 0 0 0 0 0 0 0 0 0 0
49993 - 0 0 0 0 0 0 0 0 0 0 0 0
49994 - 0 0 0 0 0 0 0 0 0 14 14 14
49995 - 34 34 34 66 66 66 78 78 78 6 6 6
49996 - 2 2 6 18 18 18 218 218 218 253 253 253
49997 -253 253 253 253 253 253 253 253 253 246 246 246
49998 -226 226 226 231 231 231 246 246 246 253 253 253
49999 -253 253 253 253 253 253 253 253 253 253 253 253
50000 -253 253 253 253 253 253 253 253 253 253 253 253
50001 -253 253 253 178 178 178 2 2 6 2 2 6
50002 - 2 2 6 2 2 6 2 2 6 2 2 6
50003 - 2 2 6 18 18 18 90 90 90 62 62 62
50004 - 30 30 30 10 10 10 0 0 0 0 0 0
50005 - 0 0 0 0 0 0 0 0 0 0 0 0
50006 - 0 0 0 0 0 0 0 0 0 0 0 0
50007 - 0 0 0 0 0 0 0 0 0 0 0 0
50008 - 0 0 0 0 0 0 0 0 0 0 0 0
50009 - 0 0 0 0 0 0 0 0 0 0 0 0
50010 - 0 0 0 0 0 0 0 0 0 0 0 0
50011 - 0 0 0 0 0 0 0 0 0 0 0 0
50012 - 0 0 0 0 0 0 0 0 0 0 0 0
50013 - 0 0 0 0 0 0 0 0 0 0 0 0
50014 - 0 0 0 0 0 0 10 10 10 26 26 26
50015 - 58 58 58 90 90 90 18 18 18 2 2 6
50016 - 2 2 6 110 110 110 253 253 253 253 253 253
50017 -253 253 253 253 253 253 253 253 253 253 253 253
50018 -250 250 250 253 253 253 253 253 253 253 253 253
50019 -253 253 253 253 253 253 253 253 253 253 253 253
50020 -253 253 253 253 253 253 253 253 253 253 253 253
50021 -253 253 253 231 231 231 18 18 18 2 2 6
50022 - 2 2 6 2 2 6 2 2 6 2 2 6
50023 - 2 2 6 2 2 6 18 18 18 94 94 94
50024 - 54 54 54 26 26 26 10 10 10 0 0 0
50025 - 0 0 0 0 0 0 0 0 0 0 0 0
50026 - 0 0 0 0 0 0 0 0 0 0 0 0
50027 - 0 0 0 0 0 0 0 0 0 0 0 0
50028 - 0 0 0 0 0 0 0 0 0 0 0 0
50029 - 0 0 0 0 0 0 0 0 0 0 0 0
50030 - 0 0 0 0 0 0 0 0 0 0 0 0
50031 - 0 0 0 0 0 0 0 0 0 0 0 0
50032 - 0 0 0 0 0 0 0 0 0 0 0 0
50033 - 0 0 0 0 0 0 0 0 0 0 0 0
50034 - 0 0 0 6 6 6 22 22 22 50 50 50
50035 - 90 90 90 26 26 26 2 2 6 2 2 6
50036 - 14 14 14 195 195 195 250 250 250 253 253 253
50037 -253 253 253 253 253 253 253 253 253 253 253 253
50038 -253 253 253 253 253 253 253 253 253 253 253 253
50039 -253 253 253 253 253 253 253 253 253 253 253 253
50040 -253 253 253 253 253 253 253 253 253 253 253 253
50041 -250 250 250 242 242 242 54 54 54 2 2 6
50042 - 2 2 6 2 2 6 2 2 6 2 2 6
50043 - 2 2 6 2 2 6 2 2 6 38 38 38
50044 - 86 86 86 50 50 50 22 22 22 6 6 6
50045 - 0 0 0 0 0 0 0 0 0 0 0 0
50046 - 0 0 0 0 0 0 0 0 0 0 0 0
50047 - 0 0 0 0 0 0 0 0 0 0 0 0
50048 - 0 0 0 0 0 0 0 0 0 0 0 0
50049 - 0 0 0 0 0 0 0 0 0 0 0 0
50050 - 0 0 0 0 0 0 0 0 0 0 0 0
50051 - 0 0 0 0 0 0 0 0 0 0 0 0
50052 - 0 0 0 0 0 0 0 0 0 0 0 0
50053 - 0 0 0 0 0 0 0 0 0 0 0 0
50054 - 6 6 6 14 14 14 38 38 38 82 82 82
50055 - 34 34 34 2 2 6 2 2 6 2 2 6
50056 - 42 42 42 195 195 195 246 246 246 253 253 253
50057 -253 253 253 253 253 253 253 253 253 250 250 250
50058 -242 242 242 242 242 242 250 250 250 253 253 253
50059 -253 253 253 253 253 253 253 253 253 253 253 253
50060 -253 253 253 250 250 250 246 246 246 238 238 238
50061 -226 226 226 231 231 231 101 101 101 6 6 6
50062 - 2 2 6 2 2 6 2 2 6 2 2 6
50063 - 2 2 6 2 2 6 2 2 6 2 2 6
50064 - 38 38 38 82 82 82 42 42 42 14 14 14
50065 - 6 6 6 0 0 0 0 0 0 0 0 0
50066 - 0 0 0 0 0 0 0 0 0 0 0 0
50067 - 0 0 0 0 0 0 0 0 0 0 0 0
50068 - 0 0 0 0 0 0 0 0 0 0 0 0
50069 - 0 0 0 0 0 0 0 0 0 0 0 0
50070 - 0 0 0 0 0 0 0 0 0 0 0 0
50071 - 0 0 0 0 0 0 0 0 0 0 0 0
50072 - 0 0 0 0 0 0 0 0 0 0 0 0
50073 - 0 0 0 0 0 0 0 0 0 0 0 0
50074 - 10 10 10 26 26 26 62 62 62 66 66 66
50075 - 2 2 6 2 2 6 2 2 6 6 6 6
50076 - 70 70 70 170 170 170 206 206 206 234 234 234
50077 -246 246 246 250 250 250 250 250 250 238 238 238
50078 -226 226 226 231 231 231 238 238 238 250 250 250
50079 -250 250 250 250 250 250 246 246 246 231 231 231
50080 -214 214 214 206 206 206 202 202 202 202 202 202
50081 -198 198 198 202 202 202 182 182 182 18 18 18
50082 - 2 2 6 2 2 6 2 2 6 2 2 6
50083 - 2 2 6 2 2 6 2 2 6 2 2 6
50084 - 2 2 6 62 62 62 66 66 66 30 30 30
50085 - 10 10 10 0 0 0 0 0 0 0 0 0
50086 - 0 0 0 0 0 0 0 0 0 0 0 0
50087 - 0 0 0 0 0 0 0 0 0 0 0 0
50088 - 0 0 0 0 0 0 0 0 0 0 0 0
50089 - 0 0 0 0 0 0 0 0 0 0 0 0
50090 - 0 0 0 0 0 0 0 0 0 0 0 0
50091 - 0 0 0 0 0 0 0 0 0 0 0 0
50092 - 0 0 0 0 0 0 0 0 0 0 0 0
50093 - 0 0 0 0 0 0 0 0 0 0 0 0
50094 - 14 14 14 42 42 42 82 82 82 18 18 18
50095 - 2 2 6 2 2 6 2 2 6 10 10 10
50096 - 94 94 94 182 182 182 218 218 218 242 242 242
50097 -250 250 250 253 253 253 253 253 253 250 250 250
50098 -234 234 234 253 253 253 253 253 253 253 253 253
50099 -253 253 253 253 253 253 253 253 253 246 246 246
50100 -238 238 238 226 226 226 210 210 210 202 202 202
50101 -195 195 195 195 195 195 210 210 210 158 158 158
50102 - 6 6 6 14 14 14 50 50 50 14 14 14
50103 - 2 2 6 2 2 6 2 2 6 2 2 6
50104 - 2 2 6 6 6 6 86 86 86 46 46 46
50105 - 18 18 18 6 6 6 0 0 0 0 0 0
50106 - 0 0 0 0 0 0 0 0 0 0 0 0
50107 - 0 0 0 0 0 0 0 0 0 0 0 0
50108 - 0 0 0 0 0 0 0 0 0 0 0 0
50109 - 0 0 0 0 0 0 0 0 0 0 0 0
50110 - 0 0 0 0 0 0 0 0 0 0 0 0
50111 - 0 0 0 0 0 0 0 0 0 0 0 0
50112 - 0 0 0 0 0 0 0 0 0 0 0 0
50113 - 0 0 0 0 0 0 0 0 0 6 6 6
50114 - 22 22 22 54 54 54 70 70 70 2 2 6
50115 - 2 2 6 10 10 10 2 2 6 22 22 22
50116 -166 166 166 231 231 231 250 250 250 253 253 253
50117 -253 253 253 253 253 253 253 253 253 250 250 250
50118 -242 242 242 253 253 253 253 253 253 253 253 253
50119 -253 253 253 253 253 253 253 253 253 253 253 253
50120 -253 253 253 253 253 253 253 253 253 246 246 246
50121 -231 231 231 206 206 206 198 198 198 226 226 226
50122 - 94 94 94 2 2 6 6 6 6 38 38 38
50123 - 30 30 30 2 2 6 2 2 6 2 2 6
50124 - 2 2 6 2 2 6 62 62 62 66 66 66
50125 - 26 26 26 10 10 10 0 0 0 0 0 0
50126 - 0 0 0 0 0 0 0 0 0 0 0 0
50127 - 0 0 0 0 0 0 0 0 0 0 0 0
50128 - 0 0 0 0 0 0 0 0 0 0 0 0
50129 - 0 0 0 0 0 0 0 0 0 0 0 0
50130 - 0 0 0 0 0 0 0 0 0 0 0 0
50131 - 0 0 0 0 0 0 0 0 0 0 0 0
50132 - 0 0 0 0 0 0 0 0 0 0 0 0
50133 - 0 0 0 0 0 0 0 0 0 10 10 10
50134 - 30 30 30 74 74 74 50 50 50 2 2 6
50135 - 26 26 26 26 26 26 2 2 6 106 106 106
50136 -238 238 238 253 253 253 253 253 253 253 253 253
50137 -253 253 253 253 253 253 253 253 253 253 253 253
50138 -253 253 253 253 253 253 253 253 253 253 253 253
50139 -253 253 253 253 253 253 253 253 253 253 253 253
50140 -253 253 253 253 253 253 253 253 253 253 253 253
50141 -253 253 253 246 246 246 218 218 218 202 202 202
50142 -210 210 210 14 14 14 2 2 6 2 2 6
50143 - 30 30 30 22 22 22 2 2 6 2 2 6
50144 - 2 2 6 2 2 6 18 18 18 86 86 86
50145 - 42 42 42 14 14 14 0 0 0 0 0 0
50146 - 0 0 0 0 0 0 0 0 0 0 0 0
50147 - 0 0 0 0 0 0 0 0 0 0 0 0
50148 - 0 0 0 0 0 0 0 0 0 0 0 0
50149 - 0 0 0 0 0 0 0 0 0 0 0 0
50150 - 0 0 0 0 0 0 0 0 0 0 0 0
50151 - 0 0 0 0 0 0 0 0 0 0 0 0
50152 - 0 0 0 0 0 0 0 0 0 0 0 0
50153 - 0 0 0 0 0 0 0 0 0 14 14 14
50154 - 42 42 42 90 90 90 22 22 22 2 2 6
50155 - 42 42 42 2 2 6 18 18 18 218 218 218
50156 -253 253 253 253 253 253 253 253 253 253 253 253
50157 -253 253 253 253 253 253 253 253 253 253 253 253
50158 -253 253 253 253 253 253 253 253 253 253 253 253
50159 -253 253 253 253 253 253 253 253 253 253 253 253
50160 -253 253 253 253 253 253 253 253 253 253 253 253
50161 -253 253 253 253 253 253 250 250 250 221 221 221
50162 -218 218 218 101 101 101 2 2 6 14 14 14
50163 - 18 18 18 38 38 38 10 10 10 2 2 6
50164 - 2 2 6 2 2 6 2 2 6 78 78 78
50165 - 58 58 58 22 22 22 6 6 6 0 0 0
50166 - 0 0 0 0 0 0 0 0 0 0 0 0
50167 - 0 0 0 0 0 0 0 0 0 0 0 0
50168 - 0 0 0 0 0 0 0 0 0 0 0 0
50169 - 0 0 0 0 0 0 0 0 0 0 0 0
50170 - 0 0 0 0 0 0 0 0 0 0 0 0
50171 - 0 0 0 0 0 0 0 0 0 0 0 0
50172 - 0 0 0 0 0 0 0 0 0 0 0 0
50173 - 0 0 0 0 0 0 6 6 6 18 18 18
50174 - 54 54 54 82 82 82 2 2 6 26 26 26
50175 - 22 22 22 2 2 6 123 123 123 253 253 253
50176 -253 253 253 253 253 253 253 253 253 253 253 253
50177 -253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 253 253 253 253 253 253
50179 -253 253 253 253 253 253 253 253 253 253 253 253
50180 -253 253 253 253 253 253 253 253 253 253 253 253
50181 -253 253 253 253 253 253 253 253 253 250 250 250
50182 -238 238 238 198 198 198 6 6 6 38 38 38
50183 - 58 58 58 26 26 26 38 38 38 2 2 6
50184 - 2 2 6 2 2 6 2 2 6 46 46 46
50185 - 78 78 78 30 30 30 10 10 10 0 0 0
50186 - 0 0 0 0 0 0 0 0 0 0 0 0
50187 - 0 0 0 0 0 0 0 0 0 0 0 0
50188 - 0 0 0 0 0 0 0 0 0 0 0 0
50189 - 0 0 0 0 0 0 0 0 0 0 0 0
50190 - 0 0 0 0 0 0 0 0 0 0 0 0
50191 - 0 0 0 0 0 0 0 0 0 0 0 0
50192 - 0 0 0 0 0 0 0 0 0 0 0 0
50193 - 0 0 0 0 0 0 10 10 10 30 30 30
50194 - 74 74 74 58 58 58 2 2 6 42 42 42
50195 - 2 2 6 22 22 22 231 231 231 253 253 253
50196 -253 253 253 253 253 253 253 253 253 253 253 253
50197 -253 253 253 253 253 253 253 253 253 250 250 250
50198 -253 253 253 253 253 253 253 253 253 253 253 253
50199 -253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 253 253 253 253 253 253
50201 -253 253 253 253 253 253 253 253 253 253 253 253
50202 -253 253 253 246 246 246 46 46 46 38 38 38
50203 - 42 42 42 14 14 14 38 38 38 14 14 14
50204 - 2 2 6 2 2 6 2 2 6 6 6 6
50205 - 86 86 86 46 46 46 14 14 14 0 0 0
50206 - 0 0 0 0 0 0 0 0 0 0 0 0
50207 - 0 0 0 0 0 0 0 0 0 0 0 0
50208 - 0 0 0 0 0 0 0 0 0 0 0 0
50209 - 0 0 0 0 0 0 0 0 0 0 0 0
50210 - 0 0 0 0 0 0 0 0 0 0 0 0
50211 - 0 0 0 0 0 0 0 0 0 0 0 0
50212 - 0 0 0 0 0 0 0 0 0 0 0 0
50213 - 0 0 0 6 6 6 14 14 14 42 42 42
50214 - 90 90 90 18 18 18 18 18 18 26 26 26
50215 - 2 2 6 116 116 116 253 253 253 253 253 253
50216 -253 253 253 253 253 253 253 253 253 253 253 253
50217 -253 253 253 253 253 253 250 250 250 238 238 238
50218 -253 253 253 253 253 253 253 253 253 253 253 253
50219 -253 253 253 253 253 253 253 253 253 253 253 253
50220 -253 253 253 253 253 253 253 253 253 253 253 253
50221 -253 253 253 253 253 253 253 253 253 253 253 253
50222 -253 253 253 253 253 253 94 94 94 6 6 6
50223 - 2 2 6 2 2 6 10 10 10 34 34 34
50224 - 2 2 6 2 2 6 2 2 6 2 2 6
50225 - 74 74 74 58 58 58 22 22 22 6 6 6
50226 - 0 0 0 0 0 0 0 0 0 0 0 0
50227 - 0 0 0 0 0 0 0 0 0 0 0 0
50228 - 0 0 0 0 0 0 0 0 0 0 0 0
50229 - 0 0 0 0 0 0 0 0 0 0 0 0
50230 - 0 0 0 0 0 0 0 0 0 0 0 0
50231 - 0 0 0 0 0 0 0 0 0 0 0 0
50232 - 0 0 0 0 0 0 0 0 0 0 0 0
50233 - 0 0 0 10 10 10 26 26 26 66 66 66
50234 - 82 82 82 2 2 6 38 38 38 6 6 6
50235 - 14 14 14 210 210 210 253 253 253 253 253 253
50236 -253 253 253 253 253 253 253 253 253 253 253 253
50237 -253 253 253 253 253 253 246 246 246 242 242 242
50238 -253 253 253 253 253 253 253 253 253 253 253 253
50239 -253 253 253 253 253 253 253 253 253 253 253 253
50240 -253 253 253 253 253 253 253 253 253 253 253 253
50241 -253 253 253 253 253 253 253 253 253 253 253 253
50242 -253 253 253 253 253 253 144 144 144 2 2 6
50243 - 2 2 6 2 2 6 2 2 6 46 46 46
50244 - 2 2 6 2 2 6 2 2 6 2 2 6
50245 - 42 42 42 74 74 74 30 30 30 10 10 10
50246 - 0 0 0 0 0 0 0 0 0 0 0 0
50247 - 0 0 0 0 0 0 0 0 0 0 0 0
50248 - 0 0 0 0 0 0 0 0 0 0 0 0
50249 - 0 0 0 0 0 0 0 0 0 0 0 0
50250 - 0 0 0 0 0 0 0 0 0 0 0 0
50251 - 0 0 0 0 0 0 0 0 0 0 0 0
50252 - 0 0 0 0 0 0 0 0 0 0 0 0
50253 - 6 6 6 14 14 14 42 42 42 90 90 90
50254 - 26 26 26 6 6 6 42 42 42 2 2 6
50255 - 74 74 74 250 250 250 253 253 253 253 253 253
50256 -253 253 253 253 253 253 253 253 253 253 253 253
50257 -253 253 253 253 253 253 242 242 242 242 242 242
50258 -253 253 253 253 253 253 253 253 253 253 253 253
50259 -253 253 253 253 253 253 253 253 253 253 253 253
50260 -253 253 253 253 253 253 253 253 253 253 253 253
50261 -253 253 253 253 253 253 253 253 253 253 253 253
50262 -253 253 253 253 253 253 182 182 182 2 2 6
50263 - 2 2 6 2 2 6 2 2 6 46 46 46
50264 - 2 2 6 2 2 6 2 2 6 2 2 6
50265 - 10 10 10 86 86 86 38 38 38 10 10 10
50266 - 0 0 0 0 0 0 0 0 0 0 0 0
50267 - 0 0 0 0 0 0 0 0 0 0 0 0
50268 - 0 0 0 0 0 0 0 0 0 0 0 0
50269 - 0 0 0 0 0 0 0 0 0 0 0 0
50270 - 0 0 0 0 0 0 0 0 0 0 0 0
50271 - 0 0 0 0 0 0 0 0 0 0 0 0
50272 - 0 0 0 0 0 0 0 0 0 0 0 0
50273 - 10 10 10 26 26 26 66 66 66 82 82 82
50274 - 2 2 6 22 22 22 18 18 18 2 2 6
50275 -149 149 149 253 253 253 253 253 253 253 253 253
50276 -253 253 253 253 253 253 253 253 253 253 253 253
50277 -253 253 253 253 253 253 234 234 234 242 242 242
50278 -253 253 253 253 253 253 253 253 253 253 253 253
50279 -253 253 253 253 253 253 253 253 253 253 253 253
50280 -253 253 253 253 253 253 253 253 253 253 253 253
50281 -253 253 253 253 253 253 253 253 253 253 253 253
50282 -253 253 253 253 253 253 206 206 206 2 2 6
50283 - 2 2 6 2 2 6 2 2 6 38 38 38
50284 - 2 2 6 2 2 6 2 2 6 2 2 6
50285 - 6 6 6 86 86 86 46 46 46 14 14 14
50286 - 0 0 0 0 0 0 0 0 0 0 0 0
50287 - 0 0 0 0 0 0 0 0 0 0 0 0
50288 - 0 0 0 0 0 0 0 0 0 0 0 0
50289 - 0 0 0 0 0 0 0 0 0 0 0 0
50290 - 0 0 0 0 0 0 0 0 0 0 0 0
50291 - 0 0 0 0 0 0 0 0 0 0 0 0
50292 - 0 0 0 0 0 0 0 0 0 6 6 6
50293 - 18 18 18 46 46 46 86 86 86 18 18 18
50294 - 2 2 6 34 34 34 10 10 10 6 6 6
50295 -210 210 210 253 253 253 253 253 253 253 253 253
50296 -253 253 253 253 253 253 253 253 253 253 253 253
50297 -253 253 253 253 253 253 234 234 234 242 242 242
50298 -253 253 253 253 253 253 253 253 253 253 253 253
50299 -253 253 253 253 253 253 253 253 253 253 253 253
50300 -253 253 253 253 253 253 253 253 253 253 253 253
50301 -253 253 253 253 253 253 253 253 253 253 253 253
50302 -253 253 253 253 253 253 221 221 221 6 6 6
50303 - 2 2 6 2 2 6 6 6 6 30 30 30
50304 - 2 2 6 2 2 6 2 2 6 2 2 6
50305 - 2 2 6 82 82 82 54 54 54 18 18 18
50306 - 6 6 6 0 0 0 0 0 0 0 0 0
50307 - 0 0 0 0 0 0 0 0 0 0 0 0
50308 - 0 0 0 0 0 0 0 0 0 0 0 0
50309 - 0 0 0 0 0 0 0 0 0 0 0 0
50310 - 0 0 0 0 0 0 0 0 0 0 0 0
50311 - 0 0 0 0 0 0 0 0 0 0 0 0
50312 - 0 0 0 0 0 0 0 0 0 10 10 10
50313 - 26 26 26 66 66 66 62 62 62 2 2 6
50314 - 2 2 6 38 38 38 10 10 10 26 26 26
50315 -238 238 238 253 253 253 253 253 253 253 253 253
50316 -253 253 253 253 253 253 253 253 253 253 253 253
50317 -253 253 253 253 253 253 231 231 231 238 238 238
50318 -253 253 253 253 253 253 253 253 253 253 253 253
50319 -253 253 253 253 253 253 253 253 253 253 253 253
50320 -253 253 253 253 253 253 253 253 253 253 253 253
50321 -253 253 253 253 253 253 253 253 253 253 253 253
50322 -253 253 253 253 253 253 231 231 231 6 6 6
50323 - 2 2 6 2 2 6 10 10 10 30 30 30
50324 - 2 2 6 2 2 6 2 2 6 2 2 6
50325 - 2 2 6 66 66 66 58 58 58 22 22 22
50326 - 6 6 6 0 0 0 0 0 0 0 0 0
50327 - 0 0 0 0 0 0 0 0 0 0 0 0
50328 - 0 0 0 0 0 0 0 0 0 0 0 0
50329 - 0 0 0 0 0 0 0 0 0 0 0 0
50330 - 0 0 0 0 0 0 0 0 0 0 0 0
50331 - 0 0 0 0 0 0 0 0 0 0 0 0
50332 - 0 0 0 0 0 0 0 0 0 10 10 10
50333 - 38 38 38 78 78 78 6 6 6 2 2 6
50334 - 2 2 6 46 46 46 14 14 14 42 42 42
50335 -246 246 246 253 253 253 253 253 253 253 253 253
50336 -253 253 253 253 253 253 253 253 253 253 253 253
50337 -253 253 253 253 253 253 231 231 231 242 242 242
50338 -253 253 253 253 253 253 253 253 253 253 253 253
50339 -253 253 253 253 253 253 253 253 253 253 253 253
50340 -253 253 253 253 253 253 253 253 253 253 253 253
50341 -253 253 253 253 253 253 253 253 253 253 253 253
50342 -253 253 253 253 253 253 234 234 234 10 10 10
50343 - 2 2 6 2 2 6 22 22 22 14 14 14
50344 - 2 2 6 2 2 6 2 2 6 2 2 6
50345 - 2 2 6 66 66 66 62 62 62 22 22 22
50346 - 6 6 6 0 0 0 0 0 0 0 0 0
50347 - 0 0 0 0 0 0 0 0 0 0 0 0
50348 - 0 0 0 0 0 0 0 0 0 0 0 0
50349 - 0 0 0 0 0 0 0 0 0 0 0 0
50350 - 0 0 0 0 0 0 0 0 0 0 0 0
50351 - 0 0 0 0 0 0 0 0 0 0 0 0
50352 - 0 0 0 0 0 0 6 6 6 18 18 18
50353 - 50 50 50 74 74 74 2 2 6 2 2 6
50354 - 14 14 14 70 70 70 34 34 34 62 62 62
50355 -250 250 250 253 253 253 253 253 253 253 253 253
50356 -253 253 253 253 253 253 253 253 253 253 253 253
50357 -253 253 253 253 253 253 231 231 231 246 246 246
50358 -253 253 253 253 253 253 253 253 253 253 253 253
50359 -253 253 253 253 253 253 253 253 253 253 253 253
50360 -253 253 253 253 253 253 253 253 253 253 253 253
50361 -253 253 253 253 253 253 253 253 253 253 253 253
50362 -253 253 253 253 253 253 234 234 234 14 14 14
50363 - 2 2 6 2 2 6 30 30 30 2 2 6
50364 - 2 2 6 2 2 6 2 2 6 2 2 6
50365 - 2 2 6 66 66 66 62 62 62 22 22 22
50366 - 6 6 6 0 0 0 0 0 0 0 0 0
50367 - 0 0 0 0 0 0 0 0 0 0 0 0
50368 - 0 0 0 0 0 0 0 0 0 0 0 0
50369 - 0 0 0 0 0 0 0 0 0 0 0 0
50370 - 0 0 0 0 0 0 0 0 0 0 0 0
50371 - 0 0 0 0 0 0 0 0 0 0 0 0
50372 - 0 0 0 0 0 0 6 6 6 18 18 18
50373 - 54 54 54 62 62 62 2 2 6 2 2 6
50374 - 2 2 6 30 30 30 46 46 46 70 70 70
50375 -250 250 250 253 253 253 253 253 253 253 253 253
50376 -253 253 253 253 253 253 253 253 253 253 253 253
50377 -253 253 253 253 253 253 231 231 231 246 246 246
50378 -253 253 253 253 253 253 253 253 253 253 253 253
50379 -253 253 253 253 253 253 253 253 253 253 253 253
50380 -253 253 253 253 253 253 253 253 253 253 253 253
50381 -253 253 253 253 253 253 253 253 253 253 253 253
50382 -253 253 253 253 253 253 226 226 226 10 10 10
50383 - 2 2 6 6 6 6 30 30 30 2 2 6
50384 - 2 2 6 2 2 6 2 2 6 2 2 6
50385 - 2 2 6 66 66 66 58 58 58 22 22 22
50386 - 6 6 6 0 0 0 0 0 0 0 0 0
50387 - 0 0 0 0 0 0 0 0 0 0 0 0
50388 - 0 0 0 0 0 0 0 0 0 0 0 0
50389 - 0 0 0 0 0 0 0 0 0 0 0 0
50390 - 0 0 0 0 0 0 0 0 0 0 0 0
50391 - 0 0 0 0 0 0 0 0 0 0 0 0
50392 - 0 0 0 0 0 0 6 6 6 22 22 22
50393 - 58 58 58 62 62 62 2 2 6 2 2 6
50394 - 2 2 6 2 2 6 30 30 30 78 78 78
50395 -250 250 250 253 253 253 253 253 253 253 253 253
50396 -253 253 253 253 253 253 253 253 253 253 253 253
50397 -253 253 253 253 253 253 231 231 231 246 246 246
50398 -253 253 253 253 253 253 253 253 253 253 253 253
50399 -253 253 253 253 253 253 253 253 253 253 253 253
50400 -253 253 253 253 253 253 253 253 253 253 253 253
50401 -253 253 253 253 253 253 253 253 253 253 253 253
50402 -253 253 253 253 253 253 206 206 206 2 2 6
50403 - 22 22 22 34 34 34 18 14 6 22 22 22
50404 - 26 26 26 18 18 18 6 6 6 2 2 6
50405 - 2 2 6 82 82 82 54 54 54 18 18 18
50406 - 6 6 6 0 0 0 0 0 0 0 0 0
50407 - 0 0 0 0 0 0 0 0 0 0 0 0
50408 - 0 0 0 0 0 0 0 0 0 0 0 0
50409 - 0 0 0 0 0 0 0 0 0 0 0 0
50410 - 0 0 0 0 0 0 0 0 0 0 0 0
50411 - 0 0 0 0 0 0 0 0 0 0 0 0
50412 - 0 0 0 0 0 0 6 6 6 26 26 26
50413 - 62 62 62 106 106 106 74 54 14 185 133 11
50414 -210 162 10 121 92 8 6 6 6 62 62 62
50415 -238 238 238 253 253 253 253 253 253 253 253 253
50416 -253 253 253 253 253 253 253 253 253 253 253 253
50417 -253 253 253 253 253 253 231 231 231 246 246 246
50418 -253 253 253 253 253 253 253 253 253 253 253 253
50419 -253 253 253 253 253 253 253 253 253 253 253 253
50420 -253 253 253 253 253 253 253 253 253 253 253 253
50421 -253 253 253 253 253 253 253 253 253 253 253 253
50422 -253 253 253 253 253 253 158 158 158 18 18 18
50423 - 14 14 14 2 2 6 2 2 6 2 2 6
50424 - 6 6 6 18 18 18 66 66 66 38 38 38
50425 - 6 6 6 94 94 94 50 50 50 18 18 18
50426 - 6 6 6 0 0 0 0 0 0 0 0 0
50427 - 0 0 0 0 0 0 0 0 0 0 0 0
50428 - 0 0 0 0 0 0 0 0 0 0 0 0
50429 - 0 0 0 0 0 0 0 0 0 0 0 0
50430 - 0 0 0 0 0 0 0 0 0 0 0 0
50431 - 0 0 0 0 0 0 0 0 0 6 6 6
50432 - 10 10 10 10 10 10 18 18 18 38 38 38
50433 - 78 78 78 142 134 106 216 158 10 242 186 14
50434 -246 190 14 246 190 14 156 118 10 10 10 10
50435 - 90 90 90 238 238 238 253 253 253 253 253 253
50436 -253 253 253 253 253 253 253 253 253 253 253 253
50437 -253 253 253 253 253 253 231 231 231 250 250 250
50438 -253 253 253 253 253 253 253 253 253 253 253 253
50439 -253 253 253 253 253 253 253 253 253 253 253 253
50440 -253 253 253 253 253 253 253 253 253 253 253 253
50441 -253 253 253 253 253 253 253 253 253 246 230 190
50442 -238 204 91 238 204 91 181 142 44 37 26 9
50443 - 2 2 6 2 2 6 2 2 6 2 2 6
50444 - 2 2 6 2 2 6 38 38 38 46 46 46
50445 - 26 26 26 106 106 106 54 54 54 18 18 18
50446 - 6 6 6 0 0 0 0 0 0 0 0 0
50447 - 0 0 0 0 0 0 0 0 0 0 0 0
50448 - 0 0 0 0 0 0 0 0 0 0 0 0
50449 - 0 0 0 0 0 0 0 0 0 0 0 0
50450 - 0 0 0 0 0 0 0 0 0 0 0 0
50451 - 0 0 0 6 6 6 14 14 14 22 22 22
50452 - 30 30 30 38 38 38 50 50 50 70 70 70
50453 -106 106 106 190 142 34 226 170 11 242 186 14
50454 -246 190 14 246 190 14 246 190 14 154 114 10
50455 - 6 6 6 74 74 74 226 226 226 253 253 253
50456 -253 253 253 253 253 253 253 253 253 253 253 253
50457 -253 253 253 253 253 253 231 231 231 250 250 250
50458 -253 253 253 253 253 253 253 253 253 253 253 253
50459 -253 253 253 253 253 253 253 253 253 253 253 253
50460 -253 253 253 253 253 253 253 253 253 253 253 253
50461 -253 253 253 253 253 253 253 253 253 228 184 62
50462 -241 196 14 241 208 19 232 195 16 38 30 10
50463 - 2 2 6 2 2 6 2 2 6 2 2 6
50464 - 2 2 6 6 6 6 30 30 30 26 26 26
50465 -203 166 17 154 142 90 66 66 66 26 26 26
50466 - 6 6 6 0 0 0 0 0 0 0 0 0
50467 - 0 0 0 0 0 0 0 0 0 0 0 0
50468 - 0 0 0 0 0 0 0 0 0 0 0 0
50469 - 0 0 0 0 0 0 0 0 0 0 0 0
50470 - 0 0 0 0 0 0 0 0 0 0 0 0
50471 - 6 6 6 18 18 18 38 38 38 58 58 58
50472 - 78 78 78 86 86 86 101 101 101 123 123 123
50473 -175 146 61 210 150 10 234 174 13 246 186 14
50474 -246 190 14 246 190 14 246 190 14 238 190 10
50475 -102 78 10 2 2 6 46 46 46 198 198 198
50476 -253 253 253 253 253 253 253 253 253 253 253 253
50477 -253 253 253 253 253 253 234 234 234 242 242 242
50478 -253 253 253 253 253 253 253 253 253 253 253 253
50479 -253 253 253 253 253 253 253 253 253 253 253 253
50480 -253 253 253 253 253 253 253 253 253 253 253 253
50481 -253 253 253 253 253 253 253 253 253 224 178 62
50482 -242 186 14 241 196 14 210 166 10 22 18 6
50483 - 2 2 6 2 2 6 2 2 6 2 2 6
50484 - 2 2 6 2 2 6 6 6 6 121 92 8
50485 -238 202 15 232 195 16 82 82 82 34 34 34
50486 - 10 10 10 0 0 0 0 0 0 0 0 0
50487 - 0 0 0 0 0 0 0 0 0 0 0 0
50488 - 0 0 0 0 0 0 0 0 0 0 0 0
50489 - 0 0 0 0 0 0 0 0 0 0 0 0
50490 - 0 0 0 0 0 0 0 0 0 0 0 0
50491 - 14 14 14 38 38 38 70 70 70 154 122 46
50492 -190 142 34 200 144 11 197 138 11 197 138 11
50493 -213 154 11 226 170 11 242 186 14 246 190 14
50494 -246 190 14 246 190 14 246 190 14 246 190 14
50495 -225 175 15 46 32 6 2 2 6 22 22 22
50496 -158 158 158 250 250 250 253 253 253 253 253 253
50497 -253 253 253 253 253 253 253 253 253 253 253 253
50498 -253 253 253 253 253 253 253 253 253 253 253 253
50499 -253 253 253 253 253 253 253 253 253 253 253 253
50500 -253 253 253 253 253 253 253 253 253 253 253 253
50501 -253 253 253 250 250 250 242 242 242 224 178 62
50502 -239 182 13 236 186 11 213 154 11 46 32 6
50503 - 2 2 6 2 2 6 2 2 6 2 2 6
50504 - 2 2 6 2 2 6 61 42 6 225 175 15
50505 -238 190 10 236 186 11 112 100 78 42 42 42
50506 - 14 14 14 0 0 0 0 0 0 0 0 0
50507 - 0 0 0 0 0 0 0 0 0 0 0 0
50508 - 0 0 0 0 0 0 0 0 0 0 0 0
50509 - 0 0 0 0 0 0 0 0 0 0 0 0
50510 - 0 0 0 0 0 0 0 0 0 6 6 6
50511 - 22 22 22 54 54 54 154 122 46 213 154 11
50512 -226 170 11 230 174 11 226 170 11 226 170 11
50513 -236 178 12 242 186 14 246 190 14 246 190 14
50514 -246 190 14 246 190 14 246 190 14 246 190 14
50515 -241 196 14 184 144 12 10 10 10 2 2 6
50516 - 6 6 6 116 116 116 242 242 242 253 253 253
50517 -253 253 253 253 253 253 253 253 253 253 253 253
50518 -253 253 253 253 253 253 253 253 253 253 253 253
50519 -253 253 253 253 253 253 253 253 253 253 253 253
50520 -253 253 253 253 253 253 253 253 253 253 253 253
50521 -253 253 253 231 231 231 198 198 198 214 170 54
50522 -236 178 12 236 178 12 210 150 10 137 92 6
50523 - 18 14 6 2 2 6 2 2 6 2 2 6
50524 - 6 6 6 70 47 6 200 144 11 236 178 12
50525 -239 182 13 239 182 13 124 112 88 58 58 58
50526 - 22 22 22 6 6 6 0 0 0 0 0 0
50527 - 0 0 0 0 0 0 0 0 0 0 0 0
50528 - 0 0 0 0 0 0 0 0 0 0 0 0
50529 - 0 0 0 0 0 0 0 0 0 0 0 0
50530 - 0 0 0 0 0 0 0 0 0 10 10 10
50531 - 30 30 30 70 70 70 180 133 36 226 170 11
50532 -239 182 13 242 186 14 242 186 14 246 186 14
50533 -246 190 14 246 190 14 246 190 14 246 190 14
50534 -246 190 14 246 190 14 246 190 14 246 190 14
50535 -246 190 14 232 195 16 98 70 6 2 2 6
50536 - 2 2 6 2 2 6 66 66 66 221 221 221
50537 -253 253 253 253 253 253 253 253 253 253 253 253
50538 -253 253 253 253 253 253 253 253 253 253 253 253
50539 -253 253 253 253 253 253 253 253 253 253 253 253
50540 -253 253 253 253 253 253 253 253 253 253 253 253
50541 -253 253 253 206 206 206 198 198 198 214 166 58
50542 -230 174 11 230 174 11 216 158 10 192 133 9
50543 -163 110 8 116 81 8 102 78 10 116 81 8
50544 -167 114 7 197 138 11 226 170 11 239 182 13
50545 -242 186 14 242 186 14 162 146 94 78 78 78
50546 - 34 34 34 14 14 14 6 6 6 0 0 0
50547 - 0 0 0 0 0 0 0 0 0 0 0 0
50548 - 0 0 0 0 0 0 0 0 0 0 0 0
50549 - 0 0 0 0 0 0 0 0 0 0 0 0
50550 - 0 0 0 0 0 0 0 0 0 6 6 6
50551 - 30 30 30 78 78 78 190 142 34 226 170 11
50552 -239 182 13 246 190 14 246 190 14 246 190 14
50553 -246 190 14 246 190 14 246 190 14 246 190 14
50554 -246 190 14 246 190 14 246 190 14 246 190 14
50555 -246 190 14 241 196 14 203 166 17 22 18 6
50556 - 2 2 6 2 2 6 2 2 6 38 38 38
50557 -218 218 218 253 253 253 253 253 253 253 253 253
50558 -253 253 253 253 253 253 253 253 253 253 253 253
50559 -253 253 253 253 253 253 253 253 253 253 253 253
50560 -253 253 253 253 253 253 253 253 253 253 253 253
50561 -250 250 250 206 206 206 198 198 198 202 162 69
50562 -226 170 11 236 178 12 224 166 10 210 150 10
50563 -200 144 11 197 138 11 192 133 9 197 138 11
50564 -210 150 10 226 170 11 242 186 14 246 190 14
50565 -246 190 14 246 186 14 225 175 15 124 112 88
50566 - 62 62 62 30 30 30 14 14 14 6 6 6
50567 - 0 0 0 0 0 0 0 0 0 0 0 0
50568 - 0 0 0 0 0 0 0 0 0 0 0 0
50569 - 0 0 0 0 0 0 0 0 0 0 0 0
50570 - 0 0 0 0 0 0 0 0 0 10 10 10
50571 - 30 30 30 78 78 78 174 135 50 224 166 10
50572 -239 182 13 246 190 14 246 190 14 246 190 14
50573 -246 190 14 246 190 14 246 190 14 246 190 14
50574 -246 190 14 246 190 14 246 190 14 246 190 14
50575 -246 190 14 246 190 14 241 196 14 139 102 15
50576 - 2 2 6 2 2 6 2 2 6 2 2 6
50577 - 78 78 78 250 250 250 253 253 253 253 253 253
50578 -253 253 253 253 253 253 253 253 253 253 253 253
50579 -253 253 253 253 253 253 253 253 253 253 253 253
50580 -253 253 253 253 253 253 253 253 253 253 253 253
50581 -250 250 250 214 214 214 198 198 198 190 150 46
50582 -219 162 10 236 178 12 234 174 13 224 166 10
50583 -216 158 10 213 154 11 213 154 11 216 158 10
50584 -226 170 11 239 182 13 246 190 14 246 190 14
50585 -246 190 14 246 190 14 242 186 14 206 162 42
50586 -101 101 101 58 58 58 30 30 30 14 14 14
50587 - 6 6 6 0 0 0 0 0 0 0 0 0
50588 - 0 0 0 0 0 0 0 0 0 0 0 0
50589 - 0 0 0 0 0 0 0 0 0 0 0 0
50590 - 0 0 0 0 0 0 0 0 0 10 10 10
50591 - 30 30 30 74 74 74 174 135 50 216 158 10
50592 -236 178 12 246 190 14 246 190 14 246 190 14
50593 -246 190 14 246 190 14 246 190 14 246 190 14
50594 -246 190 14 246 190 14 246 190 14 246 190 14
50595 -246 190 14 246 190 14 241 196 14 226 184 13
50596 - 61 42 6 2 2 6 2 2 6 2 2 6
50597 - 22 22 22 238 238 238 253 253 253 253 253 253
50598 -253 253 253 253 253 253 253 253 253 253 253 253
50599 -253 253 253 253 253 253 253 253 253 253 253 253
50600 -253 253 253 253 253 253 253 253 253 253 253 253
50601 -253 253 253 226 226 226 187 187 187 180 133 36
50602 -216 158 10 236 178 12 239 182 13 236 178 12
50603 -230 174 11 226 170 11 226 170 11 230 174 11
50604 -236 178 12 242 186 14 246 190 14 246 190 14
50605 -246 190 14 246 190 14 246 186 14 239 182 13
50606 -206 162 42 106 106 106 66 66 66 34 34 34
50607 - 14 14 14 6 6 6 0 0 0 0 0 0
50608 - 0 0 0 0 0 0 0 0 0 0 0 0
50609 - 0 0 0 0 0 0 0 0 0 0 0 0
50610 - 0 0 0 0 0 0 0 0 0 6 6 6
50611 - 26 26 26 70 70 70 163 133 67 213 154 11
50612 -236 178 12 246 190 14 246 190 14 246 190 14
50613 -246 190 14 246 190 14 246 190 14 246 190 14
50614 -246 190 14 246 190 14 246 190 14 246 190 14
50615 -246 190 14 246 190 14 246 190 14 241 196 14
50616 -190 146 13 18 14 6 2 2 6 2 2 6
50617 - 46 46 46 246 246 246 253 253 253 253 253 253
50618 -253 253 253 253 253 253 253 253 253 253 253 253
50619 -253 253 253 253 253 253 253 253 253 253 253 253
50620 -253 253 253 253 253 253 253 253 253 253 253 253
50621 -253 253 253 221 221 221 86 86 86 156 107 11
50622 -216 158 10 236 178 12 242 186 14 246 186 14
50623 -242 186 14 239 182 13 239 182 13 242 186 14
50624 -242 186 14 246 186 14 246 190 14 246 190 14
50625 -246 190 14 246 190 14 246 190 14 246 190 14
50626 -242 186 14 225 175 15 142 122 72 66 66 66
50627 - 30 30 30 10 10 10 0 0 0 0 0 0
50628 - 0 0 0 0 0 0 0 0 0 0 0 0
50629 - 0 0 0 0 0 0 0 0 0 0 0 0
50630 - 0 0 0 0 0 0 0 0 0 6 6 6
50631 - 26 26 26 70 70 70 163 133 67 210 150 10
50632 -236 178 12 246 190 14 246 190 14 246 190 14
50633 -246 190 14 246 190 14 246 190 14 246 190 14
50634 -246 190 14 246 190 14 246 190 14 246 190 14
50635 -246 190 14 246 190 14 246 190 14 246 190 14
50636 -232 195 16 121 92 8 34 34 34 106 106 106
50637 -221 221 221 253 253 253 253 253 253 253 253 253
50638 -253 253 253 253 253 253 253 253 253 253 253 253
50639 -253 253 253 253 253 253 253 253 253 253 253 253
50640 -253 253 253 253 253 253 253 253 253 253 253 253
50641 -242 242 242 82 82 82 18 14 6 163 110 8
50642 -216 158 10 236 178 12 242 186 14 246 190 14
50643 -246 190 14 246 190 14 246 190 14 246 190 14
50644 -246 190 14 246 190 14 246 190 14 246 190 14
50645 -246 190 14 246 190 14 246 190 14 246 190 14
50646 -246 190 14 246 190 14 242 186 14 163 133 67
50647 - 46 46 46 18 18 18 6 6 6 0 0 0
50648 - 0 0 0 0 0 0 0 0 0 0 0 0
50649 - 0 0 0 0 0 0 0 0 0 0 0 0
50650 - 0 0 0 0 0 0 0 0 0 10 10 10
50651 - 30 30 30 78 78 78 163 133 67 210 150 10
50652 -236 178 12 246 186 14 246 190 14 246 190 14
50653 -246 190 14 246 190 14 246 190 14 246 190 14
50654 -246 190 14 246 190 14 246 190 14 246 190 14
50655 -246 190 14 246 190 14 246 190 14 246 190 14
50656 -241 196 14 215 174 15 190 178 144 253 253 253
50657 -253 253 253 253 253 253 253 253 253 253 253 253
50658 -253 253 253 253 253 253 253 253 253 253 253 253
50659 -253 253 253 253 253 253 253 253 253 253 253 253
50660 -253 253 253 253 253 253 253 253 253 218 218 218
50661 - 58 58 58 2 2 6 22 18 6 167 114 7
50662 -216 158 10 236 178 12 246 186 14 246 190 14
50663 -246 190 14 246 190 14 246 190 14 246 190 14
50664 -246 190 14 246 190 14 246 190 14 246 190 14
50665 -246 190 14 246 190 14 246 190 14 246 190 14
50666 -246 190 14 246 186 14 242 186 14 190 150 46
50667 - 54 54 54 22 22 22 6 6 6 0 0 0
50668 - 0 0 0 0 0 0 0 0 0 0 0 0
50669 - 0 0 0 0 0 0 0 0 0 0 0 0
50670 - 0 0 0 0 0 0 0 0 0 14 14 14
50671 - 38 38 38 86 86 86 180 133 36 213 154 11
50672 -236 178 12 246 186 14 246 190 14 246 190 14
50673 -246 190 14 246 190 14 246 190 14 246 190 14
50674 -246 190 14 246 190 14 246 190 14 246 190 14
50675 -246 190 14 246 190 14 246 190 14 246 190 14
50676 -246 190 14 232 195 16 190 146 13 214 214 214
50677 -253 253 253 253 253 253 253 253 253 253 253 253
50678 -253 253 253 253 253 253 253 253 253 253 253 253
50679 -253 253 253 253 253 253 253 253 253 253 253 253
50680 -253 253 253 250 250 250 170 170 170 26 26 26
50681 - 2 2 6 2 2 6 37 26 9 163 110 8
50682 -219 162 10 239 182 13 246 186 14 246 190 14
50683 -246 190 14 246 190 14 246 190 14 246 190 14
50684 -246 190 14 246 190 14 246 190 14 246 190 14
50685 -246 190 14 246 190 14 246 190 14 246 190 14
50686 -246 186 14 236 178 12 224 166 10 142 122 72
50687 - 46 46 46 18 18 18 6 6 6 0 0 0
50688 - 0 0 0 0 0 0 0 0 0 0 0 0
50689 - 0 0 0 0 0 0 0 0 0 0 0 0
50690 - 0 0 0 0 0 0 6 6 6 18 18 18
50691 - 50 50 50 109 106 95 192 133 9 224 166 10
50692 -242 186 14 246 190 14 246 190 14 246 190 14
50693 -246 190 14 246 190 14 246 190 14 246 190 14
50694 -246 190 14 246 190 14 246 190 14 246 190 14
50695 -246 190 14 246 190 14 246 190 14 246 190 14
50696 -242 186 14 226 184 13 210 162 10 142 110 46
50697 -226 226 226 253 253 253 253 253 253 253 253 253
50698 -253 253 253 253 253 253 253 253 253 253 253 253
50699 -253 253 253 253 253 253 253 253 253 253 253 253
50700 -198 198 198 66 66 66 2 2 6 2 2 6
50701 - 2 2 6 2 2 6 50 34 6 156 107 11
50702 -219 162 10 239 182 13 246 186 14 246 190 14
50703 -246 190 14 246 190 14 246 190 14 246 190 14
50704 -246 190 14 246 190 14 246 190 14 246 190 14
50705 -246 190 14 246 190 14 246 190 14 242 186 14
50706 -234 174 13 213 154 11 154 122 46 66 66 66
50707 - 30 30 30 10 10 10 0 0 0 0 0 0
50708 - 0 0 0 0 0 0 0 0 0 0 0 0
50709 - 0 0 0 0 0 0 0 0 0 0 0 0
50710 - 0 0 0 0 0 0 6 6 6 22 22 22
50711 - 58 58 58 154 121 60 206 145 10 234 174 13
50712 -242 186 14 246 186 14 246 190 14 246 190 14
50713 -246 190 14 246 190 14 246 190 14 246 190 14
50714 -246 190 14 246 190 14 246 190 14 246 190 14
50715 -246 190 14 246 190 14 246 190 14 246 190 14
50716 -246 186 14 236 178 12 210 162 10 163 110 8
50717 - 61 42 6 138 138 138 218 218 218 250 250 250
50718 -253 253 253 253 253 253 253 253 253 250 250 250
50719 -242 242 242 210 210 210 144 144 144 66 66 66
50720 - 6 6 6 2 2 6 2 2 6 2 2 6
50721 - 2 2 6 2 2 6 61 42 6 163 110 8
50722 -216 158 10 236 178 12 246 190 14 246 190 14
50723 -246 190 14 246 190 14 246 190 14 246 190 14
50724 -246 190 14 246 190 14 246 190 14 246 190 14
50725 -246 190 14 239 182 13 230 174 11 216 158 10
50726 -190 142 34 124 112 88 70 70 70 38 38 38
50727 - 18 18 18 6 6 6 0 0 0 0 0 0
50728 - 0 0 0 0 0 0 0 0 0 0 0 0
50729 - 0 0 0 0 0 0 0 0 0 0 0 0
50730 - 0 0 0 0 0 0 6 6 6 22 22 22
50731 - 62 62 62 168 124 44 206 145 10 224 166 10
50732 -236 178 12 239 182 13 242 186 14 242 186 14
50733 -246 186 14 246 190 14 246 190 14 246 190 14
50734 -246 190 14 246 190 14 246 190 14 246 190 14
50735 -246 190 14 246 190 14 246 190 14 246 190 14
50736 -246 190 14 236 178 12 216 158 10 175 118 6
50737 - 80 54 7 2 2 6 6 6 6 30 30 30
50738 - 54 54 54 62 62 62 50 50 50 38 38 38
50739 - 14 14 14 2 2 6 2 2 6 2 2 6
50740 - 2 2 6 2 2 6 2 2 6 2 2 6
50741 - 2 2 6 6 6 6 80 54 7 167 114 7
50742 -213 154 11 236 178 12 246 190 14 246 190 14
50743 -246 190 14 246 190 14 246 190 14 246 190 14
50744 -246 190 14 242 186 14 239 182 13 239 182 13
50745 -230 174 11 210 150 10 174 135 50 124 112 88
50746 - 82 82 82 54 54 54 34 34 34 18 18 18
50747 - 6 6 6 0 0 0 0 0 0 0 0 0
50748 - 0 0 0 0 0 0 0 0 0 0 0 0
50749 - 0 0 0 0 0 0 0 0 0 0 0 0
50750 - 0 0 0 0 0 0 6 6 6 18 18 18
50751 - 50 50 50 158 118 36 192 133 9 200 144 11
50752 -216 158 10 219 162 10 224 166 10 226 170 11
50753 -230 174 11 236 178 12 239 182 13 239 182 13
50754 -242 186 14 246 186 14 246 190 14 246 190 14
50755 -246 190 14 246 190 14 246 190 14 246 190 14
50756 -246 186 14 230 174 11 210 150 10 163 110 8
50757 -104 69 6 10 10 10 2 2 6 2 2 6
50758 - 2 2 6 2 2 6 2 2 6 2 2 6
50759 - 2 2 6 2 2 6 2 2 6 2 2 6
50760 - 2 2 6 2 2 6 2 2 6 2 2 6
50761 - 2 2 6 6 6 6 91 60 6 167 114 7
50762 -206 145 10 230 174 11 242 186 14 246 190 14
50763 -246 190 14 246 190 14 246 186 14 242 186 14
50764 -239 182 13 230 174 11 224 166 10 213 154 11
50765 -180 133 36 124 112 88 86 86 86 58 58 58
50766 - 38 38 38 22 22 22 10 10 10 6 6 6
50767 - 0 0 0 0 0 0 0 0 0 0 0 0
50768 - 0 0 0 0 0 0 0 0 0 0 0 0
50769 - 0 0 0 0 0 0 0 0 0 0 0 0
50770 - 0 0 0 0 0 0 0 0 0 14 14 14
50771 - 34 34 34 70 70 70 138 110 50 158 118 36
50772 -167 114 7 180 123 7 192 133 9 197 138 11
50773 -200 144 11 206 145 10 213 154 11 219 162 10
50774 -224 166 10 230 174 11 239 182 13 242 186 14
50775 -246 186 14 246 186 14 246 186 14 246 186 14
50776 -239 182 13 216 158 10 185 133 11 152 99 6
50777 -104 69 6 18 14 6 2 2 6 2 2 6
50778 - 2 2 6 2 2 6 2 2 6 2 2 6
50779 - 2 2 6 2 2 6 2 2 6 2 2 6
50780 - 2 2 6 2 2 6 2 2 6 2 2 6
50781 - 2 2 6 6 6 6 80 54 7 152 99 6
50782 -192 133 9 219 162 10 236 178 12 239 182 13
50783 -246 186 14 242 186 14 239 182 13 236 178 12
50784 -224 166 10 206 145 10 192 133 9 154 121 60
50785 - 94 94 94 62 62 62 42 42 42 22 22 22
50786 - 14 14 14 6 6 6 0 0 0 0 0 0
50787 - 0 0 0 0 0 0 0 0 0 0 0 0
50788 - 0 0 0 0 0 0 0 0 0 0 0 0
50789 - 0 0 0 0 0 0 0 0 0 0 0 0
50790 - 0 0 0 0 0 0 0 0 0 6 6 6
50791 - 18 18 18 34 34 34 58 58 58 78 78 78
50792 -101 98 89 124 112 88 142 110 46 156 107 11
50793 -163 110 8 167 114 7 175 118 6 180 123 7
50794 -185 133 11 197 138 11 210 150 10 219 162 10
50795 -226 170 11 236 178 12 236 178 12 234 174 13
50796 -219 162 10 197 138 11 163 110 8 130 83 6
50797 - 91 60 6 10 10 10 2 2 6 2 2 6
50798 - 18 18 18 38 38 38 38 38 38 38 38 38
50799 - 38 38 38 38 38 38 38 38 38 38 38 38
50800 - 38 38 38 38 38 38 26 26 26 2 2 6
50801 - 2 2 6 6 6 6 70 47 6 137 92 6
50802 -175 118 6 200 144 11 219 162 10 230 174 11
50803 -234 174 13 230 174 11 219 162 10 210 150 10
50804 -192 133 9 163 110 8 124 112 88 82 82 82
50805 - 50 50 50 30 30 30 14 14 14 6 6 6
50806 - 0 0 0 0 0 0 0 0 0 0 0 0
50807 - 0 0 0 0 0 0 0 0 0 0 0 0
50808 - 0 0 0 0 0 0 0 0 0 0 0 0
50809 - 0 0 0 0 0 0 0 0 0 0 0 0
50810 - 0 0 0 0 0 0 0 0 0 0 0 0
50811 - 6 6 6 14 14 14 22 22 22 34 34 34
50812 - 42 42 42 58 58 58 74 74 74 86 86 86
50813 -101 98 89 122 102 70 130 98 46 121 87 25
50814 -137 92 6 152 99 6 163 110 8 180 123 7
50815 -185 133 11 197 138 11 206 145 10 200 144 11
50816 -180 123 7 156 107 11 130 83 6 104 69 6
50817 - 50 34 6 54 54 54 110 110 110 101 98 89
50818 - 86 86 86 82 82 82 78 78 78 78 78 78
50819 - 78 78 78 78 78 78 78 78 78 78 78 78
50820 - 78 78 78 82 82 82 86 86 86 94 94 94
50821 -106 106 106 101 101 101 86 66 34 124 80 6
50822 -156 107 11 180 123 7 192 133 9 200 144 11
50823 -206 145 10 200 144 11 192 133 9 175 118 6
50824 -139 102 15 109 106 95 70 70 70 42 42 42
50825 - 22 22 22 10 10 10 0 0 0 0 0 0
50826 - 0 0 0 0 0 0 0 0 0 0 0 0
50827 - 0 0 0 0 0 0 0 0 0 0 0 0
50828 - 0 0 0 0 0 0 0 0 0 0 0 0
50829 - 0 0 0 0 0 0 0 0 0 0 0 0
50830 - 0 0 0 0 0 0 0 0 0 0 0 0
50831 - 0 0 0 0 0 0 6 6 6 10 10 10
50832 - 14 14 14 22 22 22 30 30 30 38 38 38
50833 - 50 50 50 62 62 62 74 74 74 90 90 90
50834 -101 98 89 112 100 78 121 87 25 124 80 6
50835 -137 92 6 152 99 6 152 99 6 152 99 6
50836 -138 86 6 124 80 6 98 70 6 86 66 30
50837 -101 98 89 82 82 82 58 58 58 46 46 46
50838 - 38 38 38 34 34 34 34 34 34 34 34 34
50839 - 34 34 34 34 34 34 34 34 34 34 34 34
50840 - 34 34 34 34 34 34 38 38 38 42 42 42
50841 - 54 54 54 82 82 82 94 86 76 91 60 6
50842 -134 86 6 156 107 11 167 114 7 175 118 6
50843 -175 118 6 167 114 7 152 99 6 121 87 25
50844 -101 98 89 62 62 62 34 34 34 18 18 18
50845 - 6 6 6 0 0 0 0 0 0 0 0 0
50846 - 0 0 0 0 0 0 0 0 0 0 0 0
50847 - 0 0 0 0 0 0 0 0 0 0 0 0
50848 - 0 0 0 0 0 0 0 0 0 0 0 0
50849 - 0 0 0 0 0 0 0 0 0 0 0 0
50850 - 0 0 0 0 0 0 0 0 0 0 0 0
50851 - 0 0 0 0 0 0 0 0 0 0 0 0
50852 - 0 0 0 6 6 6 6 6 6 10 10 10
50853 - 18 18 18 22 22 22 30 30 30 42 42 42
50854 - 50 50 50 66 66 66 86 86 86 101 98 89
50855 -106 86 58 98 70 6 104 69 6 104 69 6
50856 -104 69 6 91 60 6 82 62 34 90 90 90
50857 - 62 62 62 38 38 38 22 22 22 14 14 14
50858 - 10 10 10 10 10 10 10 10 10 10 10 10
50859 - 10 10 10 10 10 10 6 6 6 10 10 10
50860 - 10 10 10 10 10 10 10 10 10 14 14 14
50861 - 22 22 22 42 42 42 70 70 70 89 81 66
50862 - 80 54 7 104 69 6 124 80 6 137 92 6
50863 -134 86 6 116 81 8 100 82 52 86 86 86
50864 - 58 58 58 30 30 30 14 14 14 6 6 6
50865 - 0 0 0 0 0 0 0 0 0 0 0 0
50866 - 0 0 0 0 0 0 0 0 0 0 0 0
50867 - 0 0 0 0 0 0 0 0 0 0 0 0
50868 - 0 0 0 0 0 0 0 0 0 0 0 0
50869 - 0 0 0 0 0 0 0 0 0 0 0 0
50870 - 0 0 0 0 0 0 0 0 0 0 0 0
50871 - 0 0 0 0 0 0 0 0 0 0 0 0
50872 - 0 0 0 0 0 0 0 0 0 0 0 0
50873 - 0 0 0 6 6 6 10 10 10 14 14 14
50874 - 18 18 18 26 26 26 38 38 38 54 54 54
50875 - 70 70 70 86 86 86 94 86 76 89 81 66
50876 - 89 81 66 86 86 86 74 74 74 50 50 50
50877 - 30 30 30 14 14 14 6 6 6 0 0 0
50878 - 0 0 0 0 0 0 0 0 0 0 0 0
50879 - 0 0 0 0 0 0 0 0 0 0 0 0
50880 - 0 0 0 0 0 0 0 0 0 0 0 0
50881 - 6 6 6 18 18 18 34 34 34 58 58 58
50882 - 82 82 82 89 81 66 89 81 66 89 81 66
50883 - 94 86 66 94 86 76 74 74 74 50 50 50
50884 - 26 26 26 14 14 14 6 6 6 0 0 0
50885 - 0 0 0 0 0 0 0 0 0 0 0 0
50886 - 0 0 0 0 0 0 0 0 0 0 0 0
50887 - 0 0 0 0 0 0 0 0 0 0 0 0
50888 - 0 0 0 0 0 0 0 0 0 0 0 0
50889 - 0 0 0 0 0 0 0 0 0 0 0 0
50890 - 0 0 0 0 0 0 0 0 0 0 0 0
50891 - 0 0 0 0 0 0 0 0 0 0 0 0
50892 - 0 0 0 0 0 0 0 0 0 0 0 0
50893 - 0 0 0 0 0 0 0 0 0 0 0 0
50894 - 6 6 6 6 6 6 14 14 14 18 18 18
50895 - 30 30 30 38 38 38 46 46 46 54 54 54
50896 - 50 50 50 42 42 42 30 30 30 18 18 18
50897 - 10 10 10 0 0 0 0 0 0 0 0 0
50898 - 0 0 0 0 0 0 0 0 0 0 0 0
50899 - 0 0 0 0 0 0 0 0 0 0 0 0
50900 - 0 0 0 0 0 0 0 0 0 0 0 0
50901 - 0 0 0 6 6 6 14 14 14 26 26 26
50902 - 38 38 38 50 50 50 58 58 58 58 58 58
50903 - 54 54 54 42 42 42 30 30 30 18 18 18
50904 - 10 10 10 0 0 0 0 0 0 0 0 0
50905 - 0 0 0 0 0 0 0 0 0 0 0 0
50906 - 0 0 0 0 0 0 0 0 0 0 0 0
50907 - 0 0 0 0 0 0 0 0 0 0 0 0
50908 - 0 0 0 0 0 0 0 0 0 0 0 0
50909 - 0 0 0 0 0 0 0 0 0 0 0 0
50910 - 0 0 0 0 0 0 0 0 0 0 0 0
50911 - 0 0 0 0 0 0 0 0 0 0 0 0
50912 - 0 0 0 0 0 0 0 0 0 0 0 0
50913 - 0 0 0 0 0 0 0 0 0 0 0 0
50914 - 0 0 0 0 0 0 0 0 0 6 6 6
50915 - 6 6 6 10 10 10 14 14 14 18 18 18
50916 - 18 18 18 14 14 14 10 10 10 6 6 6
50917 - 0 0 0 0 0 0 0 0 0 0 0 0
50918 - 0 0 0 0 0 0 0 0 0 0 0 0
50919 - 0 0 0 0 0 0 0 0 0 0 0 0
50920 - 0 0 0 0 0 0 0 0 0 0 0 0
50921 - 0 0 0 0 0 0 0 0 0 6 6 6
50922 - 14 14 14 18 18 18 22 22 22 22 22 22
50923 - 18 18 18 14 14 14 10 10 10 6 6 6
50924 - 0 0 0 0 0 0 0 0 0 0 0 0
50925 - 0 0 0 0 0 0 0 0 0 0 0 0
50926 - 0 0 0 0 0 0 0 0 0 0 0 0
50927 - 0 0 0 0 0 0 0 0 0 0 0 0
50928 - 0 0 0 0 0 0 0 0 0 0 0 0
50929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50942 +4 4 4 4 4 4
50943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50956 +4 4 4 4 4 4
50957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50970 +4 4 4 4 4 4
50971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50984 +4 4 4 4 4 4
50985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50998 +4 4 4 4 4 4
50999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51012 +4 4 4 4 4 4
51013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51017 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51018 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51022 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51023 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51024 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51026 +4 4 4 4 4 4
51027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51031 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51032 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51033 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51036 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51037 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51038 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51039 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51040 +4 4 4 4 4 4
51041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51045 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51046 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51047 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51050 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51051 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51052 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51053 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51054 +4 4 4 4 4 4
51055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51058 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51059 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51060 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51061 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51063 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51064 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51065 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51066 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51067 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51068 +4 4 4 4 4 4
51069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51072 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51073 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51074 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51075 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51076 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51077 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51078 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51079 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51080 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51081 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51082 +4 4 4 4 4 4
51083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51086 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51087 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51088 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51089 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51090 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51091 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51092 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51093 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51094 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51095 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51096 +4 4 4 4 4 4
51097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51099 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51100 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51101 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51102 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51103 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51104 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51105 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51106 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51107 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51108 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51109 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51110 +4 4 4 4 4 4
51111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51113 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51114 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51115 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51116 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51117 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51118 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51119 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51120 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51121 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51122 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51123 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51124 +4 4 4 4 4 4
51125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51127 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51128 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51129 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51130 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51131 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51132 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51133 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51134 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51135 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51136 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51137 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51138 +4 4 4 4 4 4
51139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51141 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51142 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51143 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51144 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51145 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51146 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51147 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51148 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51149 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51150 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51151 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51152 +4 4 4 4 4 4
51153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51154 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51155 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51156 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51157 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51158 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51159 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51160 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51161 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51162 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51163 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51164 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51165 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51166 +4 4 4 4 4 4
51167 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51168 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51169 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51170 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51171 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51172 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51173 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51174 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51175 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51176 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51177 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51178 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51179 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51180 +0 0 0 4 4 4
51181 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51182 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51183 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51184 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51185 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51186 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51187 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51188 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51189 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51190 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51191 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51192 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51193 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51194 +2 0 0 0 0 0
51195 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51196 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51197 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51198 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51199 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51200 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51201 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51202 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51203 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51204 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51205 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51206 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51207 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51208 +37 38 37 0 0 0
51209 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51210 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51211 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51212 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51213 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51214 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51215 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51216 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51217 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51218 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51219 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51220 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51221 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51222 +85 115 134 4 0 0
51223 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51224 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51225 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51226 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51227 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51228 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51229 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51230 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51231 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51232 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51233 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51234 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51235 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51236 +60 73 81 4 0 0
51237 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51238 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51239 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51240 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51241 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51242 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51243 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51244 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51245 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51246 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51247 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51248 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51249 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51250 +16 19 21 4 0 0
51251 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51252 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51253 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51254 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51255 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51256 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51257 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51258 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51259 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51260 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51261 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51262 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51263 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51264 +4 0 0 4 3 3
51265 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51266 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51267 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51269 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51270 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51271 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51272 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51273 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51274 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51275 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51276 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51277 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51278 +3 2 2 4 4 4
51279 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
51280 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
51281 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
51282 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51283 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
51284 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
51285 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51286 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
51287 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
51288 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
51289 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
51290 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
51291 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
51292 +4 4 4 4 4 4
51293 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
51294 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
51295 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
51296 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
51297 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
51298 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
51299 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
51300 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
51301 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
51302 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
51303 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
51304 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
51305 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
51306 +4 4 4 4 4 4
51307 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
51308 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
51309 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
51310 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
51311 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
51312 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51313 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
51314 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
51315 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
51316 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
51317 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
51318 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
51319 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
51320 +5 5 5 5 5 5
51321 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
51322 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
51323 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
51324 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
51325 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
51326 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51327 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
51328 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
51329 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
51330 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
51331 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
51332 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
51333 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51334 +5 5 5 4 4 4
51335 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
51336 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
51337 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
51338 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
51339 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51340 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
51341 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
51342 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51343 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51344 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51345 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51346 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51348 +4 4 4 4 4 4
51349 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51350 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51351 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51352 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51353 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51354 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51355 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51356 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51357 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51358 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51359 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51360 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
51361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51362 +4 4 4 4 4 4
51363 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51364 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51365 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51366 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51367 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51368 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51369 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51370 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51371 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51372 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51373 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51376 +4 4 4 4 4 4
51377 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51378 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51379 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51380 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51381 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51382 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51383 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51384 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51385 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51386 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51387 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51390 +4 4 4 4 4 4
51391 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51392 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51393 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51394 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51395 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51396 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51397 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51398 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51399 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51400 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51401 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51404 +4 4 4 4 4 4
51405 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51406 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51407 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51408 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51409 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51410 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51411 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51412 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51413 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51414 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51415 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51418 +4 4 4 4 4 4
51419 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51420 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51421 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51422 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51423 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51424 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51425 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51426 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51427 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51428 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51429 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51432 +4 4 4 4 4 4
51433 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51434 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51435 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51436 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51437 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51438 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51439 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51440 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51441 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51442 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51443 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51446 +4 4 4 4 4 4
51447 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51448 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51449 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51450 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51451 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51452 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51453 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51454 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51455 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51456 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51457 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51460 +4 4 4 4 4 4
51461 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51462 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51463 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51464 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51465 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51466 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51467 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51468 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51469 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51470 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51471 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51474 +4 4 4 4 4 4
51475 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51476 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51477 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51478 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51479 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51480 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51481 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51482 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51483 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51484 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51485 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51488 +4 4 4 4 4 4
51489 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51490 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51491 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51492 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51493 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51494 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51495 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51496 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51497 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51498 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51499 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51502 +4 4 4 4 4 4
51503 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51504 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51505 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51506 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51507 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51508 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51509 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51510 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51511 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51512 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51513 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51516 +4 4 4 4 4 4
51517 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51518 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51519 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51520 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51521 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51522 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51523 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51524 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51525 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51526 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51527 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51530 +4 4 4 4 4 4
51531 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51532 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51533 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51534 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51535 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51536 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51537 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51538 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51539 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51540 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51541 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51544 +4 4 4 4 4 4
51545 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51546 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51547 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51548 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51549 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51550 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51551 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51552 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51553 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51554 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51555 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4
51559 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51560 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51561 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51562 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51563 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51564 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51565 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51566 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51567 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51568 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51569 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4
51573 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51574 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51575 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51576 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51577 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51578 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51579 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51580 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51581 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51582 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51583 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51586 +4 4 4 4 4 4
51587 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51588 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51589 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51590 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51591 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51592 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51593 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51594 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51595 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51596 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51597 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51600 +4 4 4 4 4 4
51601 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51602 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51603 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51604 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51605 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51606 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51607 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51608 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51609 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51610 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51611 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51614 +4 4 4 4 4 4
51615 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51616 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51617 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51618 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51619 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51620 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51621 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51622 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51623 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51624 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51625 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51628 +4 4 4 4 4 4
51629 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51630 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51631 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51632 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51633 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51634 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51635 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51636 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51637 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51638 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51639 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51642 +4 4 4 4 4 4
51643 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51644 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51645 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51646 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51647 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51648 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51649 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51650 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51651 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51652 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51653 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51656 +4 4 4 4 4 4
51657 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51658 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51659 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51660 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51661 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51662 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51663 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51664 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51665 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51666 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51667 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51670 +4 4 4 4 4 4
51671 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51672 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51673 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51674 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51675 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51676 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51677 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51678 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51679 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51680 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51681 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51684 +4 4 4 4 4 4
51685 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51686 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51687 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51688 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51689 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51690 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51691 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51692 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51693 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51694 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51695 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51698 +4 4 4 4 4 4
51699 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51700 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51701 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51702 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51703 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51704 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51705 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51706 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51707 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51708 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51709 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51712 +4 4 4 4 4 4
51713 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51714 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51715 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51716 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51717 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51718 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51719 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51720 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51721 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51722 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51723 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51726 +4 4 4 4 4 4
51727 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51728 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51729 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51730 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51731 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51732 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51733 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51734 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51735 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51736 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51737 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51740 +4 4 4 4 4 4
51741 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51742 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51743 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51744 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51745 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51746 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51747 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51748 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51749 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51750 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51754 +4 4 4 4 4 4
51755 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51756 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51757 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51758 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51759 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51760 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51761 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51762 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51763 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51764 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51768 +4 4 4 4 4 4
51769 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51770 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51771 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51772 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51773 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51774 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51775 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51776 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51777 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51778 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51782 +4 4 4 4 4 4
51783 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51784 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51785 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51786 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51787 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51788 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51789 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51790 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51791 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51792 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51796 +4 4 4 4 4 4
51797 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51798 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51799 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51800 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51801 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51802 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51803 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51804 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51805 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51810 +4 4 4 4 4 4
51811 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51812 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51813 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51814 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51815 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51816 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51817 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51818 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51819 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51824 +4 4 4 4 4 4
51825 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51826 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51827 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51828 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51829 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51830 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51831 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51832 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51833 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51838 +4 4 4 4 4 4
51839 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51840 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51841 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51842 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51843 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51844 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51845 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51846 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51852 +4 4 4 4 4 4
51853 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51854 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51855 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51856 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51857 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51858 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51859 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51860 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51866 +4 4 4 4 4 4
51867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51868 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51869 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51870 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51871 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51872 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51873 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51874 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51880 +4 4 4 4 4 4
51881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51882 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51883 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51884 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51885 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51886 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51887 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51888 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51894 +4 4 4 4 4 4
51895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51896 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51897 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51898 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51899 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51900 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51901 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51902 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51908 +4 4 4 4 4 4
51909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51911 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51912 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51913 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51914 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51915 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51916 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51922 +4 4 4 4 4 4
51923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51926 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51927 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51928 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51929 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51936 +4 4 4 4 4 4
51937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51940 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51941 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51942 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51943 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51950 +4 4 4 4 4 4
51951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51954 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51955 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51956 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51957 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51964 +4 4 4 4 4 4
51965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51968 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51969 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51970 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51971 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51978 +4 4 4 4 4 4
51979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51983 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51984 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51985 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51992 +4 4 4 4 4 4
51993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51997 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51998 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51999 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52006 +4 4 4 4 4 4
52007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52011 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52012 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52013 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52020 +4 4 4 4 4 4
52021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52025 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52026 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52034 +4 4 4 4 4 4
52035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52036 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52037 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52039 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52040 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52048 +4 4 4 4 4 4
52049 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52050 index fe92eed..106e085 100644
52051 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52052 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52053 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52054 struct mb862xxfb_par *par = info->par;
52055
52056 if (info->var.bits_per_pixel == 32) {
52057 - info->fbops->fb_fillrect = cfb_fillrect;
52058 - info->fbops->fb_copyarea = cfb_copyarea;
52059 - info->fbops->fb_imageblit = cfb_imageblit;
52060 + pax_open_kernel();
52061 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52062 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52063 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52064 + pax_close_kernel();
52065 } else {
52066 outreg(disp, GC_L0EM, 3);
52067 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52068 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52069 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52070 + pax_open_kernel();
52071 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52072 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52073 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52074 + pax_close_kernel();
52075 }
52076 outreg(draw, GDC_REG_DRAW_BASE, 0);
52077 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52078 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52079 index ff22871..b129bed 100644
52080 --- a/drivers/video/nvidia/nvidia.c
52081 +++ b/drivers/video/nvidia/nvidia.c
52082 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52083 info->fix.line_length = (info->var.xres_virtual *
52084 info->var.bits_per_pixel) >> 3;
52085 if (info->var.accel_flags) {
52086 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52087 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52088 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52089 - info->fbops->fb_sync = nvidiafb_sync;
52090 + pax_open_kernel();
52091 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52092 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52093 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52094 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52095 + pax_close_kernel();
52096 info->pixmap.scan_align = 4;
52097 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52098 info->flags |= FBINFO_READS_FAST;
52099 NVResetGraphics(info);
52100 } else {
52101 - info->fbops->fb_imageblit = cfb_imageblit;
52102 - info->fbops->fb_fillrect = cfb_fillrect;
52103 - info->fbops->fb_copyarea = cfb_copyarea;
52104 - info->fbops->fb_sync = NULL;
52105 + pax_open_kernel();
52106 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52107 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52108 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52109 + *(void **)&info->fbops->fb_sync = NULL;
52110 + pax_close_kernel();
52111 info->pixmap.scan_align = 1;
52112 info->flags |= FBINFO_HWACCEL_DISABLED;
52113 info->flags &= ~FBINFO_READS_FAST;
52114 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52115 info->pixmap.size = 8 * 1024;
52116 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52117
52118 - if (!hwcur)
52119 - info->fbops->fb_cursor = NULL;
52120 + if (!hwcur) {
52121 + pax_open_kernel();
52122 + *(void **)&info->fbops->fb_cursor = NULL;
52123 + pax_close_kernel();
52124 + }
52125
52126 info->var.accel_flags = (!noaccel);
52127
52128 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52129 index 05c2dc3..ea1f391 100644
52130 --- a/drivers/video/s1d13xxxfb.c
52131 +++ b/drivers/video/s1d13xxxfb.c
52132 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52133
52134 switch(prod_id) {
52135 case S1D13506_PROD_ID: /* activate acceleration */
52136 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52137 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52138 + pax_open_kernel();
52139 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52140 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52141 + pax_close_kernel();
52142 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52143 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52144 break;
52145 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52146 index e188ada..aac63c8 100644
52147 --- a/drivers/video/smscufx.c
52148 +++ b/drivers/video/smscufx.c
52149 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52150 fb_deferred_io_cleanup(info);
52151 kfree(info->fbdefio);
52152 info->fbdefio = NULL;
52153 - info->fbops->fb_mmap = ufx_ops_mmap;
52154 + pax_open_kernel();
52155 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52156 + pax_close_kernel();
52157 }
52158
52159 pr_debug("released /dev/fb%d user=%d count=%d",
52160 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52161 index d2e5bc3..4cb05d1 100644
52162 --- a/drivers/video/udlfb.c
52163 +++ b/drivers/video/udlfb.c
52164 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52165 dlfb_urb_completion(urb);
52166
52167 error:
52168 - atomic_add(bytes_sent, &dev->bytes_sent);
52169 - atomic_add(bytes_identical, &dev->bytes_identical);
52170 - atomic_add(width*height*2, &dev->bytes_rendered);
52171 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52172 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52173 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52174 end_cycles = get_cycles();
52175 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52176 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52177 >> 10)), /* Kcycles */
52178 &dev->cpu_kcycles_used);
52179
52180 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52181 dlfb_urb_completion(urb);
52182
52183 error:
52184 - atomic_add(bytes_sent, &dev->bytes_sent);
52185 - atomic_add(bytes_identical, &dev->bytes_identical);
52186 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52187 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52188 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52189 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52190 end_cycles = get_cycles();
52191 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52192 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52193 >> 10)), /* Kcycles */
52194 &dev->cpu_kcycles_used);
52195 }
52196 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52197 fb_deferred_io_cleanup(info);
52198 kfree(info->fbdefio);
52199 info->fbdefio = NULL;
52200 - info->fbops->fb_mmap = dlfb_ops_mmap;
52201 + pax_open_kernel();
52202 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52203 + pax_close_kernel();
52204 }
52205
52206 pr_warn("released /dev/fb%d user=%d count=%d\n",
52207 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52208 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52209 struct dlfb_data *dev = fb_info->par;
52210 return snprintf(buf, PAGE_SIZE, "%u\n",
52211 - atomic_read(&dev->bytes_rendered));
52212 + atomic_read_unchecked(&dev->bytes_rendered));
52213 }
52214
52215 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52216 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52217 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52218 struct dlfb_data *dev = fb_info->par;
52219 return snprintf(buf, PAGE_SIZE, "%u\n",
52220 - atomic_read(&dev->bytes_identical));
52221 + atomic_read_unchecked(&dev->bytes_identical));
52222 }
52223
52224 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52225 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52226 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52227 struct dlfb_data *dev = fb_info->par;
52228 return snprintf(buf, PAGE_SIZE, "%u\n",
52229 - atomic_read(&dev->bytes_sent));
52230 + atomic_read_unchecked(&dev->bytes_sent));
52231 }
52232
52233 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52234 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52235 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52236 struct dlfb_data *dev = fb_info->par;
52237 return snprintf(buf, PAGE_SIZE, "%u\n",
52238 - atomic_read(&dev->cpu_kcycles_used));
52239 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52240 }
52241
52242 static ssize_t edid_show(
52243 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52244 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52245 struct dlfb_data *dev = fb_info->par;
52246
52247 - atomic_set(&dev->bytes_rendered, 0);
52248 - atomic_set(&dev->bytes_identical, 0);
52249 - atomic_set(&dev->bytes_sent, 0);
52250 - atomic_set(&dev->cpu_kcycles_used, 0);
52251 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52252 + atomic_set_unchecked(&dev->bytes_identical, 0);
52253 + atomic_set_unchecked(&dev->bytes_sent, 0);
52254 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52255
52256 return count;
52257 }
52258 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
52259 index 7aec6f3..e3b2d55 100644
52260 --- a/drivers/video/uvesafb.c
52261 +++ b/drivers/video/uvesafb.c
52262 @@ -19,6 +19,7 @@
52263 #include <linux/io.h>
52264 #include <linux/mutex.h>
52265 #include <linux/slab.h>
52266 +#include <linux/moduleloader.h>
52267 #include <video/edid.h>
52268 #include <video/uvesafb.h>
52269 #ifdef CONFIG_X86
52270 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52271 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52272 par->pmi_setpal = par->ypan = 0;
52273 } else {
52274 +
52275 +#ifdef CONFIG_PAX_KERNEXEC
52276 +#ifdef CONFIG_MODULES
52277 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52278 +#endif
52279 + if (!par->pmi_code) {
52280 + par->pmi_setpal = par->ypan = 0;
52281 + return 0;
52282 + }
52283 +#endif
52284 +
52285 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52286 + task->t.regs.edi);
52287 +
52288 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52289 + pax_open_kernel();
52290 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52291 + pax_close_kernel();
52292 +
52293 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52294 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52295 +#else
52296 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52297 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52298 +#endif
52299 +
52300 printk(KERN_INFO "uvesafb: protected mode interface info at "
52301 "%04x:%04x\n",
52302 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52303 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52304 par->ypan = ypan;
52305
52306 if (par->pmi_setpal || par->ypan) {
52307 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52308 if (__supported_pte_mask & _PAGE_NX) {
52309 par->pmi_setpal = par->ypan = 0;
52310 printk(KERN_WARNING "uvesafb: NX protection is active, "
52311 "better not use the PMI.\n");
52312 - } else {
52313 + } else
52314 +#endif
52315 uvesafb_vbe_getpmi(task, par);
52316 - }
52317 }
52318 #else
52319 /* The protected mode interface is not available on non-x86. */
52320 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52321 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52322
52323 /* Disable blanking if the user requested so. */
52324 - if (!blank)
52325 - info->fbops->fb_blank = NULL;
52326 + if (!blank) {
52327 + pax_open_kernel();
52328 + *(void **)&info->fbops->fb_blank = NULL;
52329 + pax_close_kernel();
52330 + }
52331
52332 /*
52333 * Find out how much IO memory is required for the mode with
52334 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52335 info->flags = FBINFO_FLAG_DEFAULT |
52336 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52337
52338 - if (!par->ypan)
52339 - info->fbops->fb_pan_display = NULL;
52340 + if (!par->ypan) {
52341 + pax_open_kernel();
52342 + *(void **)&info->fbops->fb_pan_display = NULL;
52343 + pax_close_kernel();
52344 + }
52345 }
52346
52347 static void uvesafb_init_mtrr(struct fb_info *info)
52348 @@ -1796,6 +1826,11 @@ out:
52349 if (par->vbe_modes)
52350 kfree(par->vbe_modes);
52351
52352 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52353 + if (par->pmi_code)
52354 + module_free_exec(NULL, par->pmi_code);
52355 +#endif
52356 +
52357 framebuffer_release(info);
52358 return err;
52359 }
52360 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
52361 kfree(par->vbe_state_orig);
52362 if (par->vbe_state_saved)
52363 kfree(par->vbe_state_saved);
52364 +
52365 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52366 + if (par->pmi_code)
52367 + module_free_exec(NULL, par->pmi_code);
52368 +#endif
52369 +
52370 }
52371
52372 framebuffer_release(info);
52373 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52374 index bd83233..7d8a5aa 100644
52375 --- a/drivers/video/vesafb.c
52376 +++ b/drivers/video/vesafb.c
52377 @@ -9,6 +9,7 @@
52378 */
52379
52380 #include <linux/module.h>
52381 +#include <linux/moduleloader.h>
52382 #include <linux/kernel.h>
52383 #include <linux/errno.h>
52384 #include <linux/string.h>
52385 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
52386 static int vram_total; /* Set total amount of memory */
52387 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52388 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52389 -static void (*pmi_start)(void) __read_mostly;
52390 -static void (*pmi_pal) (void) __read_mostly;
52391 +static void (*pmi_start)(void) __read_only;
52392 +static void (*pmi_pal) (void) __read_only;
52393 static int depth __read_mostly;
52394 static int vga_compat __read_mostly;
52395 /* --------------------------------------------------------------------- */
52396 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
52397 unsigned int size_remap;
52398 unsigned int size_total;
52399 char *option = NULL;
52400 + void *pmi_code = NULL;
52401
52402 /* ignore error return of fb_get_options */
52403 fb_get_options("vesafb", &option);
52404 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
52405 size_remap = size_total;
52406 vesafb_fix.smem_len = size_remap;
52407
52408 -#ifndef __i386__
52409 - screen_info.vesapm_seg = 0;
52410 -#endif
52411 -
52412 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52413 printk(KERN_WARNING
52414 "vesafb: cannot reserve video memory at 0x%lx\n",
52415 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
52416 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52417 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52418
52419 +#ifdef __i386__
52420 +
52421 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52422 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52423 + if (!pmi_code)
52424 +#elif !defined(CONFIG_PAX_KERNEXEC)
52425 + if (0)
52426 +#endif
52427 +
52428 +#endif
52429 + screen_info.vesapm_seg = 0;
52430 +
52431 if (screen_info.vesapm_seg) {
52432 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52433 - screen_info.vesapm_seg,screen_info.vesapm_off);
52434 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52435 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52436 }
52437
52438 if (screen_info.vesapm_seg < 0xc000)
52439 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
52440
52441 if (ypan || pmi_setpal) {
52442 unsigned short *pmi_base;
52443 +
52444 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52445 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52446 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52447 +
52448 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52449 + pax_open_kernel();
52450 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52451 +#else
52452 + pmi_code = pmi_base;
52453 +#endif
52454 +
52455 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52456 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52457 +
52458 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52459 + pmi_start = ktva_ktla(pmi_start);
52460 + pmi_pal = ktva_ktla(pmi_pal);
52461 + pax_close_kernel();
52462 +#endif
52463 +
52464 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52465 if (pmi_base[3]) {
52466 printk(KERN_INFO "vesafb: pmi: ports = ");
52467 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
52468 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52469 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52470
52471 - if (!ypan)
52472 - info->fbops->fb_pan_display = NULL;
52473 + if (!ypan) {
52474 + pax_open_kernel();
52475 + *(void **)&info->fbops->fb_pan_display = NULL;
52476 + pax_close_kernel();
52477 + }
52478
52479 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52480 err = -ENOMEM;
52481 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
52482 info->node, info->fix.id);
52483 return 0;
52484 err:
52485 +
52486 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52487 + module_free_exec(NULL, pmi_code);
52488 +#endif
52489 +
52490 if (info->screen_base)
52491 iounmap(info->screen_base);
52492 framebuffer_release(info);
52493 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52494 index 88714ae..16c2e11 100644
52495 --- a/drivers/video/via/via_clock.h
52496 +++ b/drivers/video/via/via_clock.h
52497 @@ -56,7 +56,7 @@ struct via_clock {
52498
52499 void (*set_engine_pll_state)(u8 state);
52500 void (*set_engine_pll)(struct via_pll_config config);
52501 -};
52502 +} __no_const;
52503
52504
52505 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52506 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52507 index fef20db..d28b1ab 100644
52508 --- a/drivers/xen/xenfs/xenstored.c
52509 +++ b/drivers/xen/xenfs/xenstored.c
52510 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52511 static int xsd_kva_open(struct inode *inode, struct file *file)
52512 {
52513 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52514 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52515 + NULL);
52516 +#else
52517 xen_store_interface);
52518 +#endif
52519 +
52520 if (!file->private_data)
52521 return -ENOMEM;
52522 return 0;
52523 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52524 index 9ff073f..05cef23 100644
52525 --- a/fs/9p/vfs_addr.c
52526 +++ b/fs/9p/vfs_addr.c
52527 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52528
52529 retval = v9fs_file_write_internal(inode,
52530 v9inode->writeback_fid,
52531 - (__force const char __user *)buffer,
52532 + (const char __force_user *)buffer,
52533 len, &offset, 0);
52534 if (retval > 0)
52535 retval = 0;
52536 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52537 index 94de6d1..8d81256 100644
52538 --- a/fs/9p/vfs_inode.c
52539 +++ b/fs/9p/vfs_inode.c
52540 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52541 void
52542 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52543 {
52544 - char *s = nd_get_link(nd);
52545 + const char *s = nd_get_link(nd);
52546
52547 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52548 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52549 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52550 index 370b24c..ff0be7b 100644
52551 --- a/fs/Kconfig.binfmt
52552 +++ b/fs/Kconfig.binfmt
52553 @@ -103,7 +103,7 @@ config HAVE_AOUT
52554
52555 config BINFMT_AOUT
52556 tristate "Kernel support for a.out and ECOFF binaries"
52557 - depends on HAVE_AOUT
52558 + depends on HAVE_AOUT && BROKEN
52559 ---help---
52560 A.out (Assembler.OUTput) is a set of formats for libraries and
52561 executables used in the earliest versions of UNIX. Linux used
52562 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52563 index 789bc25..fafaeea 100644
52564 --- a/fs/afs/inode.c
52565 +++ b/fs/afs/inode.c
52566 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52567 struct afs_vnode *vnode;
52568 struct super_block *sb;
52569 struct inode *inode;
52570 - static atomic_t afs_autocell_ino;
52571 + static atomic_unchecked_t afs_autocell_ino;
52572
52573 _enter("{%x:%u},%*.*s,",
52574 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52575 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52576 data.fid.unique = 0;
52577 data.fid.vnode = 0;
52578
52579 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52580 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52581 afs_iget5_autocell_test, afs_iget5_set,
52582 &data);
52583 if (!inode) {
52584 diff --git a/fs/aio.c b/fs/aio.c
52585 index 067e3d3..634a850 100644
52586 --- a/fs/aio.c
52587 +++ b/fs/aio.c
52588 @@ -280,7 +280,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52589 size += sizeof(struct io_event) * nr_events;
52590
52591 nr_pages = PFN_UP(size);
52592 - if (nr_pages < 0)
52593 + if (nr_pages <= 0)
52594 return -EINVAL;
52595
52596 file = anon_inode_getfile_private("[aio]", &aio_ring_fops, ctx, O_RDWR);
52597 diff --git a/fs/attr.c b/fs/attr.c
52598 index 1449adb..a2038c2 100644
52599 --- a/fs/attr.c
52600 +++ b/fs/attr.c
52601 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52602 unsigned long limit;
52603
52604 limit = rlimit(RLIMIT_FSIZE);
52605 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52606 if (limit != RLIM_INFINITY && offset > limit)
52607 goto out_sig;
52608 if (offset > inode->i_sb->s_maxbytes)
52609 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52610 index 689e40d..515cac5 100644
52611 --- a/fs/autofs4/waitq.c
52612 +++ b/fs/autofs4/waitq.c
52613 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52614 {
52615 unsigned long sigpipe, flags;
52616 mm_segment_t fs;
52617 - const char *data = (const char *)addr;
52618 + const char __user *data = (const char __force_user *)addr;
52619 ssize_t wr = 0;
52620
52621 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52622 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52623 return 1;
52624 }
52625
52626 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52627 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52628 +#endif
52629 +
52630 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52631 enum autofs_notify notify)
52632 {
52633 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52634
52635 /* If this is a direct mount request create a dummy name */
52636 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52637 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52638 + /* this name does get written to userland via autofs4_write() */
52639 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52640 +#else
52641 qstr.len = sprintf(name, "%p", dentry);
52642 +#endif
52643 else {
52644 qstr.len = autofs4_getpath(sbi, dentry, &name);
52645 if (!qstr.len) {
52646 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52647 index 2722387..56059b5 100644
52648 --- a/fs/befs/endian.h
52649 +++ b/fs/befs/endian.h
52650 @@ -11,7 +11,7 @@
52651
52652 #include <asm/byteorder.h>
52653
52654 -static inline u64
52655 +static inline u64 __intentional_overflow(-1)
52656 fs64_to_cpu(const struct super_block *sb, fs64 n)
52657 {
52658 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52659 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52660 return (__force fs64)cpu_to_be64(n);
52661 }
52662
52663 -static inline u32
52664 +static inline u32 __intentional_overflow(-1)
52665 fs32_to_cpu(const struct super_block *sb, fs32 n)
52666 {
52667 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52668 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
52669 return (__force fs32)cpu_to_be32(n);
52670 }
52671
52672 -static inline u16
52673 +static inline u16 __intentional_overflow(-1)
52674 fs16_to_cpu(const struct super_block *sb, fs16 n)
52675 {
52676 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52677 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52678 index e9c75e2..1baece1 100644
52679 --- a/fs/befs/linuxvfs.c
52680 +++ b/fs/befs/linuxvfs.c
52681 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52682 {
52683 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52684 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52685 - char *link = nd_get_link(nd);
52686 + const char *link = nd_get_link(nd);
52687 if (!IS_ERR(link))
52688 kfree(link);
52689 }
52690 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52691 index 89dec7f..361b0d75 100644
52692 --- a/fs/binfmt_aout.c
52693 +++ b/fs/binfmt_aout.c
52694 @@ -16,6 +16,7 @@
52695 #include <linux/string.h>
52696 #include <linux/fs.h>
52697 #include <linux/file.h>
52698 +#include <linux/security.h>
52699 #include <linux/stat.h>
52700 #include <linux/fcntl.h>
52701 #include <linux/ptrace.h>
52702 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52703 #endif
52704 # define START_STACK(u) ((void __user *)u.start_stack)
52705
52706 + memset(&dump, 0, sizeof(dump));
52707 +
52708 fs = get_fs();
52709 set_fs(KERNEL_DS);
52710 has_dumped = 1;
52711 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52712
52713 /* If the size of the dump file exceeds the rlimit, then see what would happen
52714 if we wrote the stack, but not the data area. */
52715 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52716 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52717 dump.u_dsize = 0;
52718
52719 /* Make sure we have enough room to write the stack and data areas. */
52720 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52721 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52722 dump.u_ssize = 0;
52723
52724 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52725 rlim = rlimit(RLIMIT_DATA);
52726 if (rlim >= RLIM_INFINITY)
52727 rlim = ~0;
52728 +
52729 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52730 if (ex.a_data + ex.a_bss > rlim)
52731 return -ENOMEM;
52732
52733 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52734
52735 install_exec_creds(bprm);
52736
52737 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52738 + current->mm->pax_flags = 0UL;
52739 +#endif
52740 +
52741 +#ifdef CONFIG_PAX_PAGEEXEC
52742 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52743 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52744 +
52745 +#ifdef CONFIG_PAX_EMUTRAMP
52746 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52747 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52748 +#endif
52749 +
52750 +#ifdef CONFIG_PAX_MPROTECT
52751 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52752 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52753 +#endif
52754 +
52755 + }
52756 +#endif
52757 +
52758 if (N_MAGIC(ex) == OMAGIC) {
52759 unsigned long text_addr, map_size;
52760 loff_t pos;
52761 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52762 }
52763
52764 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52765 - PROT_READ | PROT_WRITE | PROT_EXEC,
52766 + PROT_READ | PROT_WRITE,
52767 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52768 fd_offset + ex.a_text);
52769 if (error != N_DATADDR(ex)) {
52770 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52771 index 4c94a79..f428019 100644
52772 --- a/fs/binfmt_elf.c
52773 +++ b/fs/binfmt_elf.c
52774 @@ -34,6 +34,7 @@
52775 #include <linux/utsname.h>
52776 #include <linux/coredump.h>
52777 #include <linux/sched.h>
52778 +#include <linux/xattr.h>
52779 #include <asm/uaccess.h>
52780 #include <asm/param.h>
52781 #include <asm/page.h>
52782 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52783 #define elf_core_dump NULL
52784 #endif
52785
52786 +#ifdef CONFIG_PAX_MPROTECT
52787 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52788 +#endif
52789 +
52790 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52791 +static void elf_handle_mmap(struct file *file);
52792 +#endif
52793 +
52794 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52795 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52796 #else
52797 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52798 .load_binary = load_elf_binary,
52799 .load_shlib = load_elf_library,
52800 .core_dump = elf_core_dump,
52801 +
52802 +#ifdef CONFIG_PAX_MPROTECT
52803 + .handle_mprotect= elf_handle_mprotect,
52804 +#endif
52805 +
52806 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52807 + .handle_mmap = elf_handle_mmap,
52808 +#endif
52809 +
52810 .min_coredump = ELF_EXEC_PAGESIZE,
52811 };
52812
52813 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52814
52815 static int set_brk(unsigned long start, unsigned long end)
52816 {
52817 + unsigned long e = end;
52818 +
52819 start = ELF_PAGEALIGN(start);
52820 end = ELF_PAGEALIGN(end);
52821 if (end > start) {
52822 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52823 if (BAD_ADDR(addr))
52824 return addr;
52825 }
52826 - current->mm->start_brk = current->mm->brk = end;
52827 + current->mm->start_brk = current->mm->brk = e;
52828 return 0;
52829 }
52830
52831 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52832 elf_addr_t __user *u_rand_bytes;
52833 const char *k_platform = ELF_PLATFORM;
52834 const char *k_base_platform = ELF_BASE_PLATFORM;
52835 - unsigned char k_rand_bytes[16];
52836 + u32 k_rand_bytes[4];
52837 int items;
52838 elf_addr_t *elf_info;
52839 int ei_index = 0;
52840 const struct cred *cred = current_cred();
52841 struct vm_area_struct *vma;
52842 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52843
52844 /*
52845 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52846 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52847 * Generate 16 random bytes for userspace PRNG seeding.
52848 */
52849 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52850 - u_rand_bytes = (elf_addr_t __user *)
52851 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52852 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52853 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52854 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52855 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52856 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52857 + u_rand_bytes = (elf_addr_t __user *) p;
52858 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52859 return -EFAULT;
52860
52861 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52862 return -EFAULT;
52863 current->mm->env_end = p;
52864
52865 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52866 +
52867 /* Put the elf_info on the stack in the right place. */
52868 sp = (elf_addr_t __user *)envp + 1;
52869 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52870 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52871 return -EFAULT;
52872 return 0;
52873 }
52874 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52875 an ELF header */
52876
52877 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52878 - struct file *interpreter, unsigned long *interp_map_addr,
52879 - unsigned long no_base)
52880 + struct file *interpreter, unsigned long no_base)
52881 {
52882 struct elf_phdr *elf_phdata;
52883 struct elf_phdr *eppnt;
52884 - unsigned long load_addr = 0;
52885 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52886 int load_addr_set = 0;
52887 unsigned long last_bss = 0, elf_bss = 0;
52888 - unsigned long error = ~0UL;
52889 + unsigned long error = -EINVAL;
52890 unsigned long total_size;
52891 int retval, i, size;
52892
52893 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52894 goto out_close;
52895 }
52896
52897 +#ifdef CONFIG_PAX_SEGMEXEC
52898 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52899 + pax_task_size = SEGMEXEC_TASK_SIZE;
52900 +#endif
52901 +
52902 eppnt = elf_phdata;
52903 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52904 if (eppnt->p_type == PT_LOAD) {
52905 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52906 map_addr = elf_map(interpreter, load_addr + vaddr,
52907 eppnt, elf_prot, elf_type, total_size);
52908 total_size = 0;
52909 - if (!*interp_map_addr)
52910 - *interp_map_addr = map_addr;
52911 error = map_addr;
52912 if (BAD_ADDR(map_addr))
52913 goto out_close;
52914 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52915 k = load_addr + eppnt->p_vaddr;
52916 if (BAD_ADDR(k) ||
52917 eppnt->p_filesz > eppnt->p_memsz ||
52918 - eppnt->p_memsz > TASK_SIZE ||
52919 - TASK_SIZE - eppnt->p_memsz < k) {
52920 + eppnt->p_memsz > pax_task_size ||
52921 + pax_task_size - eppnt->p_memsz < k) {
52922 error = -ENOMEM;
52923 goto out_close;
52924 }
52925 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52926 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52927
52928 /* Map the last of the bss segment */
52929 - error = vm_brk(elf_bss, last_bss - elf_bss);
52930 - if (BAD_ADDR(error))
52931 - goto out_close;
52932 + if (last_bss > elf_bss) {
52933 + error = vm_brk(elf_bss, last_bss - elf_bss);
52934 + if (BAD_ADDR(error))
52935 + goto out_close;
52936 + }
52937 }
52938
52939 error = load_addr;
52940 @@ -538,6 +569,315 @@ out:
52941 return error;
52942 }
52943
52944 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52945 +#ifdef CONFIG_PAX_SOFTMODE
52946 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52947 +{
52948 + unsigned long pax_flags = 0UL;
52949 +
52950 +#ifdef CONFIG_PAX_PAGEEXEC
52951 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52952 + pax_flags |= MF_PAX_PAGEEXEC;
52953 +#endif
52954 +
52955 +#ifdef CONFIG_PAX_SEGMEXEC
52956 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52957 + pax_flags |= MF_PAX_SEGMEXEC;
52958 +#endif
52959 +
52960 +#ifdef CONFIG_PAX_EMUTRAMP
52961 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52962 + pax_flags |= MF_PAX_EMUTRAMP;
52963 +#endif
52964 +
52965 +#ifdef CONFIG_PAX_MPROTECT
52966 + if (elf_phdata->p_flags & PF_MPROTECT)
52967 + pax_flags |= MF_PAX_MPROTECT;
52968 +#endif
52969 +
52970 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52971 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52972 + pax_flags |= MF_PAX_RANDMMAP;
52973 +#endif
52974 +
52975 + return pax_flags;
52976 +}
52977 +#endif
52978 +
52979 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52980 +{
52981 + unsigned long pax_flags = 0UL;
52982 +
52983 +#ifdef CONFIG_PAX_PAGEEXEC
52984 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52985 + pax_flags |= MF_PAX_PAGEEXEC;
52986 +#endif
52987 +
52988 +#ifdef CONFIG_PAX_SEGMEXEC
52989 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52990 + pax_flags |= MF_PAX_SEGMEXEC;
52991 +#endif
52992 +
52993 +#ifdef CONFIG_PAX_EMUTRAMP
52994 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52995 + pax_flags |= MF_PAX_EMUTRAMP;
52996 +#endif
52997 +
52998 +#ifdef CONFIG_PAX_MPROTECT
52999 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53000 + pax_flags |= MF_PAX_MPROTECT;
53001 +#endif
53002 +
53003 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53004 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53005 + pax_flags |= MF_PAX_RANDMMAP;
53006 +#endif
53007 +
53008 + return pax_flags;
53009 +}
53010 +#endif
53011 +
53012 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53013 +#ifdef CONFIG_PAX_SOFTMODE
53014 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53015 +{
53016 + unsigned long pax_flags = 0UL;
53017 +
53018 +#ifdef CONFIG_PAX_PAGEEXEC
53019 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53020 + pax_flags |= MF_PAX_PAGEEXEC;
53021 +#endif
53022 +
53023 +#ifdef CONFIG_PAX_SEGMEXEC
53024 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53025 + pax_flags |= MF_PAX_SEGMEXEC;
53026 +#endif
53027 +
53028 +#ifdef CONFIG_PAX_EMUTRAMP
53029 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53030 + pax_flags |= MF_PAX_EMUTRAMP;
53031 +#endif
53032 +
53033 +#ifdef CONFIG_PAX_MPROTECT
53034 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53035 + pax_flags |= MF_PAX_MPROTECT;
53036 +#endif
53037 +
53038 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53039 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53040 + pax_flags |= MF_PAX_RANDMMAP;
53041 +#endif
53042 +
53043 + return pax_flags;
53044 +}
53045 +#endif
53046 +
53047 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53048 +{
53049 + unsigned long pax_flags = 0UL;
53050 +
53051 +#ifdef CONFIG_PAX_PAGEEXEC
53052 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53053 + pax_flags |= MF_PAX_PAGEEXEC;
53054 +#endif
53055 +
53056 +#ifdef CONFIG_PAX_SEGMEXEC
53057 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53058 + pax_flags |= MF_PAX_SEGMEXEC;
53059 +#endif
53060 +
53061 +#ifdef CONFIG_PAX_EMUTRAMP
53062 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53063 + pax_flags |= MF_PAX_EMUTRAMP;
53064 +#endif
53065 +
53066 +#ifdef CONFIG_PAX_MPROTECT
53067 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53068 + pax_flags |= MF_PAX_MPROTECT;
53069 +#endif
53070 +
53071 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53072 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53073 + pax_flags |= MF_PAX_RANDMMAP;
53074 +#endif
53075 +
53076 + return pax_flags;
53077 +}
53078 +#endif
53079 +
53080 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53081 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53082 +{
53083 + unsigned long pax_flags = 0UL;
53084 +
53085 +#ifdef CONFIG_PAX_EI_PAX
53086 +
53087 +#ifdef CONFIG_PAX_PAGEEXEC
53088 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53089 + pax_flags |= MF_PAX_PAGEEXEC;
53090 +#endif
53091 +
53092 +#ifdef CONFIG_PAX_SEGMEXEC
53093 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53094 + pax_flags |= MF_PAX_SEGMEXEC;
53095 +#endif
53096 +
53097 +#ifdef CONFIG_PAX_EMUTRAMP
53098 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53099 + pax_flags |= MF_PAX_EMUTRAMP;
53100 +#endif
53101 +
53102 +#ifdef CONFIG_PAX_MPROTECT
53103 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53104 + pax_flags |= MF_PAX_MPROTECT;
53105 +#endif
53106 +
53107 +#ifdef CONFIG_PAX_ASLR
53108 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53109 + pax_flags |= MF_PAX_RANDMMAP;
53110 +#endif
53111 +
53112 +#else
53113 +
53114 +#ifdef CONFIG_PAX_PAGEEXEC
53115 + pax_flags |= MF_PAX_PAGEEXEC;
53116 +#endif
53117 +
53118 +#ifdef CONFIG_PAX_SEGMEXEC
53119 + pax_flags |= MF_PAX_SEGMEXEC;
53120 +#endif
53121 +
53122 +#ifdef CONFIG_PAX_MPROTECT
53123 + pax_flags |= MF_PAX_MPROTECT;
53124 +#endif
53125 +
53126 +#ifdef CONFIG_PAX_RANDMMAP
53127 + if (randomize_va_space)
53128 + pax_flags |= MF_PAX_RANDMMAP;
53129 +#endif
53130 +
53131 +#endif
53132 +
53133 + return pax_flags;
53134 +}
53135 +
53136 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53137 +{
53138 +
53139 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53140 + unsigned long i;
53141 +
53142 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53143 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53144 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53145 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53146 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53147 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53148 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53149 + return ~0UL;
53150 +
53151 +#ifdef CONFIG_PAX_SOFTMODE
53152 + if (pax_softmode)
53153 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53154 + else
53155 +#endif
53156 +
53157 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53158 + break;
53159 + }
53160 +#endif
53161 +
53162 + return ~0UL;
53163 +}
53164 +
53165 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53166 +{
53167 +
53168 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53169 + ssize_t xattr_size, i;
53170 + unsigned char xattr_value[sizeof("pemrs") - 1];
53171 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53172 +
53173 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53174 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
53175 + return ~0UL;
53176 +
53177 + for (i = 0; i < xattr_size; i++)
53178 + switch (xattr_value[i]) {
53179 + default:
53180 + return ~0UL;
53181 +
53182 +#define parse_flag(option1, option2, flag) \
53183 + case option1: \
53184 + if (pax_flags_hardmode & MF_PAX_##flag) \
53185 + return ~0UL; \
53186 + pax_flags_hardmode |= MF_PAX_##flag; \
53187 + break; \
53188 + case option2: \
53189 + if (pax_flags_softmode & MF_PAX_##flag) \
53190 + return ~0UL; \
53191 + pax_flags_softmode |= MF_PAX_##flag; \
53192 + break;
53193 +
53194 + parse_flag('p', 'P', PAGEEXEC);
53195 + parse_flag('e', 'E', EMUTRAMP);
53196 + parse_flag('m', 'M', MPROTECT);
53197 + parse_flag('r', 'R', RANDMMAP);
53198 + parse_flag('s', 'S', SEGMEXEC);
53199 +
53200 +#undef parse_flag
53201 + }
53202 +
53203 + if (pax_flags_hardmode & pax_flags_softmode)
53204 + return ~0UL;
53205 +
53206 +#ifdef CONFIG_PAX_SOFTMODE
53207 + if (pax_softmode)
53208 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53209 + else
53210 +#endif
53211 +
53212 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53213 +#else
53214 + return ~0UL;
53215 +#endif
53216 +
53217 +}
53218 +
53219 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53220 +{
53221 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53222 +
53223 + pax_flags = pax_parse_ei_pax(elf_ex);
53224 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53225 + xattr_pax_flags = pax_parse_xattr_pax(file);
53226 +
53227 + if (pt_pax_flags == ~0UL)
53228 + pt_pax_flags = xattr_pax_flags;
53229 + else if (xattr_pax_flags == ~0UL)
53230 + xattr_pax_flags = pt_pax_flags;
53231 + if (pt_pax_flags != xattr_pax_flags)
53232 + return -EINVAL;
53233 + if (pt_pax_flags != ~0UL)
53234 + pax_flags = pt_pax_flags;
53235 +
53236 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53237 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53238 + if ((__supported_pte_mask & _PAGE_NX))
53239 + pax_flags &= ~MF_PAX_SEGMEXEC;
53240 + else
53241 + pax_flags &= ~MF_PAX_PAGEEXEC;
53242 + }
53243 +#endif
53244 +
53245 + if (0 > pax_check_flags(&pax_flags))
53246 + return -EINVAL;
53247 +
53248 + current->mm->pax_flags = pax_flags;
53249 + return 0;
53250 +}
53251 +#endif
53252 +
53253 /*
53254 * These are the functions used to load ELF style executables and shared
53255 * libraries. There is no binary dependent code anywhere else.
53256 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
53257 {
53258 unsigned int random_variable = 0;
53259
53260 +#ifdef CONFIG_PAX_RANDUSTACK
53261 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
53262 + return stack_top - current->mm->delta_stack;
53263 +#endif
53264 +
53265 if ((current->flags & PF_RANDOMIZE) &&
53266 !(current->personality & ADDR_NO_RANDOMIZE)) {
53267 random_variable = get_random_int() & STACK_RND_MASK;
53268 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
53269 unsigned long load_addr = 0, load_bias = 0;
53270 int load_addr_set = 0;
53271 char * elf_interpreter = NULL;
53272 - unsigned long error;
53273 + unsigned long error = 0;
53274 struct elf_phdr *elf_ppnt, *elf_phdata;
53275 unsigned long elf_bss, elf_brk;
53276 int retval, i;
53277 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
53278 unsigned long start_code, end_code, start_data, end_data;
53279 unsigned long reloc_func_desc __maybe_unused = 0;
53280 int executable_stack = EXSTACK_DEFAULT;
53281 - unsigned long def_flags = 0;
53282 struct pt_regs *regs = current_pt_regs();
53283 struct {
53284 struct elfhdr elf_ex;
53285 struct elfhdr interp_elf_ex;
53286 } *loc;
53287 + unsigned long pax_task_size = TASK_SIZE;
53288
53289 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
53290 if (!loc) {
53291 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
53292 goto out_free_dentry;
53293
53294 /* OK, This is the point of no return */
53295 - current->mm->def_flags = def_flags;
53296 +
53297 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53298 + current->mm->pax_flags = 0UL;
53299 +#endif
53300 +
53301 +#ifdef CONFIG_PAX_DLRESOLVE
53302 + current->mm->call_dl_resolve = 0UL;
53303 +#endif
53304 +
53305 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
53306 + current->mm->call_syscall = 0UL;
53307 +#endif
53308 +
53309 +#ifdef CONFIG_PAX_ASLR
53310 + current->mm->delta_mmap = 0UL;
53311 + current->mm->delta_stack = 0UL;
53312 +#endif
53313 +
53314 + current->mm->def_flags = 0;
53315 +
53316 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53317 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
53318 + send_sig(SIGKILL, current, 0);
53319 + goto out_free_dentry;
53320 + }
53321 +#endif
53322 +
53323 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
53324 + pax_set_initial_flags(bprm);
53325 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
53326 + if (pax_set_initial_flags_func)
53327 + (pax_set_initial_flags_func)(bprm);
53328 +#endif
53329 +
53330 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
53331 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
53332 + current->mm->context.user_cs_limit = PAGE_SIZE;
53333 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53334 + }
53335 +#endif
53336 +
53337 +#ifdef CONFIG_PAX_SEGMEXEC
53338 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53339 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53340 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53341 + pax_task_size = SEGMEXEC_TASK_SIZE;
53342 + current->mm->def_flags |= VM_NOHUGEPAGE;
53343 + }
53344 +#endif
53345 +
53346 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53347 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53348 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53349 + put_cpu();
53350 + }
53351 +#endif
53352
53353 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53354 may depend on the personality. */
53355 SET_PERSONALITY(loc->elf_ex);
53356 +
53357 +#ifdef CONFIG_PAX_ASLR
53358 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53359 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53360 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53361 + }
53362 +#endif
53363 +
53364 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53365 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53366 + executable_stack = EXSTACK_DISABLE_X;
53367 + current->personality &= ~READ_IMPLIES_EXEC;
53368 + } else
53369 +#endif
53370 +
53371 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53372 current->personality |= READ_IMPLIES_EXEC;
53373
53374 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53375 #else
53376 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53377 #endif
53378 +
53379 +#ifdef CONFIG_PAX_RANDMMAP
53380 + /* PaX: randomize base address at the default exe base if requested */
53381 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53382 +#ifdef CONFIG_SPARC64
53383 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53384 +#else
53385 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53386 +#endif
53387 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53388 + elf_flags |= MAP_FIXED;
53389 + }
53390 +#endif
53391 +
53392 }
53393
53394 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53395 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53396 * allowed task size. Note that p_filesz must always be
53397 * <= p_memsz so it is only necessary to check p_memsz.
53398 */
53399 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53400 - elf_ppnt->p_memsz > TASK_SIZE ||
53401 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53402 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53403 + elf_ppnt->p_memsz > pax_task_size ||
53404 + pax_task_size - elf_ppnt->p_memsz < k) {
53405 /* set_brk can never work. Avoid overflows. */
53406 send_sig(SIGKILL, current, 0);
53407 retval = -EINVAL;
53408 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53409 goto out_free_dentry;
53410 }
53411 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53412 - send_sig(SIGSEGV, current, 0);
53413 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53414 - goto out_free_dentry;
53415 + /*
53416 + * This bss-zeroing can fail if the ELF
53417 + * file specifies odd protections. So
53418 + * we don't check the return value
53419 + */
53420 }
53421
53422 +#ifdef CONFIG_PAX_RANDMMAP
53423 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53424 + unsigned long start, size, flags;
53425 + vm_flags_t vm_flags;
53426 +
53427 + start = ELF_PAGEALIGN(elf_brk);
53428 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53429 + flags = MAP_FIXED | MAP_PRIVATE;
53430 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53431 +
53432 + down_write(&current->mm->mmap_sem);
53433 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53434 + retval = -ENOMEM;
53435 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53436 +// if (current->personality & ADDR_NO_RANDOMIZE)
53437 +// vm_flags |= VM_READ | VM_MAYREAD;
53438 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53439 + retval = IS_ERR_VALUE(start) ? start : 0;
53440 + }
53441 + up_write(&current->mm->mmap_sem);
53442 + if (retval == 0)
53443 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53444 + if (retval < 0) {
53445 + send_sig(SIGKILL, current, 0);
53446 + goto out_free_dentry;
53447 + }
53448 + }
53449 +#endif
53450 +
53451 if (elf_interpreter) {
53452 - unsigned long interp_map_addr = 0;
53453 -
53454 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53455 interpreter,
53456 - &interp_map_addr,
53457 load_bias);
53458 if (!IS_ERR((void *)elf_entry)) {
53459 /*
53460 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53461 * Decide what to dump of a segment, part, all or none.
53462 */
53463 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53464 - unsigned long mm_flags)
53465 + unsigned long mm_flags, long signr)
53466 {
53467 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53468
53469 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53470 if (vma->vm_file == NULL)
53471 return 0;
53472
53473 - if (FILTER(MAPPED_PRIVATE))
53474 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53475 goto whole;
53476
53477 /*
53478 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53479 {
53480 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53481 int i = 0;
53482 - do
53483 + do {
53484 i += 2;
53485 - while (auxv[i - 2] != AT_NULL);
53486 + } while (auxv[i - 2] != AT_NULL);
53487 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53488 }
53489
53490 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53491 {
53492 mm_segment_t old_fs = get_fs();
53493 set_fs(KERNEL_DS);
53494 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53495 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53496 set_fs(old_fs);
53497 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53498 }
53499 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53500 }
53501
53502 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53503 - unsigned long mm_flags)
53504 + struct coredump_params *cprm)
53505 {
53506 struct vm_area_struct *vma;
53507 size_t size = 0;
53508
53509 for (vma = first_vma(current, gate_vma); vma != NULL;
53510 vma = next_vma(vma, gate_vma))
53511 - size += vma_dump_size(vma, mm_flags);
53512 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53513 return size;
53514 }
53515
53516 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53517
53518 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53519
53520 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53521 + offset += elf_core_vma_data_size(gate_vma, cprm);
53522 offset += elf_core_extra_data_size();
53523 e_shoff = offset;
53524
53525 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53526 offset = dataoff;
53527
53528 size += sizeof(*elf);
53529 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53530 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53531 goto end_coredump;
53532
53533 size += sizeof(*phdr4note);
53534 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53535 if (size > cprm->limit
53536 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53537 goto end_coredump;
53538 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53539 phdr.p_offset = offset;
53540 phdr.p_vaddr = vma->vm_start;
53541 phdr.p_paddr = 0;
53542 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53543 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53544 phdr.p_memsz = vma->vm_end - vma->vm_start;
53545 offset += phdr.p_filesz;
53546 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53547 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53548 phdr.p_align = ELF_EXEC_PAGESIZE;
53549
53550 size += sizeof(phdr);
53551 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53552 if (size > cprm->limit
53553 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53554 goto end_coredump;
53555 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53556 unsigned long addr;
53557 unsigned long end;
53558
53559 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53560 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53561
53562 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53563 struct page *page;
53564 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53565 page = get_dump_page(addr);
53566 if (page) {
53567 void *kaddr = kmap(page);
53568 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53569 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53570 !dump_write(cprm->file, kaddr,
53571 PAGE_SIZE);
53572 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53573
53574 if (e_phnum == PN_XNUM) {
53575 size += sizeof(*shdr4extnum);
53576 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53577 if (size > cprm->limit
53578 || !dump_write(cprm->file, shdr4extnum,
53579 sizeof(*shdr4extnum)))
53580 @@ -2235,6 +2697,167 @@ out:
53581
53582 #endif /* CONFIG_ELF_CORE */
53583
53584 +#ifdef CONFIG_PAX_MPROTECT
53585 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53586 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53587 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53588 + *
53589 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53590 + * basis because we want to allow the common case and not the special ones.
53591 + */
53592 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53593 +{
53594 + struct elfhdr elf_h;
53595 + struct elf_phdr elf_p;
53596 + unsigned long i;
53597 + unsigned long oldflags;
53598 + bool is_textrel_rw, is_textrel_rx, is_relro;
53599 +
53600 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53601 + return;
53602 +
53603 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53604 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53605 +
53606 +#ifdef CONFIG_PAX_ELFRELOCS
53607 + /* possible TEXTREL */
53608 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53609 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53610 +#else
53611 + is_textrel_rw = false;
53612 + is_textrel_rx = false;
53613 +#endif
53614 +
53615 + /* possible RELRO */
53616 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53617 +
53618 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53619 + return;
53620 +
53621 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53622 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53623 +
53624 +#ifdef CONFIG_PAX_ETEXECRELOCS
53625 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53626 +#else
53627 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53628 +#endif
53629 +
53630 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53631 + !elf_check_arch(&elf_h) ||
53632 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53633 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53634 + return;
53635 +
53636 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53637 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53638 + return;
53639 + switch (elf_p.p_type) {
53640 + case PT_DYNAMIC:
53641 + if (!is_textrel_rw && !is_textrel_rx)
53642 + continue;
53643 + i = 0UL;
53644 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53645 + elf_dyn dyn;
53646 +
53647 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53648 + break;
53649 + if (dyn.d_tag == DT_NULL)
53650 + break;
53651 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53652 + gr_log_textrel(vma);
53653 + if (is_textrel_rw)
53654 + vma->vm_flags |= VM_MAYWRITE;
53655 + else
53656 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53657 + vma->vm_flags &= ~VM_MAYWRITE;
53658 + break;
53659 + }
53660 + i++;
53661 + }
53662 + is_textrel_rw = false;
53663 + is_textrel_rx = false;
53664 + continue;
53665 +
53666 + case PT_GNU_RELRO:
53667 + if (!is_relro)
53668 + continue;
53669 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53670 + vma->vm_flags &= ~VM_MAYWRITE;
53671 + is_relro = false;
53672 + continue;
53673 +
53674 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53675 + case PT_PAX_FLAGS: {
53676 + const char *msg_mprotect = "", *msg_emutramp = "";
53677 + char *buffer_lib, *buffer_exe;
53678 +
53679 + if (elf_p.p_flags & PF_NOMPROTECT)
53680 + msg_mprotect = "MPROTECT disabled";
53681 +
53682 +#ifdef CONFIG_PAX_EMUTRAMP
53683 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53684 + msg_emutramp = "EMUTRAMP enabled";
53685 +#endif
53686 +
53687 + if (!msg_mprotect[0] && !msg_emutramp[0])
53688 + continue;
53689 +
53690 + if (!printk_ratelimit())
53691 + continue;
53692 +
53693 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53694 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53695 + if (buffer_lib && buffer_exe) {
53696 + char *path_lib, *path_exe;
53697 +
53698 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53699 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53700 +
53701 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53702 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53703 +
53704 + }
53705 + free_page((unsigned long)buffer_exe);
53706 + free_page((unsigned long)buffer_lib);
53707 + continue;
53708 + }
53709 +#endif
53710 +
53711 + }
53712 + }
53713 +}
53714 +#endif
53715 +
53716 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53717 +
53718 +extern int grsec_enable_log_rwxmaps;
53719 +
53720 +static void elf_handle_mmap(struct file *file)
53721 +{
53722 + struct elfhdr elf_h;
53723 + struct elf_phdr elf_p;
53724 + unsigned long i;
53725 +
53726 + if (!grsec_enable_log_rwxmaps)
53727 + return;
53728 +
53729 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53730 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53731 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53732 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53733 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53734 + return;
53735 +
53736 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53737 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53738 + return;
53739 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53740 + gr_log_ptgnustack(file);
53741 + }
53742 +}
53743 +#endif
53744 +
53745 static int __init init_elf_binfmt(void)
53746 {
53747 register_binfmt(&elf_format);
53748 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53749 index d50bbe5..af3b649 100644
53750 --- a/fs/binfmt_flat.c
53751 +++ b/fs/binfmt_flat.c
53752 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53753 realdatastart = (unsigned long) -ENOMEM;
53754 printk("Unable to allocate RAM for process data, errno %d\n",
53755 (int)-realdatastart);
53756 + down_write(&current->mm->mmap_sem);
53757 vm_munmap(textpos, text_len);
53758 + up_write(&current->mm->mmap_sem);
53759 ret = realdatastart;
53760 goto err;
53761 }
53762 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53763 }
53764 if (IS_ERR_VALUE(result)) {
53765 printk("Unable to read data+bss, errno %d\n", (int)-result);
53766 + down_write(&current->mm->mmap_sem);
53767 vm_munmap(textpos, text_len);
53768 vm_munmap(realdatastart, len);
53769 + up_write(&current->mm->mmap_sem);
53770 ret = result;
53771 goto err;
53772 }
53773 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53774 }
53775 if (IS_ERR_VALUE(result)) {
53776 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53777 + down_write(&current->mm->mmap_sem);
53778 vm_munmap(textpos, text_len + data_len + extra +
53779 MAX_SHARED_LIBS * sizeof(unsigned long));
53780 + up_write(&current->mm->mmap_sem);
53781 ret = result;
53782 goto err;
53783 }
53784 diff --git a/fs/bio.c b/fs/bio.c
53785 index ea5035d..a2932eb 100644
53786 --- a/fs/bio.c
53787 +++ b/fs/bio.c
53788 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53789 /*
53790 * Overflow, abort
53791 */
53792 - if (end < start)
53793 + if (end < start || end - start > INT_MAX - nr_pages)
53794 return ERR_PTR(-EINVAL);
53795
53796 nr_pages += end - start;
53797 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53798 /*
53799 * Overflow, abort
53800 */
53801 - if (end < start)
53802 + if (end < start || end - start > INT_MAX - nr_pages)
53803 return ERR_PTR(-EINVAL);
53804
53805 nr_pages += end - start;
53806 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53807 const int read = bio_data_dir(bio) == READ;
53808 struct bio_map_data *bmd = bio->bi_private;
53809 int i;
53810 - char *p = bmd->sgvecs[0].iov_base;
53811 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53812
53813 bio_for_each_segment_all(bvec, bio, i) {
53814 char *addr = page_address(bvec->bv_page);
53815 diff --git a/fs/block_dev.c b/fs/block_dev.c
53816 index 1e86823..8e34695 100644
53817 --- a/fs/block_dev.c
53818 +++ b/fs/block_dev.c
53819 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53820 else if (bdev->bd_contains == bdev)
53821 return true; /* is a whole device which isn't held */
53822
53823 - else if (whole->bd_holder == bd_may_claim)
53824 + else if (whole->bd_holder == (void *)bd_may_claim)
53825 return true; /* is a partition of a device that is being partitioned */
53826 else if (whole->bd_holder != NULL)
53827 return false; /* is a partition of a held device */
53828 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53829 index 61b5bcd..7eeede8 100644
53830 --- a/fs/btrfs/ctree.c
53831 +++ b/fs/btrfs/ctree.c
53832 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53833 free_extent_buffer(buf);
53834 add_root_to_dirty_list(root);
53835 } else {
53836 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53837 - parent_start = parent->start;
53838 - else
53839 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53840 + if (parent)
53841 + parent_start = parent->start;
53842 + else
53843 + parent_start = 0;
53844 + } else
53845 parent_start = 0;
53846
53847 WARN_ON(trans->transid != btrfs_header_generation(parent));
53848 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53849 index cbd9523..5cca781 100644
53850 --- a/fs/btrfs/delayed-inode.c
53851 +++ b/fs/btrfs/delayed-inode.c
53852 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53853
53854 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53855 {
53856 - int seq = atomic_inc_return(&delayed_root->items_seq);
53857 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53858 if ((atomic_dec_return(&delayed_root->items) <
53859 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53860 waitqueue_active(&delayed_root->wait))
53861 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53862 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53863 int seq, int count)
53864 {
53865 - int val = atomic_read(&delayed_root->items_seq);
53866 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53867
53868 if (val < seq || val >= seq + count)
53869 return 1;
53870 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53871 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53872 return;
53873
53874 - seq = atomic_read(&delayed_root->items_seq);
53875 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53876
53877 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53878 int ret;
53879 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53880 index a4b38f9..f86a509 100644
53881 --- a/fs/btrfs/delayed-inode.h
53882 +++ b/fs/btrfs/delayed-inode.h
53883 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53884 */
53885 struct list_head prepare_list;
53886 atomic_t items; /* for delayed items */
53887 - atomic_t items_seq; /* for delayed items */
53888 + atomic_unchecked_t items_seq; /* for delayed items */
53889 int nodes; /* for delayed nodes */
53890 wait_queue_head_t wait;
53891 };
53892 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53893 struct btrfs_delayed_root *delayed_root)
53894 {
53895 atomic_set(&delayed_root->items, 0);
53896 - atomic_set(&delayed_root->items_seq, 0);
53897 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53898 delayed_root->nodes = 0;
53899 spin_lock_init(&delayed_root->lock);
53900 init_waitqueue_head(&delayed_root->wait);
53901 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53902 index 9d46f60..a8f09eb 100644
53903 --- a/fs/btrfs/ioctl.c
53904 +++ b/fs/btrfs/ioctl.c
53905 @@ -3464,9 +3464,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53906 for (i = 0; i < num_types; i++) {
53907 struct btrfs_space_info *tmp;
53908
53909 + /* Don't copy in more than we allocated */
53910 if (!slot_count)
53911 break;
53912
53913 + slot_count--;
53914 +
53915 info = NULL;
53916 rcu_read_lock();
53917 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53918 @@ -3488,10 +3491,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53919 memcpy(dest, &space, sizeof(space));
53920 dest++;
53921 space_args.total_spaces++;
53922 - slot_count--;
53923 }
53924 - if (!slot_count)
53925 - break;
53926 }
53927 up_read(&info->groups_sem);
53928 }
53929 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53930 index e913328..a34fb36 100644
53931 --- a/fs/btrfs/super.c
53932 +++ b/fs/btrfs/super.c
53933 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53934 function, line, errstr);
53935 return;
53936 }
53937 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53938 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53939 /* Wake up anybody who may be waiting on this transaction */
53940 wake_up(&root->fs_info->transaction_wait);
53941 wake_up(&root->fs_info->transaction_blocked_wait);
53942 diff --git a/fs/buffer.c b/fs/buffer.c
53943 index 6024877..7bd000a 100644
53944 --- a/fs/buffer.c
53945 +++ b/fs/buffer.c
53946 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
53947 bh_cachep = kmem_cache_create("buffer_head",
53948 sizeof(struct buffer_head), 0,
53949 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53950 - SLAB_MEM_SPREAD),
53951 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53952 NULL);
53953
53954 /*
53955 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53956 index 622f469..e8d2d55 100644
53957 --- a/fs/cachefiles/bind.c
53958 +++ b/fs/cachefiles/bind.c
53959 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53960 args);
53961
53962 /* start by checking things over */
53963 - ASSERT(cache->fstop_percent >= 0 &&
53964 - cache->fstop_percent < cache->fcull_percent &&
53965 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53966 cache->fcull_percent < cache->frun_percent &&
53967 cache->frun_percent < 100);
53968
53969 - ASSERT(cache->bstop_percent >= 0 &&
53970 - cache->bstop_percent < cache->bcull_percent &&
53971 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53972 cache->bcull_percent < cache->brun_percent &&
53973 cache->brun_percent < 100);
53974
53975 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53976 index 0a1467b..6a53245 100644
53977 --- a/fs/cachefiles/daemon.c
53978 +++ b/fs/cachefiles/daemon.c
53979 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53980 if (n > buflen)
53981 return -EMSGSIZE;
53982
53983 - if (copy_to_user(_buffer, buffer, n) != 0)
53984 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53985 return -EFAULT;
53986
53987 return n;
53988 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53989 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53990 return -EIO;
53991
53992 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53993 + if (datalen > PAGE_SIZE - 1)
53994 return -EOPNOTSUPP;
53995
53996 /* drag the command string into the kernel so we can parse it */
53997 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53998 if (args[0] != '%' || args[1] != '\0')
53999 return -EINVAL;
54000
54001 - if (fstop < 0 || fstop >= cache->fcull_percent)
54002 + if (fstop >= cache->fcull_percent)
54003 return cachefiles_daemon_range_error(cache, args);
54004
54005 cache->fstop_percent = fstop;
54006 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54007 if (args[0] != '%' || args[1] != '\0')
54008 return -EINVAL;
54009
54010 - if (bstop < 0 || bstop >= cache->bcull_percent)
54011 + if (bstop >= cache->bcull_percent)
54012 return cachefiles_daemon_range_error(cache, args);
54013
54014 cache->bstop_percent = bstop;
54015 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54016 index 5349473..d6c0b93 100644
54017 --- a/fs/cachefiles/internal.h
54018 +++ b/fs/cachefiles/internal.h
54019 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54020 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54021 struct rb_root active_nodes; /* active nodes (can't be culled) */
54022 rwlock_t active_lock; /* lock for active_nodes */
54023 - atomic_t gravecounter; /* graveyard uniquifier */
54024 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54025 unsigned frun_percent; /* when to stop culling (% files) */
54026 unsigned fcull_percent; /* when to start culling (% files) */
54027 unsigned fstop_percent; /* when to stop allocating (% files) */
54028 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54029 * proc.c
54030 */
54031 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54032 -extern atomic_t cachefiles_lookup_histogram[HZ];
54033 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54034 -extern atomic_t cachefiles_create_histogram[HZ];
54035 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54036 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54037 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54038
54039 extern int __init cachefiles_proc_init(void);
54040 extern void cachefiles_proc_cleanup(void);
54041 static inline
54042 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54043 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54044 {
54045 unsigned long jif = jiffies - start_jif;
54046 if (jif >= HZ)
54047 jif = HZ - 1;
54048 - atomic_inc(&histogram[jif]);
54049 + atomic_inc_unchecked(&histogram[jif]);
54050 }
54051
54052 #else
54053 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54054 index f4a08d7..5aa4599 100644
54055 --- a/fs/cachefiles/namei.c
54056 +++ b/fs/cachefiles/namei.c
54057 @@ -317,7 +317,7 @@ try_again:
54058 /* first step is to make up a grave dentry in the graveyard */
54059 sprintf(nbuffer, "%08x%08x",
54060 (uint32_t) get_seconds(),
54061 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54062 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54063
54064 /* do the multiway lock magic */
54065 trap = lock_rename(cache->graveyard, dir);
54066 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54067 index eccd339..4c1d995 100644
54068 --- a/fs/cachefiles/proc.c
54069 +++ b/fs/cachefiles/proc.c
54070 @@ -14,9 +14,9 @@
54071 #include <linux/seq_file.h>
54072 #include "internal.h"
54073
54074 -atomic_t cachefiles_lookup_histogram[HZ];
54075 -atomic_t cachefiles_mkdir_histogram[HZ];
54076 -atomic_t cachefiles_create_histogram[HZ];
54077 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54078 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54079 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54080
54081 /*
54082 * display the latency histogram
54083 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54084 return 0;
54085 default:
54086 index = (unsigned long) v - 3;
54087 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54088 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54089 - z = atomic_read(&cachefiles_create_histogram[index]);
54090 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54091 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54092 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54093 if (x == 0 && y == 0 && z == 0)
54094 return 0;
54095
54096 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54097 index ebaff36..7e3ea26 100644
54098 --- a/fs/cachefiles/rdwr.c
54099 +++ b/fs/cachefiles/rdwr.c
54100 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54101 old_fs = get_fs();
54102 set_fs(KERNEL_DS);
54103 ret = file->f_op->write(
54104 - file, (const void __user *) data, len, &pos);
54105 + file, (const void __force_user *) data, len, &pos);
54106 set_fs(old_fs);
54107 kunmap(page);
54108 file_end_write(file);
54109 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54110 index 868b61d..58835a5 100644
54111 --- a/fs/ceph/dir.c
54112 +++ b/fs/ceph/dir.c
54113 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
54114 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54115 struct ceph_mds_client *mdsc = fsc->mdsc;
54116 unsigned frag = fpos_frag(ctx->pos);
54117 - int off = fpos_off(ctx->pos);
54118 + unsigned int off = fpos_off(ctx->pos);
54119 int err;
54120 u32 ftype;
54121 struct ceph_mds_reply_info_parsed *rinfo;
54122 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54123 index 6a0951e..03fac6d 100644
54124 --- a/fs/ceph/super.c
54125 +++ b/fs/ceph/super.c
54126 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54127 /*
54128 * construct our own bdi so we can control readahead, etc.
54129 */
54130 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54131 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54132
54133 static int ceph_register_bdi(struct super_block *sb,
54134 struct ceph_fs_client *fsc)
54135 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
54136 default_backing_dev_info.ra_pages;
54137
54138 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54139 - atomic_long_inc_return(&bdi_seq));
54140 + atomic_long_inc_return_unchecked(&bdi_seq));
54141 if (!err)
54142 sb->s_bdi = &fsc->backing_dev_info;
54143 return err;
54144 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54145 index f3ac415..3d2420c 100644
54146 --- a/fs/cifs/cifs_debug.c
54147 +++ b/fs/cifs/cifs_debug.c
54148 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54149
54150 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54151 #ifdef CONFIG_CIFS_STATS2
54152 - atomic_set(&totBufAllocCount, 0);
54153 - atomic_set(&totSmBufAllocCount, 0);
54154 + atomic_set_unchecked(&totBufAllocCount, 0);
54155 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54156 #endif /* CONFIG_CIFS_STATS2 */
54157 spin_lock(&cifs_tcp_ses_lock);
54158 list_for_each(tmp1, &cifs_tcp_ses_list) {
54159 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54160 tcon = list_entry(tmp3,
54161 struct cifs_tcon,
54162 tcon_list);
54163 - atomic_set(&tcon->num_smbs_sent, 0);
54164 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54165 if (server->ops->clear_stats)
54166 server->ops->clear_stats(tcon);
54167 }
54168 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54169 smBufAllocCount.counter, cifs_min_small);
54170 #ifdef CONFIG_CIFS_STATS2
54171 seq_printf(m, "Total Large %d Small %d Allocations\n",
54172 - atomic_read(&totBufAllocCount),
54173 - atomic_read(&totSmBufAllocCount));
54174 + atomic_read_unchecked(&totBufAllocCount),
54175 + atomic_read_unchecked(&totSmBufAllocCount));
54176 #endif /* CONFIG_CIFS_STATS2 */
54177
54178 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54179 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54180 if (tcon->need_reconnect)
54181 seq_puts(m, "\tDISCONNECTED ");
54182 seq_printf(m, "\nSMBs: %d",
54183 - atomic_read(&tcon->num_smbs_sent));
54184 + atomic_read_unchecked(&tcon->num_smbs_sent));
54185 if (server->ops->print_stats)
54186 server->ops->print_stats(m, tcon);
54187 }
54188 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54189 index 77fc5e1..e3d13e6 100644
54190 --- a/fs/cifs/cifsfs.c
54191 +++ b/fs/cifs/cifsfs.c
54192 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
54193 */
54194 cifs_req_cachep = kmem_cache_create("cifs_request",
54195 CIFSMaxBufSize + max_hdr_size, 0,
54196 - SLAB_HWCACHE_ALIGN, NULL);
54197 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54198 if (cifs_req_cachep == NULL)
54199 return -ENOMEM;
54200
54201 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
54202 efficient to alloc 1 per page off the slab compared to 17K (5page)
54203 alloc of large cifs buffers even when page debugging is on */
54204 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54205 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54206 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54207 NULL);
54208 if (cifs_sm_req_cachep == NULL) {
54209 mempool_destroy(cifs_req_poolp);
54210 @@ -1168,8 +1168,8 @@ init_cifs(void)
54211 atomic_set(&bufAllocCount, 0);
54212 atomic_set(&smBufAllocCount, 0);
54213 #ifdef CONFIG_CIFS_STATS2
54214 - atomic_set(&totBufAllocCount, 0);
54215 - atomic_set(&totSmBufAllocCount, 0);
54216 + atomic_set_unchecked(&totBufAllocCount, 0);
54217 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54218 #endif /* CONFIG_CIFS_STATS2 */
54219
54220 atomic_set(&midCount, 0);
54221 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54222 index 52b6f6c..68db1f4 100644
54223 --- a/fs/cifs/cifsglob.h
54224 +++ b/fs/cifs/cifsglob.h
54225 @@ -758,35 +758,35 @@ struct cifs_tcon {
54226 __u16 Flags; /* optional support bits */
54227 enum statusEnum tidStatus;
54228 #ifdef CONFIG_CIFS_STATS
54229 - atomic_t num_smbs_sent;
54230 + atomic_unchecked_t num_smbs_sent;
54231 union {
54232 struct {
54233 - atomic_t num_writes;
54234 - atomic_t num_reads;
54235 - atomic_t num_flushes;
54236 - atomic_t num_oplock_brks;
54237 - atomic_t num_opens;
54238 - atomic_t num_closes;
54239 - atomic_t num_deletes;
54240 - atomic_t num_mkdirs;
54241 - atomic_t num_posixopens;
54242 - atomic_t num_posixmkdirs;
54243 - atomic_t num_rmdirs;
54244 - atomic_t num_renames;
54245 - atomic_t num_t2renames;
54246 - atomic_t num_ffirst;
54247 - atomic_t num_fnext;
54248 - atomic_t num_fclose;
54249 - atomic_t num_hardlinks;
54250 - atomic_t num_symlinks;
54251 - atomic_t num_locks;
54252 - atomic_t num_acl_get;
54253 - atomic_t num_acl_set;
54254 + atomic_unchecked_t num_writes;
54255 + atomic_unchecked_t num_reads;
54256 + atomic_unchecked_t num_flushes;
54257 + atomic_unchecked_t num_oplock_brks;
54258 + atomic_unchecked_t num_opens;
54259 + atomic_unchecked_t num_closes;
54260 + atomic_unchecked_t num_deletes;
54261 + atomic_unchecked_t num_mkdirs;
54262 + atomic_unchecked_t num_posixopens;
54263 + atomic_unchecked_t num_posixmkdirs;
54264 + atomic_unchecked_t num_rmdirs;
54265 + atomic_unchecked_t num_renames;
54266 + atomic_unchecked_t num_t2renames;
54267 + atomic_unchecked_t num_ffirst;
54268 + atomic_unchecked_t num_fnext;
54269 + atomic_unchecked_t num_fclose;
54270 + atomic_unchecked_t num_hardlinks;
54271 + atomic_unchecked_t num_symlinks;
54272 + atomic_unchecked_t num_locks;
54273 + atomic_unchecked_t num_acl_get;
54274 + atomic_unchecked_t num_acl_set;
54275 } cifs_stats;
54276 #ifdef CONFIG_CIFS_SMB2
54277 struct {
54278 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54279 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54280 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54281 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54282 } smb2_stats;
54283 #endif /* CONFIG_CIFS_SMB2 */
54284 } stats;
54285 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
54286 }
54287
54288 #ifdef CONFIG_CIFS_STATS
54289 -#define cifs_stats_inc atomic_inc
54290 +#define cifs_stats_inc atomic_inc_unchecked
54291
54292 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
54293 unsigned int bytes)
54294 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54295 /* Various Debug counters */
54296 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54297 #ifdef CONFIG_CIFS_STATS2
54298 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54299 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54300 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54301 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54302 #endif
54303 GLOBAL_EXTERN atomic_t smBufAllocCount;
54304 GLOBAL_EXTERN atomic_t midCount;
54305 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54306 index 7e36ceb..109252f 100644
54307 --- a/fs/cifs/link.c
54308 +++ b/fs/cifs/link.c
54309 @@ -624,7 +624,7 @@ symlink_exit:
54310
54311 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54312 {
54313 - char *p = nd_get_link(nd);
54314 + const char *p = nd_get_link(nd);
54315 if (!IS_ERR(p))
54316 kfree(p);
54317 }
54318 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54319 index 138a011..cf9e13a 100644
54320 --- a/fs/cifs/misc.c
54321 +++ b/fs/cifs/misc.c
54322 @@ -170,7 +170,7 @@ cifs_buf_get(void)
54323 memset(ret_buf, 0, buf_size + 3);
54324 atomic_inc(&bufAllocCount);
54325 #ifdef CONFIG_CIFS_STATS2
54326 - atomic_inc(&totBufAllocCount);
54327 + atomic_inc_unchecked(&totBufAllocCount);
54328 #endif /* CONFIG_CIFS_STATS2 */
54329 }
54330
54331 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
54332 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
54333 atomic_inc(&smBufAllocCount);
54334 #ifdef CONFIG_CIFS_STATS2
54335 - atomic_inc(&totSmBufAllocCount);
54336 + atomic_inc_unchecked(&totSmBufAllocCount);
54337 #endif /* CONFIG_CIFS_STATS2 */
54338
54339 }
54340 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54341 index 8233b17..2b83e95 100644
54342 --- a/fs/cifs/smb1ops.c
54343 +++ b/fs/cifs/smb1ops.c
54344 @@ -590,27 +590,27 @@ static void
54345 cifs_clear_stats(struct cifs_tcon *tcon)
54346 {
54347 #ifdef CONFIG_CIFS_STATS
54348 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54349 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54350 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54351 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54352 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54353 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54354 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54355 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54356 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54357 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54358 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54359 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54360 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54361 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54362 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54363 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54364 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54365 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54366 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54367 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54368 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54369 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54370 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54371 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54372 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54373 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54374 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54375 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54376 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54377 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54378 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54379 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54380 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54381 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54382 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54383 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54384 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54385 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54386 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54387 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54388 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54389 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54390 #endif
54391 }
54392
54393 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54394 {
54395 #ifdef CONFIG_CIFS_STATS
54396 seq_printf(m, " Oplocks breaks: %d",
54397 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54398 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54399 seq_printf(m, "\nReads: %d Bytes: %llu",
54400 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54401 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54402 (long long)(tcon->bytes_read));
54403 seq_printf(m, "\nWrites: %d Bytes: %llu",
54404 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54405 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54406 (long long)(tcon->bytes_written));
54407 seq_printf(m, "\nFlushes: %d",
54408 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54409 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54410 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54411 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54412 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54413 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54414 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54415 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54416 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54417 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54418 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54419 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54420 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54421 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54422 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54423 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54424 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54425 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54426 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54427 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54428 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54429 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54430 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54431 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54432 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54433 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54434 seq_printf(m, "\nRenames: %d T2 Renames %d",
54435 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54436 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54437 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54438 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54439 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54440 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54441 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54442 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54443 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54444 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54445 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54446 #endif
54447 }
54448
54449 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54450 index 861b332..5506392 100644
54451 --- a/fs/cifs/smb2ops.c
54452 +++ b/fs/cifs/smb2ops.c
54453 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54454 #ifdef CONFIG_CIFS_STATS
54455 int i;
54456 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54457 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54458 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54459 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54460 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54461 }
54462 #endif
54463 }
54464 @@ -311,65 +311,65 @@ static void
54465 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54466 {
54467 #ifdef CONFIG_CIFS_STATS
54468 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54469 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54470 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54471 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54472 seq_printf(m, "\nNegotiates: %d sent %d failed",
54473 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54474 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54475 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54476 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54477 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54478 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54479 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54480 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54481 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54482 seq_printf(m, "\nLogoffs: %d sent %d failed",
54483 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54484 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54485 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54486 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54487 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54488 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54489 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54490 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54491 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54492 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54493 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54494 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54495 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54496 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54497 seq_printf(m, "\nCreates: %d sent %d failed",
54498 - atomic_read(&sent[SMB2_CREATE_HE]),
54499 - atomic_read(&failed[SMB2_CREATE_HE]));
54500 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54501 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54502 seq_printf(m, "\nCloses: %d sent %d failed",
54503 - atomic_read(&sent[SMB2_CLOSE_HE]),
54504 - atomic_read(&failed[SMB2_CLOSE_HE]));
54505 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54506 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54507 seq_printf(m, "\nFlushes: %d sent %d failed",
54508 - atomic_read(&sent[SMB2_FLUSH_HE]),
54509 - atomic_read(&failed[SMB2_FLUSH_HE]));
54510 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54511 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54512 seq_printf(m, "\nReads: %d sent %d failed",
54513 - atomic_read(&sent[SMB2_READ_HE]),
54514 - atomic_read(&failed[SMB2_READ_HE]));
54515 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54516 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54517 seq_printf(m, "\nWrites: %d sent %d failed",
54518 - atomic_read(&sent[SMB2_WRITE_HE]),
54519 - atomic_read(&failed[SMB2_WRITE_HE]));
54520 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54521 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54522 seq_printf(m, "\nLocks: %d sent %d failed",
54523 - atomic_read(&sent[SMB2_LOCK_HE]),
54524 - atomic_read(&failed[SMB2_LOCK_HE]));
54525 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54526 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54527 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54528 - atomic_read(&sent[SMB2_IOCTL_HE]),
54529 - atomic_read(&failed[SMB2_IOCTL_HE]));
54530 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54531 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54532 seq_printf(m, "\nCancels: %d sent %d failed",
54533 - atomic_read(&sent[SMB2_CANCEL_HE]),
54534 - atomic_read(&failed[SMB2_CANCEL_HE]));
54535 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54536 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54537 seq_printf(m, "\nEchos: %d sent %d failed",
54538 - atomic_read(&sent[SMB2_ECHO_HE]),
54539 - atomic_read(&failed[SMB2_ECHO_HE]));
54540 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54541 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54542 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54543 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54544 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54545 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54546 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54547 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54548 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54549 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54550 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54551 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54552 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54553 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54554 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54555 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54556 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54557 seq_printf(m, "\nSetInfos: %d sent %d failed",
54558 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54559 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54560 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54561 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54562 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54563 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54564 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54565 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54566 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54567 #endif
54568 }
54569
54570 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54571 index edccb52..16bc6db 100644
54572 --- a/fs/cifs/smb2pdu.c
54573 +++ b/fs/cifs/smb2pdu.c
54574 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54575 default:
54576 cifs_dbg(VFS, "info level %u isn't supported\n",
54577 srch_inf->info_level);
54578 - rc = -EINVAL;
54579 - goto qdir_exit;
54580 + return -EINVAL;
54581 }
54582
54583 req->FileIndex = cpu_to_le32(index);
54584 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54585 index 1da168c..8bc7ff6 100644
54586 --- a/fs/coda/cache.c
54587 +++ b/fs/coda/cache.c
54588 @@ -24,7 +24,7 @@
54589 #include "coda_linux.h"
54590 #include "coda_cache.h"
54591
54592 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54593 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54594
54595 /* replace or extend an acl cache hit */
54596 void coda_cache_enter(struct inode *inode, int mask)
54597 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54598 struct coda_inode_info *cii = ITOC(inode);
54599
54600 spin_lock(&cii->c_lock);
54601 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54602 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54603 if (!uid_eq(cii->c_uid, current_fsuid())) {
54604 cii->c_uid = current_fsuid();
54605 cii->c_cached_perm = mask;
54606 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54607 {
54608 struct coda_inode_info *cii = ITOC(inode);
54609 spin_lock(&cii->c_lock);
54610 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54611 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54612 spin_unlock(&cii->c_lock);
54613 }
54614
54615 /* remove all acl caches */
54616 void coda_cache_clear_all(struct super_block *sb)
54617 {
54618 - atomic_inc(&permission_epoch);
54619 + atomic_inc_unchecked(&permission_epoch);
54620 }
54621
54622
54623 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54624 spin_lock(&cii->c_lock);
54625 hit = (mask & cii->c_cached_perm) == mask &&
54626 uid_eq(cii->c_uid, current_fsuid()) &&
54627 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54628 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54629 spin_unlock(&cii->c_lock);
54630
54631 return hit;
54632 diff --git a/fs/compat.c b/fs/compat.c
54633 index 6af20de..fec3fbb 100644
54634 --- a/fs/compat.c
54635 +++ b/fs/compat.c
54636 @@ -54,7 +54,7 @@
54637 #include <asm/ioctls.h>
54638 #include "internal.h"
54639
54640 -int compat_log = 1;
54641 +int compat_log = 0;
54642
54643 int compat_printk(const char *fmt, ...)
54644 {
54645 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54646
54647 set_fs(KERNEL_DS);
54648 /* The __user pointer cast is valid because of the set_fs() */
54649 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54650 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54651 set_fs(oldfs);
54652 /* truncating is ok because it's a user address */
54653 if (!ret)
54654 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54655 goto out;
54656
54657 ret = -EINVAL;
54658 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54659 + if (nr_segs > UIO_MAXIOV)
54660 goto out;
54661 if (nr_segs > fast_segs) {
54662 ret = -ENOMEM;
54663 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54664 struct compat_readdir_callback {
54665 struct dir_context ctx;
54666 struct compat_old_linux_dirent __user *dirent;
54667 + struct file * file;
54668 int result;
54669 };
54670
54671 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54672 buf->result = -EOVERFLOW;
54673 return -EOVERFLOW;
54674 }
54675 +
54676 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54677 + return 0;
54678 +
54679 buf->result++;
54680 dirent = buf->dirent;
54681 if (!access_ok(VERIFY_WRITE, dirent,
54682 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54683 if (!f.file)
54684 return -EBADF;
54685
54686 + buf.file = f.file;
54687 error = iterate_dir(f.file, &buf.ctx);
54688 if (buf.result)
54689 error = buf.result;
54690 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54691 struct dir_context ctx;
54692 struct compat_linux_dirent __user *current_dir;
54693 struct compat_linux_dirent __user *previous;
54694 + struct file * file;
54695 int count;
54696 int error;
54697 };
54698 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54699 buf->error = -EOVERFLOW;
54700 return -EOVERFLOW;
54701 }
54702 +
54703 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54704 + return 0;
54705 +
54706 dirent = buf->previous;
54707 if (dirent) {
54708 if (__put_user(offset, &dirent->d_off))
54709 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54710 if (!f.file)
54711 return -EBADF;
54712
54713 + buf.file = f.file;
54714 error = iterate_dir(f.file, &buf.ctx);
54715 if (error >= 0)
54716 error = buf.error;
54717 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54718 struct dir_context ctx;
54719 struct linux_dirent64 __user *current_dir;
54720 struct linux_dirent64 __user *previous;
54721 + struct file * file;
54722 int count;
54723 int error;
54724 };
54725 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54726 buf->error = -EINVAL; /* only used if we fail.. */
54727 if (reclen > buf->count)
54728 return -EINVAL;
54729 +
54730 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54731 + return 0;
54732 +
54733 dirent = buf->previous;
54734
54735 if (dirent) {
54736 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54737 if (!f.file)
54738 return -EBADF;
54739
54740 + buf.file = f.file;
54741 error = iterate_dir(f.file, &buf.ctx);
54742 if (error >= 0)
54743 error = buf.error;
54744 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54745 index a81147e..20bf2b5 100644
54746 --- a/fs/compat_binfmt_elf.c
54747 +++ b/fs/compat_binfmt_elf.c
54748 @@ -30,11 +30,13 @@
54749 #undef elf_phdr
54750 #undef elf_shdr
54751 #undef elf_note
54752 +#undef elf_dyn
54753 #undef elf_addr_t
54754 #define elfhdr elf32_hdr
54755 #define elf_phdr elf32_phdr
54756 #define elf_shdr elf32_shdr
54757 #define elf_note elf32_note
54758 +#define elf_dyn Elf32_Dyn
54759 #define elf_addr_t Elf32_Addr
54760
54761 /*
54762 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54763 index 5d19acf..9ab093b 100644
54764 --- a/fs/compat_ioctl.c
54765 +++ b/fs/compat_ioctl.c
54766 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54767 return -EFAULT;
54768 if (__get_user(udata, &ss32->iomem_base))
54769 return -EFAULT;
54770 - ss.iomem_base = compat_ptr(udata);
54771 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54772 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54773 __get_user(ss.port_high, &ss32->port_high))
54774 return -EFAULT;
54775 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54776 for (i = 0; i < nmsgs; i++) {
54777 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54778 return -EFAULT;
54779 - if (get_user(datap, &umsgs[i].buf) ||
54780 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54781 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54782 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54783 return -EFAULT;
54784 }
54785 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54786 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54787 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54788 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54789 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54790 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54791 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54792 return -EFAULT;
54793
54794 return ioctl_preallocate(file, p);
54795 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54796 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54797 {
54798 unsigned int a, b;
54799 - a = *(unsigned int *)p;
54800 - b = *(unsigned int *)q;
54801 + a = *(const unsigned int *)p;
54802 + b = *(const unsigned int *)q;
54803 if (a > b)
54804 return 1;
54805 if (a < b)
54806 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54807 index 277bd1b..f312c9e 100644
54808 --- a/fs/configfs/dir.c
54809 +++ b/fs/configfs/dir.c
54810 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54811 }
54812 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54813 struct configfs_dirent *next;
54814 - const char *name;
54815 + const unsigned char * name;
54816 + char d_name[sizeof(next->s_dentry->d_iname)];
54817 int len;
54818 struct inode *inode = NULL;
54819
54820 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54821 continue;
54822
54823 name = configfs_get_name(next);
54824 - len = strlen(name);
54825 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54826 + len = next->s_dentry->d_name.len;
54827 + memcpy(d_name, name, len);
54828 + name = d_name;
54829 + } else
54830 + len = strlen(name);
54831
54832 /*
54833 * We'll have a dentry and an inode for
54834 diff --git a/fs/coredump.c b/fs/coredump.c
54835 index 9bdeca1..2247b92 100644
54836 --- a/fs/coredump.c
54837 +++ b/fs/coredump.c
54838 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
54839 struct pipe_inode_info *pipe = file->private_data;
54840
54841 pipe_lock(pipe);
54842 - pipe->readers++;
54843 - pipe->writers--;
54844 + atomic_inc(&pipe->readers);
54845 + atomic_dec(&pipe->writers);
54846 wake_up_interruptible_sync(&pipe->wait);
54847 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54848 pipe_unlock(pipe);
54849 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
54850 * We actually want wait_event_freezable() but then we need
54851 * to clear TIF_SIGPENDING and improve dump_interrupted().
54852 */
54853 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54854 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54855
54856 pipe_lock(pipe);
54857 - pipe->readers--;
54858 - pipe->writers++;
54859 + atomic_dec(&pipe->readers);
54860 + atomic_inc(&pipe->writers);
54861 pipe_unlock(pipe);
54862 }
54863
54864 @@ -499,7 +499,8 @@ void do_coredump(siginfo_t *siginfo)
54865 struct files_struct *displaced;
54866 bool need_nonrelative = false;
54867 bool core_dumped = false;
54868 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54869 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54870 + long signr = siginfo->si_signo;
54871 struct coredump_params cprm = {
54872 .siginfo = siginfo,
54873 .regs = signal_pt_regs(),
54874 @@ -512,7 +513,10 @@ void do_coredump(siginfo_t *siginfo)
54875 .mm_flags = mm->flags,
54876 };
54877
54878 - audit_core_dumps(siginfo->si_signo);
54879 + audit_core_dumps(signr);
54880 +
54881 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54882 + gr_handle_brute_attach(cprm.mm_flags);
54883
54884 binfmt = mm->binfmt;
54885 if (!binfmt || !binfmt->core_dump)
54886 @@ -536,7 +540,7 @@ void do_coredump(siginfo_t *siginfo)
54887 need_nonrelative = true;
54888 }
54889
54890 - retval = coredump_wait(siginfo->si_signo, &core_state);
54891 + retval = coredump_wait(signr, &core_state);
54892 if (retval < 0)
54893 goto fail_creds;
54894
54895 @@ -579,7 +583,7 @@ void do_coredump(siginfo_t *siginfo)
54896 }
54897 cprm.limit = RLIM_INFINITY;
54898
54899 - dump_count = atomic_inc_return(&core_dump_count);
54900 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54901 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54902 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54903 task_tgid_vnr(current), current->comm);
54904 @@ -611,6 +615,8 @@ void do_coredump(siginfo_t *siginfo)
54905 } else {
54906 struct inode *inode;
54907
54908 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54909 +
54910 if (cprm.limit < binfmt->min_coredump)
54911 goto fail_unlock;
54912
54913 @@ -669,7 +675,7 @@ close_fail:
54914 filp_close(cprm.file, NULL);
54915 fail_dropcount:
54916 if (ispipe)
54917 - atomic_dec(&core_dump_count);
54918 + atomic_dec_unchecked(&core_dump_count);
54919 fail_unlock:
54920 kfree(cn.corename);
54921 coredump_finish(mm, core_dumped);
54922 @@ -689,7 +695,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54923 {
54924 return !dump_interrupted() &&
54925 access_ok(VERIFY_READ, addr, nr) &&
54926 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54927 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54928 }
54929 EXPORT_SYMBOL(dump_write);
54930
54931 diff --git a/fs/dcache.c b/fs/dcache.c
54932 index ae6ebb8..6e46065 100644
54933 --- a/fs/dcache.c
54934 +++ b/fs/dcache.c
54935 @@ -3429,7 +3429,8 @@ void __init vfs_caches_init(unsigned long mempages)
54936 mempages -= reserve;
54937
54938 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54939 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54940 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54941 + SLAB_NO_SANITIZE, NULL);
54942
54943 dcache_init();
54944 inode_init();
54945 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54946 index c7c83ff..bda9461 100644
54947 --- a/fs/debugfs/inode.c
54948 +++ b/fs/debugfs/inode.c
54949 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54950 */
54951 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54952 {
54953 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54954 + return __create_file(name, S_IFDIR | S_IRWXU,
54955 +#else
54956 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54957 +#endif
54958 parent, NULL, NULL);
54959 }
54960 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54961 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54962 index 67e9b63..a9adb68 100644
54963 --- a/fs/ecryptfs/inode.c
54964 +++ b/fs/ecryptfs/inode.c
54965 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54966 old_fs = get_fs();
54967 set_fs(get_ds());
54968 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54969 - (char __user *)lower_buf,
54970 + (char __force_user *)lower_buf,
54971 PATH_MAX);
54972 set_fs(old_fs);
54973 if (rc < 0)
54974 @@ -706,7 +706,7 @@ out:
54975 static void
54976 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54977 {
54978 - char *buf = nd_get_link(nd);
54979 + const char *buf = nd_get_link(nd);
54980 if (!IS_ERR(buf)) {
54981 /* Free the char* */
54982 kfree(buf);
54983 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54984 index e4141f2..d8263e8 100644
54985 --- a/fs/ecryptfs/miscdev.c
54986 +++ b/fs/ecryptfs/miscdev.c
54987 @@ -304,7 +304,7 @@ check_list:
54988 goto out_unlock_msg_ctx;
54989 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54990 if (msg_ctx->msg) {
54991 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54992 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54993 goto out_unlock_msg_ctx;
54994 i += packet_length_size;
54995 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54996 diff --git a/fs/exec.c b/fs/exec.c
54997 index 8875dd1..c53682a 100644
54998 --- a/fs/exec.c
54999 +++ b/fs/exec.c
55000 @@ -55,8 +55,20 @@
55001 #include <linux/pipe_fs_i.h>
55002 #include <linux/oom.h>
55003 #include <linux/compat.h>
55004 +#include <linux/random.h>
55005 +#include <linux/seq_file.h>
55006 +#include <linux/coredump.h>
55007 +#include <linux/mman.h>
55008 +
55009 +#ifdef CONFIG_PAX_REFCOUNT
55010 +#include <linux/kallsyms.h>
55011 +#include <linux/kdebug.h>
55012 +#endif
55013 +
55014 +#include <trace/events/fs.h>
55015
55016 #include <asm/uaccess.h>
55017 +#include <asm/sections.h>
55018 #include <asm/mmu_context.h>
55019 #include <asm/tlb.h>
55020
55021 @@ -66,19 +78,34 @@
55022
55023 #include <trace/events/sched.h>
55024
55025 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55026 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55027 +{
55028 + 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");
55029 +}
55030 +#endif
55031 +
55032 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55033 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55034 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55035 +#endif
55036 +
55037 int suid_dumpable = 0;
55038
55039 static LIST_HEAD(formats);
55040 static DEFINE_RWLOCK(binfmt_lock);
55041
55042 +extern int gr_process_kernel_exec_ban(void);
55043 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55044 +
55045 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55046 {
55047 BUG_ON(!fmt);
55048 if (WARN_ON(!fmt->load_binary))
55049 return;
55050 write_lock(&binfmt_lock);
55051 - insert ? list_add(&fmt->lh, &formats) :
55052 - list_add_tail(&fmt->lh, &formats);
55053 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55054 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55055 write_unlock(&binfmt_lock);
55056 }
55057
55058 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
55059 void unregister_binfmt(struct linux_binfmt * fmt)
55060 {
55061 write_lock(&binfmt_lock);
55062 - list_del(&fmt->lh);
55063 + pax_list_del((struct list_head *)&fmt->lh);
55064 write_unlock(&binfmt_lock);
55065 }
55066
55067 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55068 int write)
55069 {
55070 struct page *page;
55071 - int ret;
55072
55073 -#ifdef CONFIG_STACK_GROWSUP
55074 - if (write) {
55075 - ret = expand_downwards(bprm->vma, pos);
55076 - if (ret < 0)
55077 - return NULL;
55078 - }
55079 -#endif
55080 - ret = get_user_pages(current, bprm->mm, pos,
55081 - 1, write, 1, &page, NULL);
55082 - if (ret <= 0)
55083 + if (0 > expand_downwards(bprm->vma, pos))
55084 + return NULL;
55085 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55086 return NULL;
55087
55088 if (write) {
55089 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55090 if (size <= ARG_MAX)
55091 return page;
55092
55093 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55094 + // only allow 512KB for argv+env on suid/sgid binaries
55095 + // to prevent easy ASLR exhaustion
55096 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55097 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55098 + (size > (512 * 1024))) {
55099 + put_page(page);
55100 + return NULL;
55101 + }
55102 +#endif
55103 +
55104 /*
55105 * Limit to 1/4-th the stack size for the argv+env strings.
55106 * This ensures that:
55107 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55108 vma->vm_end = STACK_TOP_MAX;
55109 vma->vm_start = vma->vm_end - PAGE_SIZE;
55110 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55111 +
55112 +#ifdef CONFIG_PAX_SEGMEXEC
55113 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55114 +#endif
55115 +
55116 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55117 INIT_LIST_HEAD(&vma->anon_vma_chain);
55118
55119 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55120 mm->stack_vm = mm->total_vm = 1;
55121 up_write(&mm->mmap_sem);
55122 bprm->p = vma->vm_end - sizeof(void *);
55123 +
55124 +#ifdef CONFIG_PAX_RANDUSTACK
55125 + if (randomize_va_space)
55126 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55127 +#endif
55128 +
55129 return 0;
55130 err:
55131 up_write(&mm->mmap_sem);
55132 @@ -399,7 +440,7 @@ struct user_arg_ptr {
55133 } ptr;
55134 };
55135
55136 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55137 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55138 {
55139 const char __user *native;
55140
55141 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55142 compat_uptr_t compat;
55143
55144 if (get_user(compat, argv.ptr.compat + nr))
55145 - return ERR_PTR(-EFAULT);
55146 + return (const char __force_user *)ERR_PTR(-EFAULT);
55147
55148 return compat_ptr(compat);
55149 }
55150 #endif
55151
55152 if (get_user(native, argv.ptr.native + nr))
55153 - return ERR_PTR(-EFAULT);
55154 + return (const char __force_user *)ERR_PTR(-EFAULT);
55155
55156 return native;
55157 }
55158 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
55159 if (!p)
55160 break;
55161
55162 - if (IS_ERR(p))
55163 + if (IS_ERR((const char __force_kernel *)p))
55164 return -EFAULT;
55165
55166 if (i >= max)
55167 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55168
55169 ret = -EFAULT;
55170 str = get_user_arg_ptr(argv, argc);
55171 - if (IS_ERR(str))
55172 + if (IS_ERR((const char __force_kernel *)str))
55173 goto out;
55174
55175 len = strnlen_user(str, MAX_ARG_STRLEN);
55176 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55177 int r;
55178 mm_segment_t oldfs = get_fs();
55179 struct user_arg_ptr argv = {
55180 - .ptr.native = (const char __user *const __user *)__argv,
55181 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55182 };
55183
55184 set_fs(KERNEL_DS);
55185 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55186 unsigned long new_end = old_end - shift;
55187 struct mmu_gather tlb;
55188
55189 - BUG_ON(new_start > new_end);
55190 + if (new_start >= new_end || new_start < mmap_min_addr)
55191 + return -ENOMEM;
55192
55193 /*
55194 * ensure there are no vmas between where we want to go
55195 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55196 if (vma != find_vma(mm, new_start))
55197 return -EFAULT;
55198
55199 +#ifdef CONFIG_PAX_SEGMEXEC
55200 + BUG_ON(pax_find_mirror_vma(vma));
55201 +#endif
55202 +
55203 /*
55204 * cover the whole range: [new_start, old_end)
55205 */
55206 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55207 stack_top = arch_align_stack(stack_top);
55208 stack_top = PAGE_ALIGN(stack_top);
55209
55210 - if (unlikely(stack_top < mmap_min_addr) ||
55211 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
55212 - return -ENOMEM;
55213 -
55214 stack_shift = vma->vm_end - stack_top;
55215
55216 bprm->p -= stack_shift;
55217 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
55218 bprm->exec -= stack_shift;
55219
55220 down_write(&mm->mmap_sem);
55221 +
55222 + /* Move stack pages down in memory. */
55223 + if (stack_shift) {
55224 + ret = shift_arg_pages(vma, stack_shift);
55225 + if (ret)
55226 + goto out_unlock;
55227 + }
55228 +
55229 vm_flags = VM_STACK_FLAGS;
55230
55231 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55232 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
55233 + vm_flags &= ~VM_EXEC;
55234 +
55235 +#ifdef CONFIG_PAX_MPROTECT
55236 + if (mm->pax_flags & MF_PAX_MPROTECT)
55237 + vm_flags &= ~VM_MAYEXEC;
55238 +#endif
55239 +
55240 + }
55241 +#endif
55242 +
55243 /*
55244 * Adjust stack execute permissions; explicitly enable for
55245 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
55246 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55247 goto out_unlock;
55248 BUG_ON(prev != vma);
55249
55250 - /* Move stack pages down in memory. */
55251 - if (stack_shift) {
55252 - ret = shift_arg_pages(vma, stack_shift);
55253 - if (ret)
55254 - goto out_unlock;
55255 - }
55256 -
55257 /* mprotect_fixup is overkill to remove the temporary stack flags */
55258 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55259
55260 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55261 #endif
55262 current->mm->start_stack = bprm->p;
55263 ret = expand_stack(vma, stack_base);
55264 +
55265 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55266 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55267 + unsigned long size;
55268 + vm_flags_t vm_flags;
55269 +
55270 + size = STACK_TOP - vma->vm_end;
55271 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55272 +
55273 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55274 +
55275 +#ifdef CONFIG_X86
55276 + if (!ret) {
55277 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55278 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55279 + }
55280 +#endif
55281 +
55282 + }
55283 +#endif
55284 +
55285 if (ret)
55286 ret = -EFAULT;
55287
55288 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
55289
55290 fsnotify_open(file);
55291
55292 + trace_open_exec(name);
55293 +
55294 err = deny_write_access(file);
55295 if (err)
55296 goto exit;
55297 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
55298 old_fs = get_fs();
55299 set_fs(get_ds());
55300 /* The cast to a user pointer is valid due to the set_fs() */
55301 - result = vfs_read(file, (void __user *)addr, count, &pos);
55302 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
55303 set_fs(old_fs);
55304 return result;
55305 }
55306 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
55307 }
55308 rcu_read_unlock();
55309
55310 - if (p->fs->users > n_fs) {
55311 + if (atomic_read(&p->fs->users) > n_fs) {
55312 bprm->unsafe |= LSM_UNSAFE_SHARE;
55313 } else {
55314 res = -EAGAIN;
55315 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
55316 return ret;
55317 }
55318
55319 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55320 +static DEFINE_PER_CPU(u64, exec_counter);
55321 +static int __init init_exec_counters(void)
55322 +{
55323 + unsigned int cpu;
55324 +
55325 + for_each_possible_cpu(cpu) {
55326 + per_cpu(exec_counter, cpu) = (u64)cpu;
55327 + }
55328 +
55329 + return 0;
55330 +}
55331 +early_initcall(init_exec_counters);
55332 +static inline void increment_exec_counter(void)
55333 +{
55334 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55335 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55336 +}
55337 +#else
55338 +static inline void increment_exec_counter(void) {}
55339 +#endif
55340 +
55341 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55342 + struct user_arg_ptr argv);
55343 +
55344 /*
55345 * sys_execve() executes a new program.
55346 */
55347 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
55348 struct user_arg_ptr argv,
55349 struct user_arg_ptr envp)
55350 {
55351 +#ifdef CONFIG_GRKERNSEC
55352 + struct file *old_exec_file;
55353 + struct acl_subject_label *old_acl;
55354 + struct rlimit old_rlim[RLIM_NLIMITS];
55355 +#endif
55356 struct linux_binprm *bprm;
55357 struct file *file;
55358 struct files_struct *displaced;
55359 bool clear_in_exec;
55360 int retval;
55361
55362 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
55363 +
55364 /*
55365 * We move the actual failure in case of RLIMIT_NPROC excess from
55366 * set*uid() to execve() because too many poorly written programs
55367 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
55368 if (IS_ERR(file))
55369 goto out_unmark;
55370
55371 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55372 + retval = -EPERM;
55373 + goto out_file;
55374 + }
55375 +
55376 sched_exec();
55377
55378 bprm->file = file;
55379 bprm->filename = filename;
55380 bprm->interp = filename;
55381
55382 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55383 + retval = -EACCES;
55384 + goto out_file;
55385 + }
55386 +
55387 retval = bprm_mm_init(bprm);
55388 if (retval)
55389 goto out_file;
55390 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
55391 if (retval < 0)
55392 goto out;
55393
55394 +#ifdef CONFIG_GRKERNSEC
55395 + old_acl = current->acl;
55396 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55397 + old_exec_file = current->exec_file;
55398 + get_file(file);
55399 + current->exec_file = file;
55400 +#endif
55401 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55402 + /* limit suid stack to 8MB
55403 + * we saved the old limits above and will restore them if this exec fails
55404 + */
55405 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55406 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55407 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55408 +#endif
55409 +
55410 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55411 + retval = -EPERM;
55412 + goto out_fail;
55413 + }
55414 +
55415 + if (!gr_tpe_allow(file)) {
55416 + retval = -EACCES;
55417 + goto out_fail;
55418 + }
55419 +
55420 + if (gr_check_crash_exec(file)) {
55421 + retval = -EACCES;
55422 + goto out_fail;
55423 + }
55424 +
55425 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55426 + bprm->unsafe);
55427 + if (retval < 0)
55428 + goto out_fail;
55429 +
55430 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55431 if (retval < 0)
55432 - goto out;
55433 + goto out_fail;
55434
55435 bprm->exec = bprm->p;
55436 retval = copy_strings(bprm->envc, envp, bprm);
55437 if (retval < 0)
55438 - goto out;
55439 + goto out_fail;
55440
55441 retval = copy_strings(bprm->argc, argv, bprm);
55442 if (retval < 0)
55443 - goto out;
55444 + goto out_fail;
55445 +
55446 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55447 +
55448 + gr_handle_exec_args(bprm, argv);
55449
55450 retval = exec_binprm(bprm);
55451 if (retval < 0)
55452 - goto out;
55453 + goto out_fail;
55454 +#ifdef CONFIG_GRKERNSEC
55455 + if (old_exec_file)
55456 + fput(old_exec_file);
55457 +#endif
55458
55459 /* execve succeeded */
55460 +
55461 + increment_exec_counter();
55462 current->fs->in_exec = 0;
55463 current->in_execve = 0;
55464 acct_update_integrals(current);
55465 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
55466 put_files_struct(displaced);
55467 return retval;
55468
55469 +out_fail:
55470 +#ifdef CONFIG_GRKERNSEC
55471 + current->acl = old_acl;
55472 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55473 + fput(current->exec_file);
55474 + current->exec_file = old_exec_file;
55475 +#endif
55476 +
55477 out:
55478 if (bprm->mm) {
55479 acct_arg_size(bprm, 0);
55480 @@ -1700,3 +1874,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55481 return error;
55482 }
55483 #endif
55484 +
55485 +int pax_check_flags(unsigned long *flags)
55486 +{
55487 + int retval = 0;
55488 +
55489 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55490 + if (*flags & MF_PAX_SEGMEXEC)
55491 + {
55492 + *flags &= ~MF_PAX_SEGMEXEC;
55493 + retval = -EINVAL;
55494 + }
55495 +#endif
55496 +
55497 + if ((*flags & MF_PAX_PAGEEXEC)
55498 +
55499 +#ifdef CONFIG_PAX_PAGEEXEC
55500 + && (*flags & MF_PAX_SEGMEXEC)
55501 +#endif
55502 +
55503 + )
55504 + {
55505 + *flags &= ~MF_PAX_PAGEEXEC;
55506 + retval = -EINVAL;
55507 + }
55508 +
55509 + if ((*flags & MF_PAX_MPROTECT)
55510 +
55511 +#ifdef CONFIG_PAX_MPROTECT
55512 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55513 +#endif
55514 +
55515 + )
55516 + {
55517 + *flags &= ~MF_PAX_MPROTECT;
55518 + retval = -EINVAL;
55519 + }
55520 +
55521 + if ((*flags & MF_PAX_EMUTRAMP)
55522 +
55523 +#ifdef CONFIG_PAX_EMUTRAMP
55524 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55525 +#endif
55526 +
55527 + )
55528 + {
55529 + *flags &= ~MF_PAX_EMUTRAMP;
55530 + retval = -EINVAL;
55531 + }
55532 +
55533 + return retval;
55534 +}
55535 +
55536 +EXPORT_SYMBOL(pax_check_flags);
55537 +
55538 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55539 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55540 +{
55541 + char *pathname = d_path(path, buf, buflen);
55542 +
55543 + if (IS_ERR(pathname))
55544 + goto toolong;
55545 +
55546 + pathname = mangle_path(buf, pathname, "\t\n\\");
55547 + if (!pathname)
55548 + goto toolong;
55549 +
55550 + *pathname = 0;
55551 + return buf;
55552 +
55553 +toolong:
55554 + return "<path too long>";
55555 +}
55556 +EXPORT_SYMBOL(pax_get_path);
55557 +
55558 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55559 +{
55560 + struct task_struct *tsk = current;
55561 + struct mm_struct *mm = current->mm;
55562 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55563 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55564 + char *path_exec = NULL;
55565 + char *path_fault = NULL;
55566 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55567 + siginfo_t info = { };
55568 +
55569 + if (buffer_exec && buffer_fault) {
55570 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55571 +
55572 + down_read(&mm->mmap_sem);
55573 + vma = mm->mmap;
55574 + while (vma && (!vma_exec || !vma_fault)) {
55575 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55576 + vma_exec = vma;
55577 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55578 + vma_fault = vma;
55579 + vma = vma->vm_next;
55580 + }
55581 + if (vma_exec)
55582 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55583 + if (vma_fault) {
55584 + start = vma_fault->vm_start;
55585 + end = vma_fault->vm_end;
55586 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55587 + if (vma_fault->vm_file)
55588 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55589 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55590 + path_fault = "<heap>";
55591 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55592 + path_fault = "<stack>";
55593 + else
55594 + path_fault = "<anonymous mapping>";
55595 + }
55596 + up_read(&mm->mmap_sem);
55597 + }
55598 + if (tsk->signal->curr_ip)
55599 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55600 + else
55601 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55602 + 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),
55603 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55604 + free_page((unsigned long)buffer_exec);
55605 + free_page((unsigned long)buffer_fault);
55606 + pax_report_insns(regs, pc, sp);
55607 + info.si_signo = SIGKILL;
55608 + info.si_errno = 0;
55609 + info.si_code = SI_KERNEL;
55610 + info.si_pid = 0;
55611 + info.si_uid = 0;
55612 + do_coredump(&info);
55613 +}
55614 +#endif
55615 +
55616 +#ifdef CONFIG_PAX_REFCOUNT
55617 +void pax_report_refcount_overflow(struct pt_regs *regs)
55618 +{
55619 + if (current->signal->curr_ip)
55620 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55621 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55622 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55623 + else
55624 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55625 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55626 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55627 + preempt_disable();
55628 + show_regs(regs);
55629 + preempt_enable();
55630 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55631 +}
55632 +#endif
55633 +
55634 +#ifdef CONFIG_PAX_USERCOPY
55635 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55636 +static noinline int check_stack_object(const void *obj, unsigned long len)
55637 +{
55638 + const void * const stack = task_stack_page(current);
55639 + const void * const stackend = stack + THREAD_SIZE;
55640 +
55641 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55642 + const void *frame = NULL;
55643 + const void *oldframe;
55644 +#endif
55645 +
55646 + if (obj + len < obj)
55647 + return -1;
55648 +
55649 + if (obj + len <= stack || stackend <= obj)
55650 + return 0;
55651 +
55652 + if (obj < stack || stackend < obj + len)
55653 + return -1;
55654 +
55655 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55656 + oldframe = __builtin_frame_address(1);
55657 + if (oldframe)
55658 + frame = __builtin_frame_address(2);
55659 + /*
55660 + low ----------------------------------------------> high
55661 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55662 + ^----------------^
55663 + allow copies only within here
55664 + */
55665 + while (stack <= frame && frame < stackend) {
55666 + /* if obj + len extends past the last frame, this
55667 + check won't pass and the next frame will be 0,
55668 + causing us to bail out and correctly report
55669 + the copy as invalid
55670 + */
55671 + if (obj + len <= frame)
55672 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55673 + oldframe = frame;
55674 + frame = *(const void * const *)frame;
55675 + }
55676 + return -1;
55677 +#else
55678 + return 1;
55679 +#endif
55680 +}
55681 +
55682 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55683 +{
55684 + if (current->signal->curr_ip)
55685 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55686 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55687 + else
55688 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55689 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55690 + dump_stack();
55691 + gr_handle_kernel_exploit();
55692 + do_group_exit(SIGKILL);
55693 +}
55694 +#endif
55695 +
55696 +#ifdef CONFIG_PAX_USERCOPY
55697 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55698 +{
55699 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55700 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55701 +#ifdef CONFIG_MODULES
55702 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55703 +#else
55704 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55705 +#endif
55706 +
55707 +#else
55708 + unsigned long textlow = (unsigned long)_stext;
55709 + unsigned long texthigh = (unsigned long)_etext;
55710 +
55711 +#ifdef CONFIG_X86_64
55712 + /* check against linear mapping as well */
55713 + if (high > (unsigned long)__va(__pa(textlow)) &&
55714 + low <= (unsigned long)__va(__pa(texthigh)))
55715 + return true;
55716 +#endif
55717 +
55718 +#endif
55719 +
55720 + if (high <= textlow || low > texthigh)
55721 + return false;
55722 + else
55723 + return true;
55724 +}
55725 +#endif
55726 +
55727 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55728 +{
55729 +
55730 +#ifdef CONFIG_PAX_USERCOPY
55731 + const char *type;
55732 +
55733 + if (!n)
55734 + return;
55735 +
55736 + type = check_heap_object(ptr, n);
55737 + if (!type) {
55738 + int ret = check_stack_object(ptr, n);
55739 + if (ret == 1 || ret == 2)
55740 + return;
55741 + if (ret == 0) {
55742 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55743 + type = "<kernel text>";
55744 + else
55745 + return;
55746 + } else
55747 + type = "<process stack>";
55748 + }
55749 +
55750 + pax_report_usercopy(ptr, n, to_user, type);
55751 +#endif
55752 +
55753 +}
55754 +EXPORT_SYMBOL(__check_object_size);
55755 +
55756 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55757 +void pax_track_stack(void)
55758 +{
55759 + unsigned long sp = (unsigned long)&sp;
55760 + if (sp < current_thread_info()->lowest_stack &&
55761 + sp > (unsigned long)task_stack_page(current))
55762 + current_thread_info()->lowest_stack = sp;
55763 +}
55764 +EXPORT_SYMBOL(pax_track_stack);
55765 +#endif
55766 +
55767 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55768 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55769 +{
55770 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55771 + dump_stack();
55772 + do_group_exit(SIGKILL);
55773 +}
55774 +EXPORT_SYMBOL(report_size_overflow);
55775 +#endif
55776 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55777 index 9f9992b..8b59411 100644
55778 --- a/fs/ext2/balloc.c
55779 +++ b/fs/ext2/balloc.c
55780 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55781
55782 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55783 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55784 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55785 + if (free_blocks < root_blocks + 1 &&
55786 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55787 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55788 - !in_group_p (sbi->s_resgid))) {
55789 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55790 return 0;
55791 }
55792 return 1;
55793 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
55794 index 2d7557d..14e38f94 100644
55795 --- a/fs/ext2/xattr.c
55796 +++ b/fs/ext2/xattr.c
55797 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
55798 struct buffer_head *bh = NULL;
55799 struct ext2_xattr_entry *entry;
55800 char *end;
55801 - size_t rest = buffer_size;
55802 + size_t rest = buffer_size, total_size = 0;
55803 int error;
55804
55805 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
55806 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
55807 buffer += size;
55808 }
55809 rest -= size;
55810 + total_size += size;
55811 }
55812 }
55813 - error = buffer_size - rest; /* total size */
55814 + error = total_size;
55815
55816 cleanup:
55817 brelse(bh);
55818 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55819 index 22548f5..41521d8 100644
55820 --- a/fs/ext3/balloc.c
55821 +++ b/fs/ext3/balloc.c
55822 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55823
55824 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55825 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55826 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55827 + if (free_blocks < root_blocks + 1 &&
55828 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55829 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55830 - !in_group_p (sbi->s_resgid))) {
55831 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55832 return 0;
55833 }
55834 return 1;
55835 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
55836 index b1fc963..881228c 100644
55837 --- a/fs/ext3/xattr.c
55838 +++ b/fs/ext3/xattr.c
55839 @@ -330,7 +330,7 @@ static int
55840 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55841 char *buffer, size_t buffer_size)
55842 {
55843 - size_t rest = buffer_size;
55844 + size_t rest = buffer_size, total_size = 0;
55845
55846 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
55847 const struct xattr_handler *handler =
55848 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55849 buffer += size;
55850 }
55851 rest -= size;
55852 + total_size += size;
55853 }
55854 }
55855 - return buffer_size - rest;
55856 + return total_size;
55857 }
55858
55859 static int
55860 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55861 index dc5d572..4c21f8e 100644
55862 --- a/fs/ext4/balloc.c
55863 +++ b/fs/ext4/balloc.c
55864 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55865 /* Hm, nope. Are (enough) root reserved clusters available? */
55866 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55867 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55868 - capable(CAP_SYS_RESOURCE) ||
55869 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55870 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55871 + capable_nolog(CAP_SYS_RESOURCE)) {
55872
55873 if (free_clusters >= (nclusters + dirty_clusters +
55874 resv_clusters))
55875 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55876 index af815ea..99294a6 100644
55877 --- a/fs/ext4/ext4.h
55878 +++ b/fs/ext4/ext4.h
55879 @@ -1256,19 +1256,19 @@ struct ext4_sb_info {
55880 unsigned long s_mb_last_start;
55881
55882 /* stats for buddy allocator */
55883 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55884 - atomic_t s_bal_success; /* we found long enough chunks */
55885 - atomic_t s_bal_allocated; /* in blocks */
55886 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55887 - atomic_t s_bal_goals; /* goal hits */
55888 - atomic_t s_bal_breaks; /* too long searches */
55889 - atomic_t s_bal_2orders; /* 2^order hits */
55890 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55891 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55892 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55893 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55894 + atomic_unchecked_t s_bal_goals; /* goal hits */
55895 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55896 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55897 spinlock_t s_bal_lock;
55898 unsigned long s_mb_buddies_generated;
55899 unsigned long long s_mb_generation_time;
55900 - atomic_t s_mb_lost_chunks;
55901 - atomic_t s_mb_preallocated;
55902 - atomic_t s_mb_discarded;
55903 + atomic_unchecked_t s_mb_lost_chunks;
55904 + atomic_unchecked_t s_mb_preallocated;
55905 + atomic_unchecked_t s_mb_discarded;
55906 atomic_t s_lock_busy;
55907
55908 /* locality groups */
55909 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55910 index a41e3ba..e574a00 100644
55911 --- a/fs/ext4/mballoc.c
55912 +++ b/fs/ext4/mballoc.c
55913 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55914 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55915
55916 if (EXT4_SB(sb)->s_mb_stats)
55917 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55918 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55919
55920 break;
55921 }
55922 @@ -2189,7 +2189,7 @@ repeat:
55923 ac->ac_status = AC_STATUS_CONTINUE;
55924 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55925 cr = 3;
55926 - atomic_inc(&sbi->s_mb_lost_chunks);
55927 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55928 goto repeat;
55929 }
55930 }
55931 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
55932 if (sbi->s_mb_stats) {
55933 ext4_msg(sb, KERN_INFO,
55934 "mballoc: %u blocks %u reqs (%u success)",
55935 - atomic_read(&sbi->s_bal_allocated),
55936 - atomic_read(&sbi->s_bal_reqs),
55937 - atomic_read(&sbi->s_bal_success));
55938 + atomic_read_unchecked(&sbi->s_bal_allocated),
55939 + atomic_read_unchecked(&sbi->s_bal_reqs),
55940 + atomic_read_unchecked(&sbi->s_bal_success));
55941 ext4_msg(sb, KERN_INFO,
55942 "mballoc: %u extents scanned, %u goal hits, "
55943 "%u 2^N hits, %u breaks, %u lost",
55944 - atomic_read(&sbi->s_bal_ex_scanned),
55945 - atomic_read(&sbi->s_bal_goals),
55946 - atomic_read(&sbi->s_bal_2orders),
55947 - atomic_read(&sbi->s_bal_breaks),
55948 - atomic_read(&sbi->s_mb_lost_chunks));
55949 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55950 + atomic_read_unchecked(&sbi->s_bal_goals),
55951 + atomic_read_unchecked(&sbi->s_bal_2orders),
55952 + atomic_read_unchecked(&sbi->s_bal_breaks),
55953 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55954 ext4_msg(sb, KERN_INFO,
55955 "mballoc: %lu generated and it took %Lu",
55956 sbi->s_mb_buddies_generated,
55957 sbi->s_mb_generation_time);
55958 ext4_msg(sb, KERN_INFO,
55959 "mballoc: %u preallocated, %u discarded",
55960 - atomic_read(&sbi->s_mb_preallocated),
55961 - atomic_read(&sbi->s_mb_discarded));
55962 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55963 + atomic_read_unchecked(&sbi->s_mb_discarded));
55964 }
55965
55966 free_percpu(sbi->s_locality_groups);
55967 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55968 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55969
55970 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55971 - atomic_inc(&sbi->s_bal_reqs);
55972 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55973 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55974 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55975 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55976 - atomic_inc(&sbi->s_bal_success);
55977 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55978 + atomic_inc_unchecked(&sbi->s_bal_success);
55979 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55980 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55981 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55982 - atomic_inc(&sbi->s_bal_goals);
55983 + atomic_inc_unchecked(&sbi->s_bal_goals);
55984 if (ac->ac_found > sbi->s_mb_max_to_scan)
55985 - atomic_inc(&sbi->s_bal_breaks);
55986 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55987 }
55988
55989 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55990 @@ -3578,7 +3578,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55991 trace_ext4_mb_new_inode_pa(ac, pa);
55992
55993 ext4_mb_use_inode_pa(ac, pa);
55994 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55995 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55996
55997 ei = EXT4_I(ac->ac_inode);
55998 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55999 @@ -3638,7 +3638,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56000 trace_ext4_mb_new_group_pa(ac, pa);
56001
56002 ext4_mb_use_group_pa(ac, pa);
56003 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56004 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56005
56006 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56007 lg = ac->ac_lg;
56008 @@ -3727,7 +3727,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56009 * from the bitmap and continue.
56010 */
56011 }
56012 - atomic_add(free, &sbi->s_mb_discarded);
56013 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56014
56015 return err;
56016 }
56017 @@ -3745,7 +3745,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56018 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56019 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56020 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56021 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56022 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56023 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56024
56025 return 0;
56026 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56027 index 214461e..3614c89 100644
56028 --- a/fs/ext4/mmp.c
56029 +++ b/fs/ext4/mmp.c
56030 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56031 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56032 const char *function, unsigned int line, const char *msg)
56033 {
56034 - __ext4_warning(sb, function, line, msg);
56035 + __ext4_warning(sb, function, line, "%s", msg);
56036 __ext4_warning(sb, function, line,
56037 "MMP failure info: last update time: %llu, last update "
56038 "node: %s, last update device: %s\n",
56039 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56040 index 2c2e6cb..7c3ee62 100644
56041 --- a/fs/ext4/super.c
56042 +++ b/fs/ext4/super.c
56043 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56044 }
56045
56046 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56047 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56048 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56049 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56050
56051 #ifdef CONFIG_QUOTA
56052 @@ -2431,7 +2431,7 @@ struct ext4_attr {
56053 int offset;
56054 int deprecated_val;
56055 } u;
56056 -};
56057 +} __do_const;
56058
56059 static int parse_strtoull(const char *buf,
56060 unsigned long long max, unsigned long long *value)
56061 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56062 index 03e9beb..e86ce98 100644
56063 --- a/fs/ext4/xattr.c
56064 +++ b/fs/ext4/xattr.c
56065 @@ -381,7 +381,7 @@ static int
56066 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56067 char *buffer, size_t buffer_size)
56068 {
56069 - size_t rest = buffer_size;
56070 + size_t rest = buffer_size, total_size = 0;
56071
56072 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
56073 const struct xattr_handler *handler =
56074 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56075 buffer += size;
56076 }
56077 rest -= size;
56078 + total_size += size;
56079 }
56080 }
56081 - return buffer_size - rest;
56082 + return total_size;
56083 }
56084
56085 static int
56086 diff --git a/fs/fcntl.c b/fs/fcntl.c
56087 index 65343c3..9969dcf 100644
56088 --- a/fs/fcntl.c
56089 +++ b/fs/fcntl.c
56090 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56091 if (err)
56092 return err;
56093
56094 + if (gr_handle_chroot_fowner(pid, type))
56095 + return -ENOENT;
56096 + if (gr_check_protected_task_fowner(pid, type))
56097 + return -EACCES;
56098 +
56099 f_modown(filp, pid, type, force);
56100 return 0;
56101 }
56102 diff --git a/fs/fhandle.c b/fs/fhandle.c
56103 index 999ff5c..41f4109 100644
56104 --- a/fs/fhandle.c
56105 +++ b/fs/fhandle.c
56106 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56107 } else
56108 retval = 0;
56109 /* copy the mount id */
56110 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56111 - sizeof(*mnt_id)) ||
56112 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56113 copy_to_user(ufh, handle,
56114 sizeof(struct file_handle) + handle_bytes))
56115 retval = -EFAULT;
56116 diff --git a/fs/file.c b/fs/file.c
56117 index 4a78f98..9447397 100644
56118 --- a/fs/file.c
56119 +++ b/fs/file.c
56120 @@ -16,6 +16,7 @@
56121 #include <linux/slab.h>
56122 #include <linux/vmalloc.h>
56123 #include <linux/file.h>
56124 +#include <linux/security.h>
56125 #include <linux/fdtable.h>
56126 #include <linux/bitops.h>
56127 #include <linux/interrupt.h>
56128 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56129 if (!file)
56130 return __close_fd(files, fd);
56131
56132 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56133 if (fd >= rlimit(RLIMIT_NOFILE))
56134 return -EBADF;
56135
56136 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56137 if (unlikely(oldfd == newfd))
56138 return -EINVAL;
56139
56140 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56141 if (newfd >= rlimit(RLIMIT_NOFILE))
56142 return -EBADF;
56143
56144 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56145 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56146 {
56147 int err;
56148 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56149 if (from >= rlimit(RLIMIT_NOFILE))
56150 return -EINVAL;
56151 err = alloc_fd(from, flags);
56152 diff --git a/fs/filesystems.c b/fs/filesystems.c
56153 index 92567d9..fcd8cbf 100644
56154 --- a/fs/filesystems.c
56155 +++ b/fs/filesystems.c
56156 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56157 int len = dot ? dot - name : strlen(name);
56158
56159 fs = __get_fs_type(name, len);
56160 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56161 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56162 +#else
56163 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56164 +#endif
56165 fs = __get_fs_type(name, len);
56166
56167 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56168 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56169 index d8ac61d..79a36f0 100644
56170 --- a/fs/fs_struct.c
56171 +++ b/fs/fs_struct.c
56172 @@ -4,6 +4,7 @@
56173 #include <linux/path.h>
56174 #include <linux/slab.h>
56175 #include <linux/fs_struct.h>
56176 +#include <linux/grsecurity.h>
56177 #include "internal.h"
56178
56179 /*
56180 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56181 write_seqcount_begin(&fs->seq);
56182 old_root = fs->root;
56183 fs->root = *path;
56184 + gr_set_chroot_entries(current, path);
56185 write_seqcount_end(&fs->seq);
56186 spin_unlock(&fs->lock);
56187 if (old_root.dentry)
56188 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56189 int hits = 0;
56190 spin_lock(&fs->lock);
56191 write_seqcount_begin(&fs->seq);
56192 + /* this root replacement is only done by pivot_root,
56193 + leave grsec's chroot tagging alone for this task
56194 + so that a pivoted root isn't treated as a chroot
56195 + */
56196 hits += replace_path(&fs->root, old_root, new_root);
56197 hits += replace_path(&fs->pwd, old_root, new_root);
56198 write_seqcount_end(&fs->seq);
56199 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
56200 task_lock(tsk);
56201 spin_lock(&fs->lock);
56202 tsk->fs = NULL;
56203 - kill = !--fs->users;
56204 + gr_clear_chroot_entries(tsk);
56205 + kill = !atomic_dec_return(&fs->users);
56206 spin_unlock(&fs->lock);
56207 task_unlock(tsk);
56208 if (kill)
56209 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56210 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
56211 /* We don't need to lock fs - think why ;-) */
56212 if (fs) {
56213 - fs->users = 1;
56214 + atomic_set(&fs->users, 1);
56215 fs->in_exec = 0;
56216 spin_lock_init(&fs->lock);
56217 seqcount_init(&fs->seq);
56218 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56219 spin_lock(&old->lock);
56220 fs->root = old->root;
56221 path_get(&fs->root);
56222 + /* instead of calling gr_set_chroot_entries here,
56223 + we call it from every caller of this function
56224 + */
56225 fs->pwd = old->pwd;
56226 path_get(&fs->pwd);
56227 spin_unlock(&old->lock);
56228 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
56229
56230 task_lock(current);
56231 spin_lock(&fs->lock);
56232 - kill = !--fs->users;
56233 + kill = !atomic_dec_return(&fs->users);
56234 current->fs = new_fs;
56235 + gr_set_chroot_entries(current, &new_fs->root);
56236 spin_unlock(&fs->lock);
56237 task_unlock(current);
56238
56239 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
56240
56241 int current_umask(void)
56242 {
56243 - return current->fs->umask;
56244 + return current->fs->umask | gr_acl_umask();
56245 }
56246 EXPORT_SYMBOL(current_umask);
56247
56248 /* to be mentioned only in INIT_TASK */
56249 struct fs_struct init_fs = {
56250 - .users = 1,
56251 + .users = ATOMIC_INIT(1),
56252 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
56253 .seq = SEQCNT_ZERO,
56254 .umask = 0022,
56255 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
56256 index b2a86e3..37f425a 100644
56257 --- a/fs/fscache/cookie.c
56258 +++ b/fs/fscache/cookie.c
56259 @@ -19,7 +19,7 @@
56260
56261 struct kmem_cache *fscache_cookie_jar;
56262
56263 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
56264 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
56265
56266 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
56267 static int fscache_alloc_object(struct fscache_cache *cache,
56268 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
56269 parent ? (char *) parent->def->name : "<no-parent>",
56270 def->name, netfs_data);
56271
56272 - fscache_stat(&fscache_n_acquires);
56273 + fscache_stat_unchecked(&fscache_n_acquires);
56274
56275 /* if there's no parent cookie, then we don't create one here either */
56276 if (!parent) {
56277 - fscache_stat(&fscache_n_acquires_null);
56278 + fscache_stat_unchecked(&fscache_n_acquires_null);
56279 _leave(" [no parent]");
56280 return NULL;
56281 }
56282 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
56283 /* allocate and initialise a cookie */
56284 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
56285 if (!cookie) {
56286 - fscache_stat(&fscache_n_acquires_oom);
56287 + fscache_stat_unchecked(&fscache_n_acquires_oom);
56288 _leave(" [ENOMEM]");
56289 return NULL;
56290 }
56291 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56292
56293 switch (cookie->def->type) {
56294 case FSCACHE_COOKIE_TYPE_INDEX:
56295 - fscache_stat(&fscache_n_cookie_index);
56296 + fscache_stat_unchecked(&fscache_n_cookie_index);
56297 break;
56298 case FSCACHE_COOKIE_TYPE_DATAFILE:
56299 - fscache_stat(&fscache_n_cookie_data);
56300 + fscache_stat_unchecked(&fscache_n_cookie_data);
56301 break;
56302 default:
56303 - fscache_stat(&fscache_n_cookie_special);
56304 + fscache_stat_unchecked(&fscache_n_cookie_special);
56305 break;
56306 }
56307
56308 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56309 if (fscache_acquire_non_index_cookie(cookie) < 0) {
56310 atomic_dec(&parent->n_children);
56311 __fscache_cookie_put(cookie);
56312 - fscache_stat(&fscache_n_acquires_nobufs);
56313 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
56314 _leave(" = NULL");
56315 return NULL;
56316 }
56317 }
56318
56319 - fscache_stat(&fscache_n_acquires_ok);
56320 + fscache_stat_unchecked(&fscache_n_acquires_ok);
56321 _leave(" = %p", cookie);
56322 return cookie;
56323 }
56324 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
56325 cache = fscache_select_cache_for_object(cookie->parent);
56326 if (!cache) {
56327 up_read(&fscache_addremove_sem);
56328 - fscache_stat(&fscache_n_acquires_no_cache);
56329 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
56330 _leave(" = -ENOMEDIUM [no cache]");
56331 return -ENOMEDIUM;
56332 }
56333 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
56334 object = cache->ops->alloc_object(cache, cookie);
56335 fscache_stat_d(&fscache_n_cop_alloc_object);
56336 if (IS_ERR(object)) {
56337 - fscache_stat(&fscache_n_object_no_alloc);
56338 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
56339 ret = PTR_ERR(object);
56340 goto error;
56341 }
56342
56343 - fscache_stat(&fscache_n_object_alloc);
56344 + fscache_stat_unchecked(&fscache_n_object_alloc);
56345
56346 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
56347 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
56348
56349 _debug("ALLOC OBJ%x: %s {%lx}",
56350 object->debug_id, cookie->def->name, object->events);
56351 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
56352
56353 _enter("{%s}", cookie->def->name);
56354
56355 - fscache_stat(&fscache_n_invalidates);
56356 + fscache_stat_unchecked(&fscache_n_invalidates);
56357
56358 /* Only permit invalidation of data files. Invalidating an index will
56359 * require the caller to release all its attachments to the tree rooted
56360 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56361 {
56362 struct fscache_object *object;
56363
56364 - fscache_stat(&fscache_n_updates);
56365 + fscache_stat_unchecked(&fscache_n_updates);
56366
56367 if (!cookie) {
56368 - fscache_stat(&fscache_n_updates_null);
56369 + fscache_stat_unchecked(&fscache_n_updates_null);
56370 _leave(" [no cookie]");
56371 return;
56372 }
56373 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56374 {
56375 struct fscache_object *object;
56376
56377 - fscache_stat(&fscache_n_relinquishes);
56378 + fscache_stat_unchecked(&fscache_n_relinquishes);
56379 if (retire)
56380 - fscache_stat(&fscache_n_relinquishes_retire);
56381 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56382
56383 if (!cookie) {
56384 - fscache_stat(&fscache_n_relinquishes_null);
56385 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56386 _leave(" [no cookie]");
56387 return;
56388 }
56389 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
56390 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
56391 goto inconsistent;
56392
56393 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
56394 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56395
56396 atomic_inc(&cookie->n_active);
56397 if (fscache_submit_op(object, op) < 0)
56398 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56399 index 4226f66..0fb3f45 100644
56400 --- a/fs/fscache/internal.h
56401 +++ b/fs/fscache/internal.h
56402 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
56403 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
56404 extern int fscache_wait_for_operation_activation(struct fscache_object *,
56405 struct fscache_operation *,
56406 - atomic_t *,
56407 - atomic_t *,
56408 + atomic_unchecked_t *,
56409 + atomic_unchecked_t *,
56410 void (*)(struct fscache_operation *));
56411 extern void fscache_invalidate_writes(struct fscache_cookie *);
56412
56413 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
56414 * stats.c
56415 */
56416 #ifdef CONFIG_FSCACHE_STATS
56417 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56418 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56419 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56420 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56421
56422 -extern atomic_t fscache_n_op_pend;
56423 -extern atomic_t fscache_n_op_run;
56424 -extern atomic_t fscache_n_op_enqueue;
56425 -extern atomic_t fscache_n_op_deferred_release;
56426 -extern atomic_t fscache_n_op_release;
56427 -extern atomic_t fscache_n_op_gc;
56428 -extern atomic_t fscache_n_op_cancelled;
56429 -extern atomic_t fscache_n_op_rejected;
56430 +extern atomic_unchecked_t fscache_n_op_pend;
56431 +extern atomic_unchecked_t fscache_n_op_run;
56432 +extern atomic_unchecked_t fscache_n_op_enqueue;
56433 +extern atomic_unchecked_t fscache_n_op_deferred_release;
56434 +extern atomic_unchecked_t fscache_n_op_release;
56435 +extern atomic_unchecked_t fscache_n_op_gc;
56436 +extern atomic_unchecked_t fscache_n_op_cancelled;
56437 +extern atomic_unchecked_t fscache_n_op_rejected;
56438
56439 -extern atomic_t fscache_n_attr_changed;
56440 -extern atomic_t fscache_n_attr_changed_ok;
56441 -extern atomic_t fscache_n_attr_changed_nobufs;
56442 -extern atomic_t fscache_n_attr_changed_nomem;
56443 -extern atomic_t fscache_n_attr_changed_calls;
56444 +extern atomic_unchecked_t fscache_n_attr_changed;
56445 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56446 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56447 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56448 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56449
56450 -extern atomic_t fscache_n_allocs;
56451 -extern atomic_t fscache_n_allocs_ok;
56452 -extern atomic_t fscache_n_allocs_wait;
56453 -extern atomic_t fscache_n_allocs_nobufs;
56454 -extern atomic_t fscache_n_allocs_intr;
56455 -extern atomic_t fscache_n_allocs_object_dead;
56456 -extern atomic_t fscache_n_alloc_ops;
56457 -extern atomic_t fscache_n_alloc_op_waits;
56458 +extern atomic_unchecked_t fscache_n_allocs;
56459 +extern atomic_unchecked_t fscache_n_allocs_ok;
56460 +extern atomic_unchecked_t fscache_n_allocs_wait;
56461 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56462 +extern atomic_unchecked_t fscache_n_allocs_intr;
56463 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56464 +extern atomic_unchecked_t fscache_n_alloc_ops;
56465 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56466
56467 -extern atomic_t fscache_n_retrievals;
56468 -extern atomic_t fscache_n_retrievals_ok;
56469 -extern atomic_t fscache_n_retrievals_wait;
56470 -extern atomic_t fscache_n_retrievals_nodata;
56471 -extern atomic_t fscache_n_retrievals_nobufs;
56472 -extern atomic_t fscache_n_retrievals_intr;
56473 -extern atomic_t fscache_n_retrievals_nomem;
56474 -extern atomic_t fscache_n_retrievals_object_dead;
56475 -extern atomic_t fscache_n_retrieval_ops;
56476 -extern atomic_t fscache_n_retrieval_op_waits;
56477 +extern atomic_unchecked_t fscache_n_retrievals;
56478 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56479 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56480 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56481 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56482 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56483 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56484 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56485 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56486 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56487
56488 -extern atomic_t fscache_n_stores;
56489 -extern atomic_t fscache_n_stores_ok;
56490 -extern atomic_t fscache_n_stores_again;
56491 -extern atomic_t fscache_n_stores_nobufs;
56492 -extern atomic_t fscache_n_stores_oom;
56493 -extern atomic_t fscache_n_store_ops;
56494 -extern atomic_t fscache_n_store_calls;
56495 -extern atomic_t fscache_n_store_pages;
56496 -extern atomic_t fscache_n_store_radix_deletes;
56497 -extern atomic_t fscache_n_store_pages_over_limit;
56498 +extern atomic_unchecked_t fscache_n_stores;
56499 +extern atomic_unchecked_t fscache_n_stores_ok;
56500 +extern atomic_unchecked_t fscache_n_stores_again;
56501 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56502 +extern atomic_unchecked_t fscache_n_stores_oom;
56503 +extern atomic_unchecked_t fscache_n_store_ops;
56504 +extern atomic_unchecked_t fscache_n_store_calls;
56505 +extern atomic_unchecked_t fscache_n_store_pages;
56506 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56507 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56508
56509 -extern atomic_t fscache_n_store_vmscan_not_storing;
56510 -extern atomic_t fscache_n_store_vmscan_gone;
56511 -extern atomic_t fscache_n_store_vmscan_busy;
56512 -extern atomic_t fscache_n_store_vmscan_cancelled;
56513 -extern atomic_t fscache_n_store_vmscan_wait;
56514 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56515 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56516 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56517 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56518 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56519
56520 -extern atomic_t fscache_n_marks;
56521 -extern atomic_t fscache_n_uncaches;
56522 +extern atomic_unchecked_t fscache_n_marks;
56523 +extern atomic_unchecked_t fscache_n_uncaches;
56524
56525 -extern atomic_t fscache_n_acquires;
56526 -extern atomic_t fscache_n_acquires_null;
56527 -extern atomic_t fscache_n_acquires_no_cache;
56528 -extern atomic_t fscache_n_acquires_ok;
56529 -extern atomic_t fscache_n_acquires_nobufs;
56530 -extern atomic_t fscache_n_acquires_oom;
56531 +extern atomic_unchecked_t fscache_n_acquires;
56532 +extern atomic_unchecked_t fscache_n_acquires_null;
56533 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56534 +extern atomic_unchecked_t fscache_n_acquires_ok;
56535 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56536 +extern atomic_unchecked_t fscache_n_acquires_oom;
56537
56538 -extern atomic_t fscache_n_invalidates;
56539 -extern atomic_t fscache_n_invalidates_run;
56540 +extern atomic_unchecked_t fscache_n_invalidates;
56541 +extern atomic_unchecked_t fscache_n_invalidates_run;
56542
56543 -extern atomic_t fscache_n_updates;
56544 -extern atomic_t fscache_n_updates_null;
56545 -extern atomic_t fscache_n_updates_run;
56546 +extern atomic_unchecked_t fscache_n_updates;
56547 +extern atomic_unchecked_t fscache_n_updates_null;
56548 +extern atomic_unchecked_t fscache_n_updates_run;
56549
56550 -extern atomic_t fscache_n_relinquishes;
56551 -extern atomic_t fscache_n_relinquishes_null;
56552 -extern atomic_t fscache_n_relinquishes_waitcrt;
56553 -extern atomic_t fscache_n_relinquishes_retire;
56554 +extern atomic_unchecked_t fscache_n_relinquishes;
56555 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56556 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56557 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56558
56559 -extern atomic_t fscache_n_cookie_index;
56560 -extern atomic_t fscache_n_cookie_data;
56561 -extern atomic_t fscache_n_cookie_special;
56562 +extern atomic_unchecked_t fscache_n_cookie_index;
56563 +extern atomic_unchecked_t fscache_n_cookie_data;
56564 +extern atomic_unchecked_t fscache_n_cookie_special;
56565
56566 -extern atomic_t fscache_n_object_alloc;
56567 -extern atomic_t fscache_n_object_no_alloc;
56568 -extern atomic_t fscache_n_object_lookups;
56569 -extern atomic_t fscache_n_object_lookups_negative;
56570 -extern atomic_t fscache_n_object_lookups_positive;
56571 -extern atomic_t fscache_n_object_lookups_timed_out;
56572 -extern atomic_t fscache_n_object_created;
56573 -extern atomic_t fscache_n_object_avail;
56574 -extern atomic_t fscache_n_object_dead;
56575 +extern atomic_unchecked_t fscache_n_object_alloc;
56576 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56577 +extern atomic_unchecked_t fscache_n_object_lookups;
56578 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56579 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56580 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56581 +extern atomic_unchecked_t fscache_n_object_created;
56582 +extern atomic_unchecked_t fscache_n_object_avail;
56583 +extern atomic_unchecked_t fscache_n_object_dead;
56584
56585 -extern atomic_t fscache_n_checkaux_none;
56586 -extern atomic_t fscache_n_checkaux_okay;
56587 -extern atomic_t fscache_n_checkaux_update;
56588 -extern atomic_t fscache_n_checkaux_obsolete;
56589 +extern atomic_unchecked_t fscache_n_checkaux_none;
56590 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56591 +extern atomic_unchecked_t fscache_n_checkaux_update;
56592 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56593
56594 extern atomic_t fscache_n_cop_alloc_object;
56595 extern atomic_t fscache_n_cop_lookup_object;
56596 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
56597 atomic_inc(stat);
56598 }
56599
56600 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56601 +{
56602 + atomic_inc_unchecked(stat);
56603 +}
56604 +
56605 static inline void fscache_stat_d(atomic_t *stat)
56606 {
56607 atomic_dec(stat);
56608 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
56609
56610 #define __fscache_stat(stat) (NULL)
56611 #define fscache_stat(stat) do {} while (0)
56612 +#define fscache_stat_unchecked(stat) do {} while (0)
56613 #define fscache_stat_d(stat) do {} while (0)
56614 #endif
56615
56616 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56617 index 86d75a6..5f3d7a0 100644
56618 --- a/fs/fscache/object.c
56619 +++ b/fs/fscache/object.c
56620 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56621 _debug("LOOKUP \"%s\" in \"%s\"",
56622 cookie->def->name, object->cache->tag->name);
56623
56624 - fscache_stat(&fscache_n_object_lookups);
56625 + fscache_stat_unchecked(&fscache_n_object_lookups);
56626 fscache_stat(&fscache_n_cop_lookup_object);
56627 ret = object->cache->ops->lookup_object(object);
56628 fscache_stat_d(&fscache_n_cop_lookup_object);
56629 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56630 if (ret == -ETIMEDOUT) {
56631 /* probably stuck behind another object, so move this one to
56632 * the back of the queue */
56633 - fscache_stat(&fscache_n_object_lookups_timed_out);
56634 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56635 _leave(" [timeout]");
56636 return NO_TRANSIT;
56637 }
56638 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56639 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56640
56641 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56642 - fscache_stat(&fscache_n_object_lookups_negative);
56643 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56644
56645 /* Allow write requests to begin stacking up and read requests to begin
56646 * returning ENODATA.
56647 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56648 /* if we were still looking up, then we must have a positive lookup
56649 * result, in which case there may be data available */
56650 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56651 - fscache_stat(&fscache_n_object_lookups_positive);
56652 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56653
56654 /* We do (presumably) have data */
56655 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56656 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56657 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56658 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56659 } else {
56660 - fscache_stat(&fscache_n_object_created);
56661 + fscache_stat_unchecked(&fscache_n_object_created);
56662 }
56663
56664 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56665 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56666 fscache_stat_d(&fscache_n_cop_lookup_complete);
56667
56668 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56669 - fscache_stat(&fscache_n_object_avail);
56670 + fscache_stat_unchecked(&fscache_n_object_avail);
56671
56672 _leave("");
56673 return transit_to(JUMPSTART_DEPS);
56674 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56675
56676 /* this just shifts the object release to the work processor */
56677 fscache_put_object(object);
56678 - fscache_stat(&fscache_n_object_dead);
56679 + fscache_stat_unchecked(&fscache_n_object_dead);
56680
56681 _leave("");
56682 return transit_to(OBJECT_DEAD);
56683 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56684 enum fscache_checkaux result;
56685
56686 if (!object->cookie->def->check_aux) {
56687 - fscache_stat(&fscache_n_checkaux_none);
56688 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56689 return FSCACHE_CHECKAUX_OKAY;
56690 }
56691
56692 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56693 switch (result) {
56694 /* entry okay as is */
56695 case FSCACHE_CHECKAUX_OKAY:
56696 - fscache_stat(&fscache_n_checkaux_okay);
56697 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56698 break;
56699
56700 /* entry requires update */
56701 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56702 - fscache_stat(&fscache_n_checkaux_update);
56703 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56704 break;
56705
56706 /* entry requires deletion */
56707 case FSCACHE_CHECKAUX_OBSOLETE:
56708 - fscache_stat(&fscache_n_checkaux_obsolete);
56709 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56710 break;
56711
56712 default:
56713 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56714 {
56715 const struct fscache_state *s;
56716
56717 - fscache_stat(&fscache_n_invalidates_run);
56718 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56719 fscache_stat(&fscache_n_cop_invalidate_object);
56720 s = _fscache_invalidate_object(object, event);
56721 fscache_stat_d(&fscache_n_cop_invalidate_object);
56722 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56723 {
56724 _enter("{OBJ%x},%d", object->debug_id, event);
56725
56726 - fscache_stat(&fscache_n_updates_run);
56727 + fscache_stat_unchecked(&fscache_n_updates_run);
56728 fscache_stat(&fscache_n_cop_update_object);
56729 object->cache->ops->update_object(object);
56730 fscache_stat_d(&fscache_n_cop_update_object);
56731 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56732 index 318071a..379938b 100644
56733 --- a/fs/fscache/operation.c
56734 +++ b/fs/fscache/operation.c
56735 @@ -17,7 +17,7 @@
56736 #include <linux/slab.h>
56737 #include "internal.h"
56738
56739 -atomic_t fscache_op_debug_id;
56740 +atomic_unchecked_t fscache_op_debug_id;
56741 EXPORT_SYMBOL(fscache_op_debug_id);
56742
56743 /**
56744 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56745 ASSERTCMP(atomic_read(&op->usage), >, 0);
56746 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56747
56748 - fscache_stat(&fscache_n_op_enqueue);
56749 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56750 switch (op->flags & FSCACHE_OP_TYPE) {
56751 case FSCACHE_OP_ASYNC:
56752 _debug("queue async");
56753 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56754 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56755 if (op->processor)
56756 fscache_enqueue_operation(op);
56757 - fscache_stat(&fscache_n_op_run);
56758 + fscache_stat_unchecked(&fscache_n_op_run);
56759 }
56760
56761 /*
56762 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56763 if (object->n_in_progress > 0) {
56764 atomic_inc(&op->usage);
56765 list_add_tail(&op->pend_link, &object->pending_ops);
56766 - fscache_stat(&fscache_n_op_pend);
56767 + fscache_stat_unchecked(&fscache_n_op_pend);
56768 } else if (!list_empty(&object->pending_ops)) {
56769 atomic_inc(&op->usage);
56770 list_add_tail(&op->pend_link, &object->pending_ops);
56771 - fscache_stat(&fscache_n_op_pend);
56772 + fscache_stat_unchecked(&fscache_n_op_pend);
56773 fscache_start_operations(object);
56774 } else {
56775 ASSERTCMP(object->n_in_progress, ==, 0);
56776 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56777 object->n_exclusive++; /* reads and writes must wait */
56778 atomic_inc(&op->usage);
56779 list_add_tail(&op->pend_link, &object->pending_ops);
56780 - fscache_stat(&fscache_n_op_pend);
56781 + fscache_stat_unchecked(&fscache_n_op_pend);
56782 ret = 0;
56783 } else {
56784 /* If we're in any other state, there must have been an I/O
56785 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56786 if (object->n_exclusive > 0) {
56787 atomic_inc(&op->usage);
56788 list_add_tail(&op->pend_link, &object->pending_ops);
56789 - fscache_stat(&fscache_n_op_pend);
56790 + fscache_stat_unchecked(&fscache_n_op_pend);
56791 } else if (!list_empty(&object->pending_ops)) {
56792 atomic_inc(&op->usage);
56793 list_add_tail(&op->pend_link, &object->pending_ops);
56794 - fscache_stat(&fscache_n_op_pend);
56795 + fscache_stat_unchecked(&fscache_n_op_pend);
56796 fscache_start_operations(object);
56797 } else {
56798 ASSERTCMP(object->n_exclusive, ==, 0);
56799 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56800 object->n_ops++;
56801 atomic_inc(&op->usage);
56802 list_add_tail(&op->pend_link, &object->pending_ops);
56803 - fscache_stat(&fscache_n_op_pend);
56804 + fscache_stat_unchecked(&fscache_n_op_pend);
56805 ret = 0;
56806 } else if (fscache_object_is_dying(object)) {
56807 - fscache_stat(&fscache_n_op_rejected);
56808 + fscache_stat_unchecked(&fscache_n_op_rejected);
56809 op->state = FSCACHE_OP_ST_CANCELLED;
56810 ret = -ENOBUFS;
56811 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56812 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56813 ret = -EBUSY;
56814 if (op->state == FSCACHE_OP_ST_PENDING) {
56815 ASSERT(!list_empty(&op->pend_link));
56816 - fscache_stat(&fscache_n_op_cancelled);
56817 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56818 list_del_init(&op->pend_link);
56819 if (do_cancel)
56820 do_cancel(op);
56821 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56822 while (!list_empty(&object->pending_ops)) {
56823 op = list_entry(object->pending_ops.next,
56824 struct fscache_operation, pend_link);
56825 - fscache_stat(&fscache_n_op_cancelled);
56826 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56827 list_del_init(&op->pend_link);
56828
56829 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56830 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56831 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56832 op->state = FSCACHE_OP_ST_DEAD;
56833
56834 - fscache_stat(&fscache_n_op_release);
56835 + fscache_stat_unchecked(&fscache_n_op_release);
56836
56837 if (op->release) {
56838 op->release(op);
56839 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56840 * lock, and defer it otherwise */
56841 if (!spin_trylock(&object->lock)) {
56842 _debug("defer put");
56843 - fscache_stat(&fscache_n_op_deferred_release);
56844 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56845
56846 cache = object->cache;
56847 spin_lock(&cache->op_gc_list_lock);
56848 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56849
56850 _debug("GC DEFERRED REL OBJ%x OP%x",
56851 object->debug_id, op->debug_id);
56852 - fscache_stat(&fscache_n_op_gc);
56853 + fscache_stat_unchecked(&fscache_n_op_gc);
56854
56855 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56856 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56857 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56858 index 73899c1..ae40c58 100644
56859 --- a/fs/fscache/page.c
56860 +++ b/fs/fscache/page.c
56861 @@ -61,7 +61,7 @@ try_again:
56862 val = radix_tree_lookup(&cookie->stores, page->index);
56863 if (!val) {
56864 rcu_read_unlock();
56865 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56866 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56867 __fscache_uncache_page(cookie, page);
56868 return true;
56869 }
56870 @@ -91,11 +91,11 @@ try_again:
56871 spin_unlock(&cookie->stores_lock);
56872
56873 if (xpage) {
56874 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56875 - fscache_stat(&fscache_n_store_radix_deletes);
56876 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56877 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56878 ASSERTCMP(xpage, ==, page);
56879 } else {
56880 - fscache_stat(&fscache_n_store_vmscan_gone);
56881 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56882 }
56883
56884 wake_up_bit(&cookie->flags, 0);
56885 @@ -110,11 +110,11 @@ page_busy:
56886 * sleeping on memory allocation, so we may need to impose a timeout
56887 * too. */
56888 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56889 - fscache_stat(&fscache_n_store_vmscan_busy);
56890 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56891 return false;
56892 }
56893
56894 - fscache_stat(&fscache_n_store_vmscan_wait);
56895 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56896 __fscache_wait_on_page_write(cookie, page);
56897 gfp &= ~__GFP_WAIT;
56898 goto try_again;
56899 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56900 FSCACHE_COOKIE_STORING_TAG);
56901 if (!radix_tree_tag_get(&cookie->stores, page->index,
56902 FSCACHE_COOKIE_PENDING_TAG)) {
56903 - fscache_stat(&fscache_n_store_radix_deletes);
56904 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56905 xpage = radix_tree_delete(&cookie->stores, page->index);
56906 }
56907 spin_unlock(&cookie->stores_lock);
56908 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56909
56910 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56911
56912 - fscache_stat(&fscache_n_attr_changed_calls);
56913 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56914
56915 if (fscache_object_is_active(object) &&
56916 fscache_use_cookie(object)) {
56917 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56918
56919 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56920
56921 - fscache_stat(&fscache_n_attr_changed);
56922 + fscache_stat_unchecked(&fscache_n_attr_changed);
56923
56924 op = kzalloc(sizeof(*op), GFP_KERNEL);
56925 if (!op) {
56926 - fscache_stat(&fscache_n_attr_changed_nomem);
56927 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56928 _leave(" = -ENOMEM");
56929 return -ENOMEM;
56930 }
56931 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56932 if (fscache_submit_exclusive_op(object, op) < 0)
56933 goto nobufs;
56934 spin_unlock(&cookie->lock);
56935 - fscache_stat(&fscache_n_attr_changed_ok);
56936 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56937 fscache_put_operation(op);
56938 _leave(" = 0");
56939 return 0;
56940 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56941 nobufs:
56942 spin_unlock(&cookie->lock);
56943 kfree(op);
56944 - fscache_stat(&fscache_n_attr_changed_nobufs);
56945 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56946 _leave(" = %d", -ENOBUFS);
56947 return -ENOBUFS;
56948 }
56949 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56950 /* allocate a retrieval operation and attempt to submit it */
56951 op = kzalloc(sizeof(*op), GFP_NOIO);
56952 if (!op) {
56953 - fscache_stat(&fscache_n_retrievals_nomem);
56954 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56955 return NULL;
56956 }
56957
56958 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56959 return 0;
56960 }
56961
56962 - fscache_stat(&fscache_n_retrievals_wait);
56963 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56964
56965 jif = jiffies;
56966 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56967 fscache_wait_bit_interruptible,
56968 TASK_INTERRUPTIBLE) != 0) {
56969 - fscache_stat(&fscache_n_retrievals_intr);
56970 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56971 _leave(" = -ERESTARTSYS");
56972 return -ERESTARTSYS;
56973 }
56974 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56975 */
56976 int fscache_wait_for_operation_activation(struct fscache_object *object,
56977 struct fscache_operation *op,
56978 - atomic_t *stat_op_waits,
56979 - atomic_t *stat_object_dead,
56980 + atomic_unchecked_t *stat_op_waits,
56981 + atomic_unchecked_t *stat_object_dead,
56982 void (*do_cancel)(struct fscache_operation *))
56983 {
56984 int ret;
56985 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
56986
56987 _debug(">>> WT");
56988 if (stat_op_waits)
56989 - fscache_stat(stat_op_waits);
56990 + fscache_stat_unchecked(stat_op_waits);
56991 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
56992 fscache_wait_bit_interruptible,
56993 TASK_INTERRUPTIBLE) != 0) {
56994 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
56995 check_if_dead:
56996 if (op->state == FSCACHE_OP_ST_CANCELLED) {
56997 if (stat_object_dead)
56998 - fscache_stat(stat_object_dead);
56999 + fscache_stat_unchecked(stat_object_dead);
57000 _leave(" = -ENOBUFS [cancelled]");
57001 return -ENOBUFS;
57002 }
57003 @@ -361,7 +361,7 @@ check_if_dead:
57004 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
57005 fscache_cancel_op(op, do_cancel);
57006 if (stat_object_dead)
57007 - fscache_stat(stat_object_dead);
57008 + fscache_stat_unchecked(stat_object_dead);
57009 return -ENOBUFS;
57010 }
57011 return 0;
57012 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57013
57014 _enter("%p,%p,,,", cookie, page);
57015
57016 - fscache_stat(&fscache_n_retrievals);
57017 + fscache_stat_unchecked(&fscache_n_retrievals);
57018
57019 if (hlist_empty(&cookie->backing_objects))
57020 goto nobufs;
57021 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57022 goto nobufs_unlock_dec;
57023 spin_unlock(&cookie->lock);
57024
57025 - fscache_stat(&fscache_n_retrieval_ops);
57026 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57027
57028 /* pin the netfs read context in case we need to do the actual netfs
57029 * read because we've encountered a cache read failure */
57030 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57031
57032 error:
57033 if (ret == -ENOMEM)
57034 - fscache_stat(&fscache_n_retrievals_nomem);
57035 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57036 else if (ret == -ERESTARTSYS)
57037 - fscache_stat(&fscache_n_retrievals_intr);
57038 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57039 else if (ret == -ENODATA)
57040 - fscache_stat(&fscache_n_retrievals_nodata);
57041 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57042 else if (ret < 0)
57043 - fscache_stat(&fscache_n_retrievals_nobufs);
57044 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57045 else
57046 - fscache_stat(&fscache_n_retrievals_ok);
57047 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57048
57049 fscache_put_retrieval(op);
57050 _leave(" = %d", ret);
57051 @@ -480,7 +480,7 @@ nobufs_unlock:
57052 atomic_dec(&cookie->n_active);
57053 kfree(op);
57054 nobufs:
57055 - fscache_stat(&fscache_n_retrievals_nobufs);
57056 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57057 _leave(" = -ENOBUFS");
57058 return -ENOBUFS;
57059 }
57060 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57061
57062 _enter("%p,,%d,,,", cookie, *nr_pages);
57063
57064 - fscache_stat(&fscache_n_retrievals);
57065 + fscache_stat_unchecked(&fscache_n_retrievals);
57066
57067 if (hlist_empty(&cookie->backing_objects))
57068 goto nobufs;
57069 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57070 goto nobufs_unlock_dec;
57071 spin_unlock(&cookie->lock);
57072
57073 - fscache_stat(&fscache_n_retrieval_ops);
57074 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57075
57076 /* pin the netfs read context in case we need to do the actual netfs
57077 * read because we've encountered a cache read failure */
57078 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57079
57080 error:
57081 if (ret == -ENOMEM)
57082 - fscache_stat(&fscache_n_retrievals_nomem);
57083 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57084 else if (ret == -ERESTARTSYS)
57085 - fscache_stat(&fscache_n_retrievals_intr);
57086 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57087 else if (ret == -ENODATA)
57088 - fscache_stat(&fscache_n_retrievals_nodata);
57089 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57090 else if (ret < 0)
57091 - fscache_stat(&fscache_n_retrievals_nobufs);
57092 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57093 else
57094 - fscache_stat(&fscache_n_retrievals_ok);
57095 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57096
57097 fscache_put_retrieval(op);
57098 _leave(" = %d", ret);
57099 @@ -606,7 +606,7 @@ nobufs_unlock:
57100 atomic_dec(&cookie->n_active);
57101 kfree(op);
57102 nobufs:
57103 - fscache_stat(&fscache_n_retrievals_nobufs);
57104 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57105 _leave(" = -ENOBUFS");
57106 return -ENOBUFS;
57107 }
57108 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57109
57110 _enter("%p,%p,,,", cookie, page);
57111
57112 - fscache_stat(&fscache_n_allocs);
57113 + fscache_stat_unchecked(&fscache_n_allocs);
57114
57115 if (hlist_empty(&cookie->backing_objects))
57116 goto nobufs;
57117 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57118 goto nobufs_unlock;
57119 spin_unlock(&cookie->lock);
57120
57121 - fscache_stat(&fscache_n_alloc_ops);
57122 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57123
57124 ret = fscache_wait_for_operation_activation(
57125 object, &op->op,
57126 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57127
57128 error:
57129 if (ret == -ERESTARTSYS)
57130 - fscache_stat(&fscache_n_allocs_intr);
57131 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57132 else if (ret < 0)
57133 - fscache_stat(&fscache_n_allocs_nobufs);
57134 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57135 else
57136 - fscache_stat(&fscache_n_allocs_ok);
57137 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57138
57139 fscache_put_retrieval(op);
57140 _leave(" = %d", ret);
57141 @@ -694,7 +694,7 @@ nobufs_unlock:
57142 atomic_dec(&cookie->n_active);
57143 kfree(op);
57144 nobufs:
57145 - fscache_stat(&fscache_n_allocs_nobufs);
57146 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57147 _leave(" = -ENOBUFS");
57148 return -ENOBUFS;
57149 }
57150 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57151
57152 spin_lock(&cookie->stores_lock);
57153
57154 - fscache_stat(&fscache_n_store_calls);
57155 + fscache_stat_unchecked(&fscache_n_store_calls);
57156
57157 /* find a page to store */
57158 page = NULL;
57159 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57160 page = results[0];
57161 _debug("gang %d [%lx]", n, page->index);
57162 if (page->index > op->store_limit) {
57163 - fscache_stat(&fscache_n_store_pages_over_limit);
57164 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57165 goto superseded;
57166 }
57167
57168 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57169 spin_unlock(&cookie->stores_lock);
57170 spin_unlock(&object->lock);
57171
57172 - fscache_stat(&fscache_n_store_pages);
57173 + fscache_stat_unchecked(&fscache_n_store_pages);
57174 fscache_stat(&fscache_n_cop_write_page);
57175 ret = object->cache->ops->write_page(op, page);
57176 fscache_stat_d(&fscache_n_cop_write_page);
57177 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57178 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57179 ASSERT(PageFsCache(page));
57180
57181 - fscache_stat(&fscache_n_stores);
57182 + fscache_stat_unchecked(&fscache_n_stores);
57183
57184 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57185 _leave(" = -ENOBUFS [invalidating]");
57186 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57187 spin_unlock(&cookie->stores_lock);
57188 spin_unlock(&object->lock);
57189
57190 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
57191 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57192 op->store_limit = object->store_limit;
57193
57194 atomic_inc(&cookie->n_active);
57195 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57196
57197 spin_unlock(&cookie->lock);
57198 radix_tree_preload_end();
57199 - fscache_stat(&fscache_n_store_ops);
57200 - fscache_stat(&fscache_n_stores_ok);
57201 + fscache_stat_unchecked(&fscache_n_store_ops);
57202 + fscache_stat_unchecked(&fscache_n_stores_ok);
57203
57204 /* the work queue now carries its own ref on the object */
57205 fscache_put_operation(&op->op);
57206 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57207 return 0;
57208
57209 already_queued:
57210 - fscache_stat(&fscache_n_stores_again);
57211 + fscache_stat_unchecked(&fscache_n_stores_again);
57212 already_pending:
57213 spin_unlock(&cookie->stores_lock);
57214 spin_unlock(&object->lock);
57215 spin_unlock(&cookie->lock);
57216 radix_tree_preload_end();
57217 kfree(op);
57218 - fscache_stat(&fscache_n_stores_ok);
57219 + fscache_stat_unchecked(&fscache_n_stores_ok);
57220 _leave(" = 0");
57221 return 0;
57222
57223 @@ -999,14 +999,14 @@ nobufs:
57224 spin_unlock(&cookie->lock);
57225 radix_tree_preload_end();
57226 kfree(op);
57227 - fscache_stat(&fscache_n_stores_nobufs);
57228 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
57229 _leave(" = -ENOBUFS");
57230 return -ENOBUFS;
57231
57232 nomem_free:
57233 kfree(op);
57234 nomem:
57235 - fscache_stat(&fscache_n_stores_oom);
57236 + fscache_stat_unchecked(&fscache_n_stores_oom);
57237 _leave(" = -ENOMEM");
57238 return -ENOMEM;
57239 }
57240 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
57241 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57242 ASSERTCMP(page, !=, NULL);
57243
57244 - fscache_stat(&fscache_n_uncaches);
57245 + fscache_stat_unchecked(&fscache_n_uncaches);
57246
57247 /* cache withdrawal may beat us to it */
57248 if (!PageFsCache(page))
57249 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
57250 struct fscache_cookie *cookie = op->op.object->cookie;
57251
57252 #ifdef CONFIG_FSCACHE_STATS
57253 - atomic_inc(&fscache_n_marks);
57254 + atomic_inc_unchecked(&fscache_n_marks);
57255 #endif
57256
57257 _debug("- mark %p{%lx}", page, page->index);
57258 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
57259 index 40d13c7..ddf52b9 100644
57260 --- a/fs/fscache/stats.c
57261 +++ b/fs/fscache/stats.c
57262 @@ -18,99 +18,99 @@
57263 /*
57264 * operation counters
57265 */
57266 -atomic_t fscache_n_op_pend;
57267 -atomic_t fscache_n_op_run;
57268 -atomic_t fscache_n_op_enqueue;
57269 -atomic_t fscache_n_op_requeue;
57270 -atomic_t fscache_n_op_deferred_release;
57271 -atomic_t fscache_n_op_release;
57272 -atomic_t fscache_n_op_gc;
57273 -atomic_t fscache_n_op_cancelled;
57274 -atomic_t fscache_n_op_rejected;
57275 +atomic_unchecked_t fscache_n_op_pend;
57276 +atomic_unchecked_t fscache_n_op_run;
57277 +atomic_unchecked_t fscache_n_op_enqueue;
57278 +atomic_unchecked_t fscache_n_op_requeue;
57279 +atomic_unchecked_t fscache_n_op_deferred_release;
57280 +atomic_unchecked_t fscache_n_op_release;
57281 +atomic_unchecked_t fscache_n_op_gc;
57282 +atomic_unchecked_t fscache_n_op_cancelled;
57283 +atomic_unchecked_t fscache_n_op_rejected;
57284
57285 -atomic_t fscache_n_attr_changed;
57286 -atomic_t fscache_n_attr_changed_ok;
57287 -atomic_t fscache_n_attr_changed_nobufs;
57288 -atomic_t fscache_n_attr_changed_nomem;
57289 -atomic_t fscache_n_attr_changed_calls;
57290 +atomic_unchecked_t fscache_n_attr_changed;
57291 +atomic_unchecked_t fscache_n_attr_changed_ok;
57292 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
57293 +atomic_unchecked_t fscache_n_attr_changed_nomem;
57294 +atomic_unchecked_t fscache_n_attr_changed_calls;
57295
57296 -atomic_t fscache_n_allocs;
57297 -atomic_t fscache_n_allocs_ok;
57298 -atomic_t fscache_n_allocs_wait;
57299 -atomic_t fscache_n_allocs_nobufs;
57300 -atomic_t fscache_n_allocs_intr;
57301 -atomic_t fscache_n_allocs_object_dead;
57302 -atomic_t fscache_n_alloc_ops;
57303 -atomic_t fscache_n_alloc_op_waits;
57304 +atomic_unchecked_t fscache_n_allocs;
57305 +atomic_unchecked_t fscache_n_allocs_ok;
57306 +atomic_unchecked_t fscache_n_allocs_wait;
57307 +atomic_unchecked_t fscache_n_allocs_nobufs;
57308 +atomic_unchecked_t fscache_n_allocs_intr;
57309 +atomic_unchecked_t fscache_n_allocs_object_dead;
57310 +atomic_unchecked_t fscache_n_alloc_ops;
57311 +atomic_unchecked_t fscache_n_alloc_op_waits;
57312
57313 -atomic_t fscache_n_retrievals;
57314 -atomic_t fscache_n_retrievals_ok;
57315 -atomic_t fscache_n_retrievals_wait;
57316 -atomic_t fscache_n_retrievals_nodata;
57317 -atomic_t fscache_n_retrievals_nobufs;
57318 -atomic_t fscache_n_retrievals_intr;
57319 -atomic_t fscache_n_retrievals_nomem;
57320 -atomic_t fscache_n_retrievals_object_dead;
57321 -atomic_t fscache_n_retrieval_ops;
57322 -atomic_t fscache_n_retrieval_op_waits;
57323 +atomic_unchecked_t fscache_n_retrievals;
57324 +atomic_unchecked_t fscache_n_retrievals_ok;
57325 +atomic_unchecked_t fscache_n_retrievals_wait;
57326 +atomic_unchecked_t fscache_n_retrievals_nodata;
57327 +atomic_unchecked_t fscache_n_retrievals_nobufs;
57328 +atomic_unchecked_t fscache_n_retrievals_intr;
57329 +atomic_unchecked_t fscache_n_retrievals_nomem;
57330 +atomic_unchecked_t fscache_n_retrievals_object_dead;
57331 +atomic_unchecked_t fscache_n_retrieval_ops;
57332 +atomic_unchecked_t fscache_n_retrieval_op_waits;
57333
57334 -atomic_t fscache_n_stores;
57335 -atomic_t fscache_n_stores_ok;
57336 -atomic_t fscache_n_stores_again;
57337 -atomic_t fscache_n_stores_nobufs;
57338 -atomic_t fscache_n_stores_oom;
57339 -atomic_t fscache_n_store_ops;
57340 -atomic_t fscache_n_store_calls;
57341 -atomic_t fscache_n_store_pages;
57342 -atomic_t fscache_n_store_radix_deletes;
57343 -atomic_t fscache_n_store_pages_over_limit;
57344 +atomic_unchecked_t fscache_n_stores;
57345 +atomic_unchecked_t fscache_n_stores_ok;
57346 +atomic_unchecked_t fscache_n_stores_again;
57347 +atomic_unchecked_t fscache_n_stores_nobufs;
57348 +atomic_unchecked_t fscache_n_stores_oom;
57349 +atomic_unchecked_t fscache_n_store_ops;
57350 +atomic_unchecked_t fscache_n_store_calls;
57351 +atomic_unchecked_t fscache_n_store_pages;
57352 +atomic_unchecked_t fscache_n_store_radix_deletes;
57353 +atomic_unchecked_t fscache_n_store_pages_over_limit;
57354
57355 -atomic_t fscache_n_store_vmscan_not_storing;
57356 -atomic_t fscache_n_store_vmscan_gone;
57357 -atomic_t fscache_n_store_vmscan_busy;
57358 -atomic_t fscache_n_store_vmscan_cancelled;
57359 -atomic_t fscache_n_store_vmscan_wait;
57360 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57361 +atomic_unchecked_t fscache_n_store_vmscan_gone;
57362 +atomic_unchecked_t fscache_n_store_vmscan_busy;
57363 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57364 +atomic_unchecked_t fscache_n_store_vmscan_wait;
57365
57366 -atomic_t fscache_n_marks;
57367 -atomic_t fscache_n_uncaches;
57368 +atomic_unchecked_t fscache_n_marks;
57369 +atomic_unchecked_t fscache_n_uncaches;
57370
57371 -atomic_t fscache_n_acquires;
57372 -atomic_t fscache_n_acquires_null;
57373 -atomic_t fscache_n_acquires_no_cache;
57374 -atomic_t fscache_n_acquires_ok;
57375 -atomic_t fscache_n_acquires_nobufs;
57376 -atomic_t fscache_n_acquires_oom;
57377 +atomic_unchecked_t fscache_n_acquires;
57378 +atomic_unchecked_t fscache_n_acquires_null;
57379 +atomic_unchecked_t fscache_n_acquires_no_cache;
57380 +atomic_unchecked_t fscache_n_acquires_ok;
57381 +atomic_unchecked_t fscache_n_acquires_nobufs;
57382 +atomic_unchecked_t fscache_n_acquires_oom;
57383
57384 -atomic_t fscache_n_invalidates;
57385 -atomic_t fscache_n_invalidates_run;
57386 +atomic_unchecked_t fscache_n_invalidates;
57387 +atomic_unchecked_t fscache_n_invalidates_run;
57388
57389 -atomic_t fscache_n_updates;
57390 -atomic_t fscache_n_updates_null;
57391 -atomic_t fscache_n_updates_run;
57392 +atomic_unchecked_t fscache_n_updates;
57393 +atomic_unchecked_t fscache_n_updates_null;
57394 +atomic_unchecked_t fscache_n_updates_run;
57395
57396 -atomic_t fscache_n_relinquishes;
57397 -atomic_t fscache_n_relinquishes_null;
57398 -atomic_t fscache_n_relinquishes_waitcrt;
57399 -atomic_t fscache_n_relinquishes_retire;
57400 +atomic_unchecked_t fscache_n_relinquishes;
57401 +atomic_unchecked_t fscache_n_relinquishes_null;
57402 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57403 +atomic_unchecked_t fscache_n_relinquishes_retire;
57404
57405 -atomic_t fscache_n_cookie_index;
57406 -atomic_t fscache_n_cookie_data;
57407 -atomic_t fscache_n_cookie_special;
57408 +atomic_unchecked_t fscache_n_cookie_index;
57409 +atomic_unchecked_t fscache_n_cookie_data;
57410 +atomic_unchecked_t fscache_n_cookie_special;
57411
57412 -atomic_t fscache_n_object_alloc;
57413 -atomic_t fscache_n_object_no_alloc;
57414 -atomic_t fscache_n_object_lookups;
57415 -atomic_t fscache_n_object_lookups_negative;
57416 -atomic_t fscache_n_object_lookups_positive;
57417 -atomic_t fscache_n_object_lookups_timed_out;
57418 -atomic_t fscache_n_object_created;
57419 -atomic_t fscache_n_object_avail;
57420 -atomic_t fscache_n_object_dead;
57421 +atomic_unchecked_t fscache_n_object_alloc;
57422 +atomic_unchecked_t fscache_n_object_no_alloc;
57423 +atomic_unchecked_t fscache_n_object_lookups;
57424 +atomic_unchecked_t fscache_n_object_lookups_negative;
57425 +atomic_unchecked_t fscache_n_object_lookups_positive;
57426 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
57427 +atomic_unchecked_t fscache_n_object_created;
57428 +atomic_unchecked_t fscache_n_object_avail;
57429 +atomic_unchecked_t fscache_n_object_dead;
57430
57431 -atomic_t fscache_n_checkaux_none;
57432 -atomic_t fscache_n_checkaux_okay;
57433 -atomic_t fscache_n_checkaux_update;
57434 -atomic_t fscache_n_checkaux_obsolete;
57435 +atomic_unchecked_t fscache_n_checkaux_none;
57436 +atomic_unchecked_t fscache_n_checkaux_okay;
57437 +atomic_unchecked_t fscache_n_checkaux_update;
57438 +atomic_unchecked_t fscache_n_checkaux_obsolete;
57439
57440 atomic_t fscache_n_cop_alloc_object;
57441 atomic_t fscache_n_cop_lookup_object;
57442 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57443 seq_puts(m, "FS-Cache statistics\n");
57444
57445 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57446 - atomic_read(&fscache_n_cookie_index),
57447 - atomic_read(&fscache_n_cookie_data),
57448 - atomic_read(&fscache_n_cookie_special));
57449 + atomic_read_unchecked(&fscache_n_cookie_index),
57450 + atomic_read_unchecked(&fscache_n_cookie_data),
57451 + atomic_read_unchecked(&fscache_n_cookie_special));
57452
57453 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57454 - atomic_read(&fscache_n_object_alloc),
57455 - atomic_read(&fscache_n_object_no_alloc),
57456 - atomic_read(&fscache_n_object_avail),
57457 - atomic_read(&fscache_n_object_dead));
57458 + atomic_read_unchecked(&fscache_n_object_alloc),
57459 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57460 + atomic_read_unchecked(&fscache_n_object_avail),
57461 + atomic_read_unchecked(&fscache_n_object_dead));
57462 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57463 - atomic_read(&fscache_n_checkaux_none),
57464 - atomic_read(&fscache_n_checkaux_okay),
57465 - atomic_read(&fscache_n_checkaux_update),
57466 - atomic_read(&fscache_n_checkaux_obsolete));
57467 + atomic_read_unchecked(&fscache_n_checkaux_none),
57468 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57469 + atomic_read_unchecked(&fscache_n_checkaux_update),
57470 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57471
57472 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57473 - atomic_read(&fscache_n_marks),
57474 - atomic_read(&fscache_n_uncaches));
57475 + atomic_read_unchecked(&fscache_n_marks),
57476 + atomic_read_unchecked(&fscache_n_uncaches));
57477
57478 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57479 " oom=%u\n",
57480 - atomic_read(&fscache_n_acquires),
57481 - atomic_read(&fscache_n_acquires_null),
57482 - atomic_read(&fscache_n_acquires_no_cache),
57483 - atomic_read(&fscache_n_acquires_ok),
57484 - atomic_read(&fscache_n_acquires_nobufs),
57485 - atomic_read(&fscache_n_acquires_oom));
57486 + atomic_read_unchecked(&fscache_n_acquires),
57487 + atomic_read_unchecked(&fscache_n_acquires_null),
57488 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57489 + atomic_read_unchecked(&fscache_n_acquires_ok),
57490 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57491 + atomic_read_unchecked(&fscache_n_acquires_oom));
57492
57493 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57494 - atomic_read(&fscache_n_object_lookups),
57495 - atomic_read(&fscache_n_object_lookups_negative),
57496 - atomic_read(&fscache_n_object_lookups_positive),
57497 - atomic_read(&fscache_n_object_created),
57498 - atomic_read(&fscache_n_object_lookups_timed_out));
57499 + atomic_read_unchecked(&fscache_n_object_lookups),
57500 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57501 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57502 + atomic_read_unchecked(&fscache_n_object_created),
57503 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57504
57505 seq_printf(m, "Invals : n=%u run=%u\n",
57506 - atomic_read(&fscache_n_invalidates),
57507 - atomic_read(&fscache_n_invalidates_run));
57508 + atomic_read_unchecked(&fscache_n_invalidates),
57509 + atomic_read_unchecked(&fscache_n_invalidates_run));
57510
57511 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57512 - atomic_read(&fscache_n_updates),
57513 - atomic_read(&fscache_n_updates_null),
57514 - atomic_read(&fscache_n_updates_run));
57515 + atomic_read_unchecked(&fscache_n_updates),
57516 + atomic_read_unchecked(&fscache_n_updates_null),
57517 + atomic_read_unchecked(&fscache_n_updates_run));
57518
57519 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57520 - atomic_read(&fscache_n_relinquishes),
57521 - atomic_read(&fscache_n_relinquishes_null),
57522 - atomic_read(&fscache_n_relinquishes_waitcrt),
57523 - atomic_read(&fscache_n_relinquishes_retire));
57524 + atomic_read_unchecked(&fscache_n_relinquishes),
57525 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57526 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57527 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57528
57529 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57530 - atomic_read(&fscache_n_attr_changed),
57531 - atomic_read(&fscache_n_attr_changed_ok),
57532 - atomic_read(&fscache_n_attr_changed_nobufs),
57533 - atomic_read(&fscache_n_attr_changed_nomem),
57534 - atomic_read(&fscache_n_attr_changed_calls));
57535 + atomic_read_unchecked(&fscache_n_attr_changed),
57536 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57537 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57538 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57539 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57540
57541 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57542 - atomic_read(&fscache_n_allocs),
57543 - atomic_read(&fscache_n_allocs_ok),
57544 - atomic_read(&fscache_n_allocs_wait),
57545 - atomic_read(&fscache_n_allocs_nobufs),
57546 - atomic_read(&fscache_n_allocs_intr));
57547 + atomic_read_unchecked(&fscache_n_allocs),
57548 + atomic_read_unchecked(&fscache_n_allocs_ok),
57549 + atomic_read_unchecked(&fscache_n_allocs_wait),
57550 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57551 + atomic_read_unchecked(&fscache_n_allocs_intr));
57552 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57553 - atomic_read(&fscache_n_alloc_ops),
57554 - atomic_read(&fscache_n_alloc_op_waits),
57555 - atomic_read(&fscache_n_allocs_object_dead));
57556 + atomic_read_unchecked(&fscache_n_alloc_ops),
57557 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57558 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57559
57560 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57561 " int=%u oom=%u\n",
57562 - atomic_read(&fscache_n_retrievals),
57563 - atomic_read(&fscache_n_retrievals_ok),
57564 - atomic_read(&fscache_n_retrievals_wait),
57565 - atomic_read(&fscache_n_retrievals_nodata),
57566 - atomic_read(&fscache_n_retrievals_nobufs),
57567 - atomic_read(&fscache_n_retrievals_intr),
57568 - atomic_read(&fscache_n_retrievals_nomem));
57569 + atomic_read_unchecked(&fscache_n_retrievals),
57570 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57571 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57572 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57573 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57574 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57575 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57576 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57577 - atomic_read(&fscache_n_retrieval_ops),
57578 - atomic_read(&fscache_n_retrieval_op_waits),
57579 - atomic_read(&fscache_n_retrievals_object_dead));
57580 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57581 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57582 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57583
57584 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57585 - atomic_read(&fscache_n_stores),
57586 - atomic_read(&fscache_n_stores_ok),
57587 - atomic_read(&fscache_n_stores_again),
57588 - atomic_read(&fscache_n_stores_nobufs),
57589 - atomic_read(&fscache_n_stores_oom));
57590 + atomic_read_unchecked(&fscache_n_stores),
57591 + atomic_read_unchecked(&fscache_n_stores_ok),
57592 + atomic_read_unchecked(&fscache_n_stores_again),
57593 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57594 + atomic_read_unchecked(&fscache_n_stores_oom));
57595 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57596 - atomic_read(&fscache_n_store_ops),
57597 - atomic_read(&fscache_n_store_calls),
57598 - atomic_read(&fscache_n_store_pages),
57599 - atomic_read(&fscache_n_store_radix_deletes),
57600 - atomic_read(&fscache_n_store_pages_over_limit));
57601 + atomic_read_unchecked(&fscache_n_store_ops),
57602 + atomic_read_unchecked(&fscache_n_store_calls),
57603 + atomic_read_unchecked(&fscache_n_store_pages),
57604 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57605 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57606
57607 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57608 - atomic_read(&fscache_n_store_vmscan_not_storing),
57609 - atomic_read(&fscache_n_store_vmscan_gone),
57610 - atomic_read(&fscache_n_store_vmscan_busy),
57611 - atomic_read(&fscache_n_store_vmscan_cancelled),
57612 - atomic_read(&fscache_n_store_vmscan_wait));
57613 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57614 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57615 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57616 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57617 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57618
57619 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57620 - atomic_read(&fscache_n_op_pend),
57621 - atomic_read(&fscache_n_op_run),
57622 - atomic_read(&fscache_n_op_enqueue),
57623 - atomic_read(&fscache_n_op_cancelled),
57624 - atomic_read(&fscache_n_op_rejected));
57625 + atomic_read_unchecked(&fscache_n_op_pend),
57626 + atomic_read_unchecked(&fscache_n_op_run),
57627 + atomic_read_unchecked(&fscache_n_op_enqueue),
57628 + atomic_read_unchecked(&fscache_n_op_cancelled),
57629 + atomic_read_unchecked(&fscache_n_op_rejected));
57630 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57631 - atomic_read(&fscache_n_op_deferred_release),
57632 - atomic_read(&fscache_n_op_release),
57633 - atomic_read(&fscache_n_op_gc));
57634 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57635 + atomic_read_unchecked(&fscache_n_op_release),
57636 + atomic_read_unchecked(&fscache_n_op_gc));
57637
57638 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57639 atomic_read(&fscache_n_cop_alloc_object),
57640 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57641 index adbfd66..4b25822 100644
57642 --- a/fs/fuse/cuse.c
57643 +++ b/fs/fuse/cuse.c
57644 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
57645 INIT_LIST_HEAD(&cuse_conntbl[i]);
57646
57647 /* inherit and extend fuse_dev_operations */
57648 - cuse_channel_fops = fuse_dev_operations;
57649 - cuse_channel_fops.owner = THIS_MODULE;
57650 - cuse_channel_fops.open = cuse_channel_open;
57651 - cuse_channel_fops.release = cuse_channel_release;
57652 + pax_open_kernel();
57653 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57654 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57655 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57656 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57657 + pax_close_kernel();
57658
57659 cuse_class = class_create(THIS_MODULE, "cuse");
57660 if (IS_ERR(cuse_class))
57661 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57662 index ef74ad5..c9ac759e 100644
57663 --- a/fs/fuse/dev.c
57664 +++ b/fs/fuse/dev.c
57665 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57666 ret = 0;
57667 pipe_lock(pipe);
57668
57669 - if (!pipe->readers) {
57670 + if (!atomic_read(&pipe->readers)) {
57671 send_sig(SIGPIPE, current, 0);
57672 if (!ret)
57673 ret = -EPIPE;
57674 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57675 page_nr++;
57676 ret += buf->len;
57677
57678 - if (pipe->files)
57679 + if (atomic_read(&pipe->files))
57680 do_wakeup = 1;
57681 }
57682
57683 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57684 index b7989f2..1f72ec4 100644
57685 --- a/fs/fuse/dir.c
57686 +++ b/fs/fuse/dir.c
57687 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
57688 return link;
57689 }
57690
57691 -static void free_link(char *link)
57692 +static void free_link(const char *link)
57693 {
57694 if (!IS_ERR(link))
57695 free_page((unsigned long) link);
57696 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57697 index ced3257..b5c3b942 100644
57698 --- a/fs/gfs2/inode.c
57699 +++ b/fs/gfs2/inode.c
57700 @@ -1508,7 +1508,7 @@ out:
57701
57702 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57703 {
57704 - char *s = nd_get_link(nd);
57705 + const char *s = nd_get_link(nd);
57706 if (!IS_ERR(s))
57707 kfree(s);
57708 }
57709 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
57710 index 2543728..14d7bd4 100644
57711 --- a/fs/hostfs/hostfs_kern.c
57712 +++ b/fs/hostfs/hostfs_kern.c
57713 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
57714
57715 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
57716 {
57717 - char *s = nd_get_link(nd);
57718 + const char *s = nd_get_link(nd);
57719 if (!IS_ERR(s))
57720 __putname(s);
57721 }
57722 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57723 index d19b30a..ef89c36 100644
57724 --- a/fs/hugetlbfs/inode.c
57725 +++ b/fs/hugetlbfs/inode.c
57726 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57727 struct mm_struct *mm = current->mm;
57728 struct vm_area_struct *vma;
57729 struct hstate *h = hstate_file(file);
57730 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57731 struct vm_unmapped_area_info info;
57732
57733 if (len & ~huge_page_mask(h))
57734 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57735 return addr;
57736 }
57737
57738 +#ifdef CONFIG_PAX_RANDMMAP
57739 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57740 +#endif
57741 +
57742 if (addr) {
57743 addr = ALIGN(addr, huge_page_size(h));
57744 vma = find_vma(mm, addr);
57745 - if (TASK_SIZE - len >= addr &&
57746 - (!vma || addr + len <= vma->vm_start))
57747 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57748 return addr;
57749 }
57750
57751 info.flags = 0;
57752 info.length = len;
57753 info.low_limit = TASK_UNMAPPED_BASE;
57754 +
57755 +#ifdef CONFIG_PAX_RANDMMAP
57756 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57757 + info.low_limit += mm->delta_mmap;
57758 +#endif
57759 +
57760 info.high_limit = TASK_SIZE;
57761 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57762 info.align_offset = 0;
57763 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57764 };
57765 MODULE_ALIAS_FS("hugetlbfs");
57766
57767 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57768 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57769
57770 static int can_do_hugetlb_shm(void)
57771 {
57772 diff --git a/fs/inode.c b/fs/inode.c
57773 index b33ba8e..3c79a47 100644
57774 --- a/fs/inode.c
57775 +++ b/fs/inode.c
57776 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
57777
57778 #ifdef CONFIG_SMP
57779 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57780 - static atomic_t shared_last_ino;
57781 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57782 + static atomic_unchecked_t shared_last_ino;
57783 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57784
57785 res = next - LAST_INO_BATCH;
57786 }
57787 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57788 index 4a6cf28..d3a29d3 100644
57789 --- a/fs/jffs2/erase.c
57790 +++ b/fs/jffs2/erase.c
57791 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57792 struct jffs2_unknown_node marker = {
57793 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57794 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57795 - .totlen = cpu_to_je32(c->cleanmarker_size)
57796 + .totlen = cpu_to_je32(c->cleanmarker_size),
57797 + .hdr_crc = cpu_to_je32(0)
57798 };
57799
57800 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57801 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57802 index a6597d6..41b30ec 100644
57803 --- a/fs/jffs2/wbuf.c
57804 +++ b/fs/jffs2/wbuf.c
57805 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57806 {
57807 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57808 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57809 - .totlen = constant_cpu_to_je32(8)
57810 + .totlen = constant_cpu_to_je32(8),
57811 + .hdr_crc = constant_cpu_to_je32(0)
57812 };
57813
57814 /*
57815 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57816 index 6669aa2..36b033d 100644
57817 --- a/fs/jfs/super.c
57818 +++ b/fs/jfs/super.c
57819 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57820
57821 jfs_inode_cachep =
57822 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57823 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57824 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57825 init_once);
57826 if (jfs_inode_cachep == NULL)
57827 return -ENOMEM;
57828 diff --git a/fs/libfs.c b/fs/libfs.c
57829 index 3a3a9b5..3a9b074 100644
57830 --- a/fs/libfs.c
57831 +++ b/fs/libfs.c
57832 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57833
57834 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57835 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57836 + char d_name[sizeof(next->d_iname)];
57837 + const unsigned char *name;
57838 +
57839 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57840 if (!simple_positive(next)) {
57841 spin_unlock(&next->d_lock);
57842 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57843
57844 spin_unlock(&next->d_lock);
57845 spin_unlock(&dentry->d_lock);
57846 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57847 + name = next->d_name.name;
57848 + if (name == next->d_iname) {
57849 + memcpy(d_name, name, next->d_name.len);
57850 + name = d_name;
57851 + }
57852 + if (!dir_emit(ctx, name, next->d_name.len,
57853 next->d_inode->i_ino, dt_type(next->d_inode)))
57854 return 0;
57855 spin_lock(&dentry->d_lock);
57856 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57857 index acd3947..1f896e2 100644
57858 --- a/fs/lockd/clntproc.c
57859 +++ b/fs/lockd/clntproc.c
57860 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57861 /*
57862 * Cookie counter for NLM requests
57863 */
57864 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57865 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57866
57867 void nlmclnt_next_cookie(struct nlm_cookie *c)
57868 {
57869 - u32 cookie = atomic_inc_return(&nlm_cookie);
57870 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57871
57872 memcpy(c->data, &cookie, 4);
57873 c->len=4;
57874 diff --git a/fs/locks.c b/fs/locks.c
57875 index b27a300..4156d0b 100644
57876 --- a/fs/locks.c
57877 +++ b/fs/locks.c
57878 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57879 return;
57880
57881 if (filp->f_op && filp->f_op->flock) {
57882 - struct file_lock fl = {
57883 + struct file_lock flock = {
57884 .fl_pid = current->tgid,
57885 .fl_file = filp,
57886 .fl_flags = FL_FLOCK,
57887 .fl_type = F_UNLCK,
57888 .fl_end = OFFSET_MAX,
57889 };
57890 - filp->f_op->flock(filp, F_SETLKW, &fl);
57891 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57892 - fl.fl_ops->fl_release_private(&fl);
57893 + filp->f_op->flock(filp, F_SETLKW, &flock);
57894 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57895 + flock.fl_ops->fl_release_private(&flock);
57896 }
57897
57898 spin_lock(&inode->i_lock);
57899 diff --git a/fs/namei.c b/fs/namei.c
57900 index caa2805..c9d3edc 100644
57901 --- a/fs/namei.c
57902 +++ b/fs/namei.c
57903 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57904 if (ret != -EACCES)
57905 return ret;
57906
57907 +#ifdef CONFIG_GRKERNSEC
57908 + /* we'll block if we have to log due to a denied capability use */
57909 + if (mask & MAY_NOT_BLOCK)
57910 + return -ECHILD;
57911 +#endif
57912 +
57913 if (S_ISDIR(inode->i_mode)) {
57914 /* DACs are overridable for directories */
57915 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57916 - return 0;
57917 if (!(mask & MAY_WRITE))
57918 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57919 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57920 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57921 return 0;
57922 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57923 + return 0;
57924 return -EACCES;
57925 }
57926 /*
57927 + * Searching includes executable on directories, else just read.
57928 + */
57929 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57930 + if (mask == MAY_READ)
57931 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57932 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57933 + return 0;
57934 +
57935 + /*
57936 * Read/write DACs are always overridable.
57937 * Executable DACs are overridable when there is
57938 * at least one exec bit set.
57939 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57940 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57941 return 0;
57942
57943 - /*
57944 - * Searching includes executable on directories, else just read.
57945 - */
57946 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57947 - if (mask == MAY_READ)
57948 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57949 - return 0;
57950 -
57951 return -EACCES;
57952 }
57953
57954 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57955 {
57956 struct dentry *dentry = link->dentry;
57957 int error;
57958 - char *s;
57959 + const char *s;
57960
57961 BUG_ON(nd->flags & LOOKUP_RCU);
57962
57963 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57964 if (error)
57965 goto out_put_nd_path;
57966
57967 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57968 + dentry->d_inode, dentry, nd->path.mnt)) {
57969 + error = -EACCES;
57970 + goto out_put_nd_path;
57971 + }
57972 +
57973 nd->last_type = LAST_BIND;
57974 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57975 error = PTR_ERR(*p);
57976 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57977 if (res)
57978 break;
57979 res = walk_component(nd, path, LOOKUP_FOLLOW);
57980 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57981 + res = -EACCES;
57982 put_link(nd, &link, cookie);
57983 } while (res > 0);
57984
57985 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
57986 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57987 {
57988 unsigned long a, b, adata, bdata, mask, hash, len;
57989 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57990 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57991
57992 hash = a = 0;
57993 len = -sizeof(unsigned long);
57994 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
57995 if (err)
57996 break;
57997 err = lookup_last(nd, &path);
57998 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57999 + err = -EACCES;
58000 put_link(nd, &link, cookie);
58001 }
58002 }
58003 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
58004 if (!err)
58005 err = complete_walk(nd);
58006
58007 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58008 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58009 + path_put(&nd->path);
58010 + err = -ENOENT;
58011 + }
58012 + }
58013 +
58014 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58015 if (!can_lookup(nd->inode)) {
58016 path_put(&nd->path);
58017 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
58018 retval = path_lookupat(dfd, name->name,
58019 flags | LOOKUP_REVAL, nd);
58020
58021 - if (likely(!retval))
58022 + if (likely(!retval)) {
58023 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58024 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58025 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58026 + path_put(&nd->path);
58027 + return -ENOENT;
58028 + }
58029 + }
58030 + }
58031 return retval;
58032 }
58033
58034 @@ -2586,6 +2618,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58035 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58036 return -EPERM;
58037
58038 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58039 + return -EPERM;
58040 + if (gr_handle_rawio(inode))
58041 + return -EPERM;
58042 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58043 + return -EACCES;
58044 +
58045 return 0;
58046 }
58047
58048 @@ -2817,7 +2856,7 @@ looked_up:
58049 * cleared otherwise prior to returning.
58050 */
58051 static int lookup_open(struct nameidata *nd, struct path *path,
58052 - struct file *file,
58053 + struct path *link, struct file *file,
58054 const struct open_flags *op,
58055 bool got_write, int *opened)
58056 {
58057 @@ -2852,6 +2891,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58058 /* Negative dentry, just create the file */
58059 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58060 umode_t mode = op->mode;
58061 +
58062 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58063 + error = -EACCES;
58064 + goto out_dput;
58065 + }
58066 +
58067 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58068 + error = -EACCES;
58069 + goto out_dput;
58070 + }
58071 +
58072 if (!IS_POSIXACL(dir->d_inode))
58073 mode &= ~current_umask();
58074 /*
58075 @@ -2873,6 +2923,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58076 nd->flags & LOOKUP_EXCL);
58077 if (error)
58078 goto out_dput;
58079 + else
58080 + gr_handle_create(dentry, nd->path.mnt);
58081 }
58082 out_no_open:
58083 path->dentry = dentry;
58084 @@ -2887,7 +2939,7 @@ out_dput:
58085 /*
58086 * Handle the last step of open()
58087 */
58088 -static int do_last(struct nameidata *nd, struct path *path,
58089 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58090 struct file *file, const struct open_flags *op,
58091 int *opened, struct filename *name)
58092 {
58093 @@ -2937,6 +2989,15 @@ static int do_last(struct nameidata *nd, struct path *path,
58094 if (error)
58095 return error;
58096
58097 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58098 + error = -ENOENT;
58099 + goto out;
58100 + }
58101 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58102 + error = -EACCES;
58103 + goto out;
58104 + }
58105 +
58106 audit_inode(name, dir, LOOKUP_PARENT);
58107 error = -EISDIR;
58108 /* trailing slashes? */
58109 @@ -2956,7 +3017,7 @@ retry_lookup:
58110 */
58111 }
58112 mutex_lock(&dir->d_inode->i_mutex);
58113 - error = lookup_open(nd, path, file, op, got_write, opened);
58114 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58115 mutex_unlock(&dir->d_inode->i_mutex);
58116
58117 if (error <= 0) {
58118 @@ -2980,11 +3041,28 @@ retry_lookup:
58119 goto finish_open_created;
58120 }
58121
58122 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58123 + error = -ENOENT;
58124 + goto exit_dput;
58125 + }
58126 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58127 + error = -EACCES;
58128 + goto exit_dput;
58129 + }
58130 +
58131 /*
58132 * create/update audit record if it already exists.
58133 */
58134 - if (path->dentry->d_inode)
58135 + if (path->dentry->d_inode) {
58136 + /* only check if O_CREAT is specified, all other checks need to go
58137 + into may_open */
58138 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58139 + error = -EACCES;
58140 + goto exit_dput;
58141 + }
58142 +
58143 audit_inode(name, path->dentry, 0);
58144 + }
58145
58146 /*
58147 * If atomic_open() acquired write access it is dropped now due to
58148 @@ -3025,6 +3103,11 @@ finish_lookup:
58149 }
58150 }
58151 BUG_ON(inode != path->dentry->d_inode);
58152 + /* if we're resolving a symlink to another symlink */
58153 + if (link && gr_handle_symlink_owner(link, inode)) {
58154 + error = -EACCES;
58155 + goto out;
58156 + }
58157 return 1;
58158 }
58159
58160 @@ -3034,7 +3117,6 @@ finish_lookup:
58161 save_parent.dentry = nd->path.dentry;
58162 save_parent.mnt = mntget(path->mnt);
58163 nd->path.dentry = path->dentry;
58164 -
58165 }
58166 nd->inode = inode;
58167 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58168 @@ -3044,7 +3126,18 @@ finish_open:
58169 path_put(&save_parent);
58170 return error;
58171 }
58172 +
58173 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58174 + error = -ENOENT;
58175 + goto out;
58176 + }
58177 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58178 + error = -EACCES;
58179 + goto out;
58180 + }
58181 +
58182 audit_inode(name, nd->path.dentry, 0);
58183 +
58184 error = -EISDIR;
58185 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58186 goto out;
58187 @@ -3207,7 +3300,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58188 if (unlikely(error))
58189 goto out;
58190
58191 - error = do_last(nd, &path, file, op, &opened, pathname);
58192 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
58193 while (unlikely(error > 0)) { /* trailing symlink */
58194 struct path link = path;
58195 void *cookie;
58196 @@ -3225,7 +3318,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58197 error = follow_link(&link, nd, &cookie);
58198 if (unlikely(error))
58199 break;
58200 - error = do_last(nd, &path, file, op, &opened, pathname);
58201 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
58202 put_link(nd, &link, cookie);
58203 }
58204 out:
58205 @@ -3325,8 +3418,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
58206 goto unlock;
58207
58208 error = -EEXIST;
58209 - if (dentry->d_inode)
58210 + if (dentry->d_inode) {
58211 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
58212 + error = -ENOENT;
58213 + }
58214 goto fail;
58215 + }
58216 /*
58217 * Special case - lookup gave negative, but... we had foo/bar/
58218 * From the vfs_mknod() POV we just have a negative dentry -
58219 @@ -3378,6 +3475,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
58220 }
58221 EXPORT_SYMBOL(user_path_create);
58222
58223 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
58224 +{
58225 + struct filename *tmp = getname(pathname);
58226 + struct dentry *res;
58227 + if (IS_ERR(tmp))
58228 + return ERR_CAST(tmp);
58229 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
58230 + if (IS_ERR(res))
58231 + putname(tmp);
58232 + else
58233 + *to = tmp;
58234 + return res;
58235 +}
58236 +
58237 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
58238 {
58239 int error = may_create(dir, dentry);
58240 @@ -3440,6 +3551,17 @@ retry:
58241
58242 if (!IS_POSIXACL(path.dentry->d_inode))
58243 mode &= ~current_umask();
58244 +
58245 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
58246 + error = -EPERM;
58247 + goto out;
58248 + }
58249 +
58250 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
58251 + error = -EACCES;
58252 + goto out;
58253 + }
58254 +
58255 error = security_path_mknod(&path, dentry, mode, dev);
58256 if (error)
58257 goto out;
58258 @@ -3456,6 +3578,8 @@ retry:
58259 break;
58260 }
58261 out:
58262 + if (!error)
58263 + gr_handle_create(dentry, path.mnt);
58264 done_path_create(&path, dentry);
58265 if (retry_estale(error, lookup_flags)) {
58266 lookup_flags |= LOOKUP_REVAL;
58267 @@ -3508,9 +3632,16 @@ retry:
58268
58269 if (!IS_POSIXACL(path.dentry->d_inode))
58270 mode &= ~current_umask();
58271 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
58272 + error = -EACCES;
58273 + goto out;
58274 + }
58275 error = security_path_mkdir(&path, dentry, mode);
58276 if (!error)
58277 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
58278 + if (!error)
58279 + gr_handle_create(dentry, path.mnt);
58280 +out:
58281 done_path_create(&path, dentry);
58282 if (retry_estale(error, lookup_flags)) {
58283 lookup_flags |= LOOKUP_REVAL;
58284 @@ -3591,6 +3722,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
58285 struct filename *name;
58286 struct dentry *dentry;
58287 struct nameidata nd;
58288 + ino_t saved_ino = 0;
58289 + dev_t saved_dev = 0;
58290 unsigned int lookup_flags = 0;
58291 retry:
58292 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58293 @@ -3623,10 +3756,21 @@ retry:
58294 error = -ENOENT;
58295 goto exit3;
58296 }
58297 +
58298 + saved_ino = dentry->d_inode->i_ino;
58299 + saved_dev = gr_get_dev_from_dentry(dentry);
58300 +
58301 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
58302 + error = -EACCES;
58303 + goto exit3;
58304 + }
58305 +
58306 error = security_path_rmdir(&nd.path, dentry);
58307 if (error)
58308 goto exit3;
58309 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
58310 + if (!error && (saved_dev || saved_ino))
58311 + gr_handle_delete(saved_ino, saved_dev);
58312 exit3:
58313 dput(dentry);
58314 exit2:
58315 @@ -3692,6 +3836,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
58316 struct dentry *dentry;
58317 struct nameidata nd;
58318 struct inode *inode = NULL;
58319 + ino_t saved_ino = 0;
58320 + dev_t saved_dev = 0;
58321 unsigned int lookup_flags = 0;
58322 retry:
58323 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58324 @@ -3718,10 +3864,22 @@ retry:
58325 if (!inode)
58326 goto slashes;
58327 ihold(inode);
58328 +
58329 + if (inode->i_nlink <= 1) {
58330 + saved_ino = inode->i_ino;
58331 + saved_dev = gr_get_dev_from_dentry(dentry);
58332 + }
58333 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
58334 + error = -EACCES;
58335 + goto exit2;
58336 + }
58337 +
58338 error = security_path_unlink(&nd.path, dentry);
58339 if (error)
58340 goto exit2;
58341 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
58342 + if (!error && (saved_ino || saved_dev))
58343 + gr_handle_delete(saved_ino, saved_dev);
58344 exit2:
58345 dput(dentry);
58346 }
58347 @@ -3799,9 +3957,17 @@ retry:
58348 if (IS_ERR(dentry))
58349 goto out_putname;
58350
58351 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
58352 + error = -EACCES;
58353 + goto out;
58354 + }
58355 +
58356 error = security_path_symlink(&path, dentry, from->name);
58357 if (!error)
58358 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
58359 + if (!error)
58360 + gr_handle_create(dentry, path.mnt);
58361 +out:
58362 done_path_create(&path, dentry);
58363 if (retry_estale(error, lookup_flags)) {
58364 lookup_flags |= LOOKUP_REVAL;
58365 @@ -3881,6 +4047,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
58366 {
58367 struct dentry *new_dentry;
58368 struct path old_path, new_path;
58369 + struct filename *to = NULL;
58370 int how = 0;
58371 int error;
58372
58373 @@ -3904,7 +4071,7 @@ retry:
58374 if (error)
58375 return error;
58376
58377 - new_dentry = user_path_create(newdfd, newname, &new_path,
58378 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
58379 (how & LOOKUP_REVAL));
58380 error = PTR_ERR(new_dentry);
58381 if (IS_ERR(new_dentry))
58382 @@ -3916,11 +4083,28 @@ retry:
58383 error = may_linkat(&old_path);
58384 if (unlikely(error))
58385 goto out_dput;
58386 +
58387 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
58388 + old_path.dentry->d_inode,
58389 + old_path.dentry->d_inode->i_mode, to)) {
58390 + error = -EACCES;
58391 + goto out_dput;
58392 + }
58393 +
58394 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58395 + old_path.dentry, old_path.mnt, to)) {
58396 + error = -EACCES;
58397 + goto out_dput;
58398 + }
58399 +
58400 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58401 if (error)
58402 goto out_dput;
58403 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58404 + if (!error)
58405 + gr_handle_create(new_dentry, new_path.mnt);
58406 out_dput:
58407 + putname(to);
58408 done_path_create(&new_path, new_dentry);
58409 if (retry_estale(error, how)) {
58410 how |= LOOKUP_REVAL;
58411 @@ -4166,12 +4350,21 @@ retry:
58412 if (new_dentry == trap)
58413 goto exit5;
58414
58415 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
58416 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
58417 + to);
58418 + if (error)
58419 + goto exit5;
58420 +
58421 error = security_path_rename(&oldnd.path, old_dentry,
58422 &newnd.path, new_dentry);
58423 if (error)
58424 goto exit5;
58425 error = vfs_rename(old_dir->d_inode, old_dentry,
58426 new_dir->d_inode, new_dentry);
58427 + if (!error)
58428 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
58429 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
58430 exit5:
58431 dput(new_dentry);
58432 exit4:
58433 @@ -4203,6 +4396,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
58434
58435 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
58436 {
58437 + char tmpbuf[64];
58438 + const char *newlink;
58439 int len;
58440
58441 len = PTR_ERR(link);
58442 @@ -4212,7 +4407,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
58443 len = strlen(link);
58444 if (len > (unsigned) buflen)
58445 len = buflen;
58446 - if (copy_to_user(buffer, link, len))
58447 +
58448 + if (len < sizeof(tmpbuf)) {
58449 + memcpy(tmpbuf, link, len);
58450 + newlink = tmpbuf;
58451 + } else
58452 + newlink = link;
58453 +
58454 + if (copy_to_user(buffer, newlink, len))
58455 len = -EFAULT;
58456 out:
58457 return len;
58458 diff --git a/fs/namespace.c b/fs/namespace.c
58459 index da5c494..a755a54 100644
58460 --- a/fs/namespace.c
58461 +++ b/fs/namespace.c
58462 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
58463 if (!(sb->s_flags & MS_RDONLY))
58464 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58465 up_write(&sb->s_umount);
58466 +
58467 + gr_log_remount(mnt->mnt_devname, retval);
58468 +
58469 return retval;
58470 }
58471
58472 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
58473 }
58474 br_write_unlock(&vfsmount_lock);
58475 namespace_unlock();
58476 +
58477 + gr_log_unmount(mnt->mnt_devname, retval);
58478 +
58479 return retval;
58480 }
58481
58482 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
58483 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58484 */
58485
58486 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58487 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58488 {
58489 struct path path;
58490 struct mount *mnt;
58491 @@ -1347,7 +1353,7 @@ out:
58492 /*
58493 * The 2.0 compatible umount. No flags.
58494 */
58495 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58496 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58497 {
58498 return sys_umount(name, 0);
58499 }
58500 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58501 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58502 MS_STRICTATIME);
58503
58504 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58505 + retval = -EPERM;
58506 + goto dput_out;
58507 + }
58508 +
58509 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58510 + retval = -EPERM;
58511 + goto dput_out;
58512 + }
58513 +
58514 if (flags & MS_REMOUNT)
58515 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58516 data_page);
58517 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58518 dev_name, data_page);
58519 dput_out:
58520 path_put(&path);
58521 +
58522 + gr_log_mount(dev_name, dir_name, retval);
58523 +
58524 return retval;
58525 }
58526
58527 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58528 * number incrementing at 10Ghz will take 12,427 years to wrap which
58529 * is effectively never, so we can ignore the possibility.
58530 */
58531 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58532 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58533
58534 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58535 {
58536 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58537 kfree(new_ns);
58538 return ERR_PTR(ret);
58539 }
58540 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58541 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58542 atomic_set(&new_ns->count, 1);
58543 new_ns->root = NULL;
58544 INIT_LIST_HEAD(&new_ns->list);
58545 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58546 * Allocate a new namespace structure and populate it with contents
58547 * copied from the namespace of the passed in task structure.
58548 */
58549 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58550 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58551 struct user_namespace *user_ns, struct fs_struct *fs)
58552 {
58553 struct mnt_namespace *new_ns;
58554 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58555 }
58556 EXPORT_SYMBOL(mount_subtree);
58557
58558 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58559 - char __user *, type, unsigned long, flags, void __user *, data)
58560 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58561 + const char __user *, type, unsigned long, flags, void __user *, data)
58562 {
58563 int ret;
58564 char *kernel_type;
58565 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58566 if (error)
58567 goto out2;
58568
58569 + if (gr_handle_chroot_pivot()) {
58570 + error = -EPERM;
58571 + goto out2;
58572 + }
58573 +
58574 get_fs_root(current->fs, &root);
58575 old_mp = lock_mount(&old);
58576 error = PTR_ERR(old_mp);
58577 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58578 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
58579 return -EPERM;
58580
58581 - if (fs->users != 1)
58582 + if (atomic_read(&fs->users) != 1)
58583 return -EINVAL;
58584
58585 get_mnt_ns(mnt_ns);
58586 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58587 index f4ccfe6..a5cf064 100644
58588 --- a/fs/nfs/callback_xdr.c
58589 +++ b/fs/nfs/callback_xdr.c
58590 @@ -51,7 +51,7 @@ struct callback_op {
58591 callback_decode_arg_t decode_args;
58592 callback_encode_res_t encode_res;
58593 long res_maxsize;
58594 -};
58595 +} __do_const;
58596
58597 static struct callback_op callback_ops[];
58598
58599 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58600 index eda8879..bfc6837 100644
58601 --- a/fs/nfs/inode.c
58602 +++ b/fs/nfs/inode.c
58603 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58604 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58605 }
58606
58607 -static atomic_long_t nfs_attr_generation_counter;
58608 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58609
58610 static unsigned long nfs_read_attr_generation_counter(void)
58611 {
58612 - return atomic_long_read(&nfs_attr_generation_counter);
58613 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58614 }
58615
58616 unsigned long nfs_inc_attr_generation_counter(void)
58617 {
58618 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58619 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58620 }
58621
58622 void nfs_fattr_init(struct nfs_fattr *fattr)
58623 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
58624 index cc14cbb..6021bb6 100644
58625 --- a/fs/nfs/nfs4state.c
58626 +++ b/fs/nfs/nfs4state.c
58627 @@ -1881,10 +1881,15 @@ again:
58628 nfs4_root_machine_cred(clp);
58629 goto again;
58630 }
58631 - if (i > 2)
58632 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
58633 break;
58634 case -NFS4ERR_CLID_INUSE:
58635 case -NFS4ERR_WRONGSEC:
58636 + /* No point in retrying if we already used RPC_AUTH_UNIX */
58637 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) {
58638 + status = -EPERM;
58639 + break;
58640 + }
58641 clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX);
58642 if (IS_ERR(clnt)) {
58643 status = PTR_ERR(clnt);
58644 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58645 index 419572f..5414a23 100644
58646 --- a/fs/nfsd/nfs4proc.c
58647 +++ b/fs/nfsd/nfs4proc.c
58648 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58649 nfsd4op_rsize op_rsize_bop;
58650 stateid_getter op_get_currentstateid;
58651 stateid_setter op_set_currentstateid;
58652 -};
58653 +} __do_const;
58654
58655 static struct nfsd4_operation nfsd4_ops[];
58656
58657 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58658 index d9454fe..855c9d1 100644
58659 --- a/fs/nfsd/nfs4xdr.c
58660 +++ b/fs/nfsd/nfs4xdr.c
58661 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58662
58663 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58664
58665 -static nfsd4_dec nfsd4_dec_ops[] = {
58666 +static const nfsd4_dec nfsd4_dec_ops[] = {
58667 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58668 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58669 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58670 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58671 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58672 };
58673
58674 -static nfsd4_dec nfsd41_dec_ops[] = {
58675 +static const nfsd4_dec nfsd41_dec_ops[] = {
58676 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58677 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58678 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58679 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58680 };
58681
58682 struct nfsd4_minorversion_ops {
58683 - nfsd4_dec *decoders;
58684 + const nfsd4_dec *decoders;
58685 int nops;
58686 };
58687
58688 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58689 index 9186c7c..3fdde3e 100644
58690 --- a/fs/nfsd/nfscache.c
58691 +++ b/fs/nfsd/nfscache.c
58692 @@ -540,14 +540,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58693 {
58694 struct svc_cacherep *rp = rqstp->rq_cacherep;
58695 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58696 - int len;
58697 + long len;
58698 size_t bufsize = 0;
58699
58700 if (!rp)
58701 return;
58702
58703 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58704 - len >>= 2;
58705 + if (statp) {
58706 + len = (char*)statp - (char*)resv->iov_base;
58707 + len = resv->iov_len - len;
58708 + len >>= 2;
58709 + }
58710
58711 /* Don't cache excessive amounts of data and XDR failures */
58712 if (!statp || len > (256 >> 2)) {
58713 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58714 index c827acb..b253b77 100644
58715 --- a/fs/nfsd/vfs.c
58716 +++ b/fs/nfsd/vfs.c
58717 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58718 } else {
58719 oldfs = get_fs();
58720 set_fs(KERNEL_DS);
58721 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58722 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58723 set_fs(oldfs);
58724 }
58725
58726 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58727
58728 /* Write the data. */
58729 oldfs = get_fs(); set_fs(KERNEL_DS);
58730 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58731 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58732 set_fs(oldfs);
58733 if (host_err < 0)
58734 goto out_nfserr;
58735 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58736 */
58737
58738 oldfs = get_fs(); set_fs(KERNEL_DS);
58739 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58740 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58741 set_fs(oldfs);
58742
58743 if (host_err < 0)
58744 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58745 index fea6bd5..8ee9d81 100644
58746 --- a/fs/nls/nls_base.c
58747 +++ b/fs/nls/nls_base.c
58748 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58749
58750 int register_nls(struct nls_table * nls)
58751 {
58752 - struct nls_table ** tmp = &tables;
58753 + struct nls_table *tmp = tables;
58754
58755 if (nls->next)
58756 return -EBUSY;
58757
58758 spin_lock(&nls_lock);
58759 - while (*tmp) {
58760 - if (nls == *tmp) {
58761 + while (tmp) {
58762 + if (nls == tmp) {
58763 spin_unlock(&nls_lock);
58764 return -EBUSY;
58765 }
58766 - tmp = &(*tmp)->next;
58767 + tmp = tmp->next;
58768 }
58769 - nls->next = tables;
58770 + pax_open_kernel();
58771 + *(struct nls_table **)&nls->next = tables;
58772 + pax_close_kernel();
58773 tables = nls;
58774 spin_unlock(&nls_lock);
58775 return 0;
58776 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58777
58778 int unregister_nls(struct nls_table * nls)
58779 {
58780 - struct nls_table ** tmp = &tables;
58781 + struct nls_table * const * tmp = &tables;
58782
58783 spin_lock(&nls_lock);
58784 while (*tmp) {
58785 if (nls == *tmp) {
58786 - *tmp = nls->next;
58787 + pax_open_kernel();
58788 + *(struct nls_table **)tmp = nls->next;
58789 + pax_close_kernel();
58790 spin_unlock(&nls_lock);
58791 return 0;
58792 }
58793 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58794 index 7424929..35f6be5 100644
58795 --- a/fs/nls/nls_euc-jp.c
58796 +++ b/fs/nls/nls_euc-jp.c
58797 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58798 p_nls = load_nls("cp932");
58799
58800 if (p_nls) {
58801 - table.charset2upper = p_nls->charset2upper;
58802 - table.charset2lower = p_nls->charset2lower;
58803 + pax_open_kernel();
58804 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58805 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58806 + pax_close_kernel();
58807 return register_nls(&table);
58808 }
58809
58810 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58811 index e7bc1d7..06bd4bb 100644
58812 --- a/fs/nls/nls_koi8-ru.c
58813 +++ b/fs/nls/nls_koi8-ru.c
58814 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58815 p_nls = load_nls("koi8-u");
58816
58817 if (p_nls) {
58818 - table.charset2upper = p_nls->charset2upper;
58819 - table.charset2lower = p_nls->charset2lower;
58820 + pax_open_kernel();
58821 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58822 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58823 + pax_close_kernel();
58824 return register_nls(&table);
58825 }
58826
58827 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58828 index e44cb64..4807084 100644
58829 --- a/fs/notify/fanotify/fanotify_user.c
58830 +++ b/fs/notify/fanotify/fanotify_user.c
58831 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58832
58833 fd = fanotify_event_metadata.fd;
58834 ret = -EFAULT;
58835 - if (copy_to_user(buf, &fanotify_event_metadata,
58836 - fanotify_event_metadata.event_len))
58837 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58838 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58839 goto out_close_fd;
58840
58841 ret = prepare_for_access_response(group, event, fd);
58842 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58843 index 7b51b05..5ea5ef6 100644
58844 --- a/fs/notify/notification.c
58845 +++ b/fs/notify/notification.c
58846 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58847 * get set to 0 so it will never get 'freed'
58848 */
58849 static struct fsnotify_event *q_overflow_event;
58850 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58851 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58852
58853 /**
58854 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58855 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58856 */
58857 u32 fsnotify_get_cookie(void)
58858 {
58859 - return atomic_inc_return(&fsnotify_sync_cookie);
58860 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58861 }
58862 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58863
58864 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58865 index 9e38daf..5727cae 100644
58866 --- a/fs/ntfs/dir.c
58867 +++ b/fs/ntfs/dir.c
58868 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58869 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58870 ~(s64)(ndir->itype.index.block_size - 1)));
58871 /* Bounds checks. */
58872 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58873 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58874 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58875 "inode 0x%lx or driver bug.", vdir->i_ino);
58876 goto err_out;
58877 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58878 index ea4ba9d..1e13d34 100644
58879 --- a/fs/ntfs/file.c
58880 +++ b/fs/ntfs/file.c
58881 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58882 char *addr;
58883 size_t total = 0;
58884 unsigned len;
58885 - int left;
58886 + unsigned left;
58887
58888 do {
58889 len = PAGE_CACHE_SIZE - ofs;
58890 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58891 index 82650d5..db37dcf 100644
58892 --- a/fs/ntfs/super.c
58893 +++ b/fs/ntfs/super.c
58894 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58895 if (!silent)
58896 ntfs_error(sb, "Primary boot sector is invalid.");
58897 } else if (!silent)
58898 - ntfs_error(sb, read_err_str, "primary");
58899 + ntfs_error(sb, read_err_str, "%s", "primary");
58900 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58901 if (bh_primary)
58902 brelse(bh_primary);
58903 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58904 goto hotfix_primary_boot_sector;
58905 brelse(bh_backup);
58906 } else if (!silent)
58907 - ntfs_error(sb, read_err_str, "backup");
58908 + ntfs_error(sb, read_err_str, "%s", "backup");
58909 /* Try to read NT3.51- backup boot sector. */
58910 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58911 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58912 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58913 "sector.");
58914 brelse(bh_backup);
58915 } else if (!silent)
58916 - ntfs_error(sb, read_err_str, "backup");
58917 + ntfs_error(sb, read_err_str, "%s", "backup");
58918 /* We failed. Cleanup and return. */
58919 if (bh_primary)
58920 brelse(bh_primary);
58921 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58922 index cd5496b..26a1055 100644
58923 --- a/fs/ocfs2/localalloc.c
58924 +++ b/fs/ocfs2/localalloc.c
58925 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58926 goto bail;
58927 }
58928
58929 - atomic_inc(&osb->alloc_stats.moves);
58930 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58931
58932 bail:
58933 if (handle)
58934 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58935 index 3a90347..c40bef8 100644
58936 --- a/fs/ocfs2/ocfs2.h
58937 +++ b/fs/ocfs2/ocfs2.h
58938 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58939
58940 struct ocfs2_alloc_stats
58941 {
58942 - atomic_t moves;
58943 - atomic_t local_data;
58944 - atomic_t bitmap_data;
58945 - atomic_t bg_allocs;
58946 - atomic_t bg_extends;
58947 + atomic_unchecked_t moves;
58948 + atomic_unchecked_t local_data;
58949 + atomic_unchecked_t bitmap_data;
58950 + atomic_unchecked_t bg_allocs;
58951 + atomic_unchecked_t bg_extends;
58952 };
58953
58954 enum ocfs2_local_alloc_state
58955 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58956 index 5397c07..54afc55 100644
58957 --- a/fs/ocfs2/suballoc.c
58958 +++ b/fs/ocfs2/suballoc.c
58959 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58960 mlog_errno(status);
58961 goto bail;
58962 }
58963 - atomic_inc(&osb->alloc_stats.bg_extends);
58964 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58965
58966 /* You should never ask for this much metadata */
58967 BUG_ON(bits_wanted >
58968 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58969 mlog_errno(status);
58970 goto bail;
58971 }
58972 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58973 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58974
58975 *suballoc_loc = res.sr_bg_blkno;
58976 *suballoc_bit_start = res.sr_bit_offset;
58977 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58978 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58979 res->sr_bits);
58980
58981 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58982 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58983
58984 BUG_ON(res->sr_bits != 1);
58985
58986 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58987 mlog_errno(status);
58988 goto bail;
58989 }
58990 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58991 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58992
58993 BUG_ON(res.sr_bits != 1);
58994
58995 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58996 cluster_start,
58997 num_clusters);
58998 if (!status)
58999 - atomic_inc(&osb->alloc_stats.local_data);
59000 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59001 } else {
59002 if (min_clusters > (osb->bitmap_cpg - 1)) {
59003 /* The only paths asking for contiguousness
59004 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59005 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59006 res.sr_bg_blkno,
59007 res.sr_bit_offset);
59008 - atomic_inc(&osb->alloc_stats.bitmap_data);
59009 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59010 *num_clusters = res.sr_bits;
59011 }
59012 }
59013 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59014 index d4e81e4..ad89f5f 100644
59015 --- a/fs/ocfs2/super.c
59016 +++ b/fs/ocfs2/super.c
59017 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59018 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59019 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59020 "Stats",
59021 - atomic_read(&osb->alloc_stats.bitmap_data),
59022 - atomic_read(&osb->alloc_stats.local_data),
59023 - atomic_read(&osb->alloc_stats.bg_allocs),
59024 - atomic_read(&osb->alloc_stats.moves),
59025 - atomic_read(&osb->alloc_stats.bg_extends));
59026 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59027 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59028 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59029 + atomic_read_unchecked(&osb->alloc_stats.moves),
59030 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59031
59032 out += snprintf(buf + out, len - out,
59033 "%10s => State: %u Descriptor: %llu Size: %u bits "
59034 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59035 spin_lock_init(&osb->osb_xattr_lock);
59036 ocfs2_init_steal_slots(osb);
59037
59038 - atomic_set(&osb->alloc_stats.moves, 0);
59039 - atomic_set(&osb->alloc_stats.local_data, 0);
59040 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59041 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59042 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59043 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59044 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59045 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59046 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59047 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59048
59049 /* Copy the blockcheck stats from the superblock probe */
59050 osb->osb_ecc_stats = *stats;
59051 diff --git a/fs/open.c b/fs/open.c
59052 index d420331..2dbb3fd 100644
59053 --- a/fs/open.c
59054 +++ b/fs/open.c
59055 @@ -32,6 +32,8 @@
59056 #include <linux/dnotify.h>
59057 #include <linux/compat.h>
59058
59059 +#define CREATE_TRACE_POINTS
59060 +#include <trace/events/fs.h>
59061 #include "internal.h"
59062
59063 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59064 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59065 error = locks_verify_truncate(inode, NULL, length);
59066 if (!error)
59067 error = security_path_truncate(path);
59068 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59069 + error = -EACCES;
59070 if (!error)
59071 error = do_truncate(path->dentry, length, 0, NULL);
59072
59073 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59074 error = locks_verify_truncate(inode, f.file, length);
59075 if (!error)
59076 error = security_path_truncate(&f.file->f_path);
59077 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59078 + error = -EACCES;
59079 if (!error)
59080 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59081 sb_end_write(inode->i_sb);
59082 @@ -360,6 +366,9 @@ retry:
59083 if (__mnt_is_readonly(path.mnt))
59084 res = -EROFS;
59085
59086 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59087 + res = -EACCES;
59088 +
59089 out_path_release:
59090 path_put(&path);
59091 if (retry_estale(res, lookup_flags)) {
59092 @@ -391,6 +400,8 @@ retry:
59093 if (error)
59094 goto dput_and_out;
59095
59096 + gr_log_chdir(path.dentry, path.mnt);
59097 +
59098 set_fs_pwd(current->fs, &path);
59099
59100 dput_and_out:
59101 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59102 goto out_putf;
59103
59104 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59105 +
59106 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59107 + error = -EPERM;
59108 +
59109 + if (!error)
59110 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59111 +
59112 if (!error)
59113 set_fs_pwd(current->fs, &f.file->f_path);
59114 out_putf:
59115 @@ -449,7 +467,13 @@ retry:
59116 if (error)
59117 goto dput_and_out;
59118
59119 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59120 + goto dput_and_out;
59121 +
59122 set_fs_root(current->fs, &path);
59123 +
59124 + gr_handle_chroot_chdir(&path);
59125 +
59126 error = 0;
59127 dput_and_out:
59128 path_put(&path);
59129 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59130 if (error)
59131 return error;
59132 mutex_lock(&inode->i_mutex);
59133 +
59134 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59135 + error = -EACCES;
59136 + goto out_unlock;
59137 + }
59138 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59139 + error = -EACCES;
59140 + goto out_unlock;
59141 + }
59142 +
59143 error = security_path_chmod(path, mode);
59144 if (error)
59145 goto out_unlock;
59146 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59147 uid = make_kuid(current_user_ns(), user);
59148 gid = make_kgid(current_user_ns(), group);
59149
59150 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59151 + return -EACCES;
59152 +
59153 newattrs.ia_valid = ATTR_CTIME;
59154 if (user != (uid_t) -1) {
59155 if (!uid_valid(uid))
59156 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59157 } else {
59158 fsnotify_open(f);
59159 fd_install(fd, f);
59160 + trace_do_sys_open(tmp->name, flags, mode);
59161 }
59162 }
59163 putname(tmp);
59164 diff --git a/fs/pipe.c b/fs/pipe.c
59165 index d2c45e1..009fe1c 100644
59166 --- a/fs/pipe.c
59167 +++ b/fs/pipe.c
59168 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59169
59170 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59171 {
59172 - if (pipe->files)
59173 + if (atomic_read(&pipe->files))
59174 mutex_lock_nested(&pipe->mutex, subclass);
59175 }
59176
59177 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59178
59179 void pipe_unlock(struct pipe_inode_info *pipe)
59180 {
59181 - if (pipe->files)
59182 + if (atomic_read(&pipe->files))
59183 mutex_unlock(&pipe->mutex);
59184 }
59185 EXPORT_SYMBOL(pipe_unlock);
59186 @@ -449,9 +449,9 @@ redo:
59187 }
59188 if (bufs) /* More to do? */
59189 continue;
59190 - if (!pipe->writers)
59191 + if (!atomic_read(&pipe->writers))
59192 break;
59193 - if (!pipe->waiting_writers) {
59194 + if (!atomic_read(&pipe->waiting_writers)) {
59195 /* syscall merging: Usually we must not sleep
59196 * if O_NONBLOCK is set, or if we got some data.
59197 * But if a writer sleeps in kernel space, then
59198 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
59199 ret = 0;
59200 __pipe_lock(pipe);
59201
59202 - if (!pipe->readers) {
59203 + if (!atomic_read(&pipe->readers)) {
59204 send_sig(SIGPIPE, current, 0);
59205 ret = -EPIPE;
59206 goto out;
59207 @@ -562,7 +562,7 @@ redo1:
59208 for (;;) {
59209 int bufs;
59210
59211 - if (!pipe->readers) {
59212 + if (!atomic_read(&pipe->readers)) {
59213 send_sig(SIGPIPE, current, 0);
59214 if (!ret)
59215 ret = -EPIPE;
59216 @@ -653,9 +653,9 @@ redo2:
59217 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59218 do_wakeup = 0;
59219 }
59220 - pipe->waiting_writers++;
59221 + atomic_inc(&pipe->waiting_writers);
59222 pipe_wait(pipe);
59223 - pipe->waiting_writers--;
59224 + atomic_dec(&pipe->waiting_writers);
59225 }
59226 out:
59227 __pipe_unlock(pipe);
59228 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59229 mask = 0;
59230 if (filp->f_mode & FMODE_READ) {
59231 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
59232 - if (!pipe->writers && filp->f_version != pipe->w_counter)
59233 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
59234 mask |= POLLHUP;
59235 }
59236
59237 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59238 * Most Unices do not set POLLERR for FIFOs but on Linux they
59239 * behave exactly like pipes for poll().
59240 */
59241 - if (!pipe->readers)
59242 + if (!atomic_read(&pipe->readers))
59243 mask |= POLLERR;
59244 }
59245
59246 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
59247
59248 __pipe_lock(pipe);
59249 if (file->f_mode & FMODE_READ)
59250 - pipe->readers--;
59251 + atomic_dec(&pipe->readers);
59252 if (file->f_mode & FMODE_WRITE)
59253 - pipe->writers--;
59254 + atomic_dec(&pipe->writers);
59255
59256 - if (pipe->readers || pipe->writers) {
59257 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
59258 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
59259 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59260 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
59261 }
59262 spin_lock(&inode->i_lock);
59263 - if (!--pipe->files) {
59264 + if (atomic_dec_and_test(&pipe->files)) {
59265 inode->i_pipe = NULL;
59266 kill = 1;
59267 }
59268 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
59269 kfree(pipe);
59270 }
59271
59272 -static struct vfsmount *pipe_mnt __read_mostly;
59273 +struct vfsmount *pipe_mnt __read_mostly;
59274
59275 /*
59276 * pipefs_dname() is called from d_path().
59277 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
59278 goto fail_iput;
59279
59280 inode->i_pipe = pipe;
59281 - pipe->files = 2;
59282 - pipe->readers = pipe->writers = 1;
59283 + atomic_set(&pipe->files, 2);
59284 + atomic_set(&pipe->readers, 1);
59285 + atomic_set(&pipe->writers, 1);
59286 inode->i_fop = &pipefifo_fops;
59287
59288 /*
59289 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
59290 spin_lock(&inode->i_lock);
59291 if (inode->i_pipe) {
59292 pipe = inode->i_pipe;
59293 - pipe->files++;
59294 + atomic_inc(&pipe->files);
59295 spin_unlock(&inode->i_lock);
59296 } else {
59297 spin_unlock(&inode->i_lock);
59298 pipe = alloc_pipe_info();
59299 if (!pipe)
59300 return -ENOMEM;
59301 - pipe->files = 1;
59302 + atomic_set(&pipe->files, 1);
59303 spin_lock(&inode->i_lock);
59304 if (unlikely(inode->i_pipe)) {
59305 - inode->i_pipe->files++;
59306 + atomic_inc(&inode->i_pipe->files);
59307 spin_unlock(&inode->i_lock);
59308 free_pipe_info(pipe);
59309 pipe = inode->i_pipe;
59310 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
59311 * opened, even when there is no process writing the FIFO.
59312 */
59313 pipe->r_counter++;
59314 - if (pipe->readers++ == 0)
59315 + if (atomic_inc_return(&pipe->readers) == 1)
59316 wake_up_partner(pipe);
59317
59318 - if (!is_pipe && !pipe->writers) {
59319 + if (!is_pipe && !atomic_read(&pipe->writers)) {
59320 if ((filp->f_flags & O_NONBLOCK)) {
59321 /* suppress POLLHUP until we have
59322 * seen a writer */
59323 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
59324 * errno=ENXIO when there is no process reading the FIFO.
59325 */
59326 ret = -ENXIO;
59327 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
59328 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
59329 goto err;
59330
59331 pipe->w_counter++;
59332 - if (!pipe->writers++)
59333 + if (atomic_inc_return(&pipe->writers) == 1)
59334 wake_up_partner(pipe);
59335
59336 - if (!is_pipe && !pipe->readers) {
59337 + if (!is_pipe && !atomic_read(&pipe->readers)) {
59338 if (wait_for_partner(pipe, &pipe->r_counter))
59339 goto err_wr;
59340 }
59341 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
59342 * the process can at least talk to itself.
59343 */
59344
59345 - pipe->readers++;
59346 - pipe->writers++;
59347 + atomic_inc(&pipe->readers);
59348 + atomic_inc(&pipe->writers);
59349 pipe->r_counter++;
59350 pipe->w_counter++;
59351 - if (pipe->readers == 1 || pipe->writers == 1)
59352 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
59353 wake_up_partner(pipe);
59354 break;
59355
59356 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
59357 return 0;
59358
59359 err_rd:
59360 - if (!--pipe->readers)
59361 + if (atomic_dec_and_test(&pipe->readers))
59362 wake_up_interruptible(&pipe->wait);
59363 ret = -ERESTARTSYS;
59364 goto err;
59365
59366 err_wr:
59367 - if (!--pipe->writers)
59368 + if (atomic_dec_and_test(&pipe->writers))
59369 wake_up_interruptible(&pipe->wait);
59370 ret = -ERESTARTSYS;
59371 goto err;
59372
59373 err:
59374 spin_lock(&inode->i_lock);
59375 - if (!--pipe->files) {
59376 + if (atomic_dec_and_test(&pipe->files)) {
59377 inode->i_pipe = NULL;
59378 kill = 1;
59379 }
59380 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
59381 index 15af622..0e9f4467 100644
59382 --- a/fs/proc/Kconfig
59383 +++ b/fs/proc/Kconfig
59384 @@ -30,12 +30,12 @@ config PROC_FS
59385
59386 config PROC_KCORE
59387 bool "/proc/kcore support" if !ARM
59388 - depends on PROC_FS && MMU
59389 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
59390
59391 config PROC_VMCORE
59392 bool "/proc/vmcore support"
59393 - depends on PROC_FS && CRASH_DUMP
59394 - default y
59395 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
59396 + default n
59397 help
59398 Exports the dump image of crashed kernel in ELF format.
59399
59400 @@ -59,8 +59,8 @@ config PROC_SYSCTL
59401 limited in memory.
59402
59403 config PROC_PAGE_MONITOR
59404 - default y
59405 - depends on PROC_FS && MMU
59406 + default n
59407 + depends on PROC_FS && MMU && !GRKERNSEC
59408 bool "Enable /proc page monitoring" if EXPERT
59409 help
59410 Various /proc files exist to monitor process memory utilization:
59411 diff --git a/fs/proc/array.c b/fs/proc/array.c
59412 index cbd0f1b..adec3f0 100644
59413 --- a/fs/proc/array.c
59414 +++ b/fs/proc/array.c
59415 @@ -60,6 +60,7 @@
59416 #include <linux/tty.h>
59417 #include <linux/string.h>
59418 #include <linux/mman.h>
59419 +#include <linux/grsecurity.h>
59420 #include <linux/proc_fs.h>
59421 #include <linux/ioport.h>
59422 #include <linux/uaccess.h>
59423 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
59424 seq_putc(m, '\n');
59425 }
59426
59427 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59428 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
59429 +{
59430 + if (p->mm)
59431 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
59432 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
59433 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
59434 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
59435 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
59436 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
59437 + else
59438 + seq_printf(m, "PaX:\t-----\n");
59439 +}
59440 +#endif
59441 +
59442 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59443 struct pid *pid, struct task_struct *task)
59444 {
59445 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59446 task_cpus_allowed(m, task);
59447 cpuset_task_status_allowed(m, task);
59448 task_context_switch_counts(m, task);
59449 +
59450 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59451 + task_pax(m, task);
59452 +#endif
59453 +
59454 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
59455 + task_grsec_rbac(m, task);
59456 +#endif
59457 +
59458 return 0;
59459 }
59460
59461 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59462 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59463 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59464 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59465 +#endif
59466 +
59467 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59468 struct pid *pid, struct task_struct *task, int whole)
59469 {
59470 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59471 char tcomm[sizeof(task->comm)];
59472 unsigned long flags;
59473
59474 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59475 + if (current->exec_id != m->exec_id) {
59476 + gr_log_badprocpid("stat");
59477 + return 0;
59478 + }
59479 +#endif
59480 +
59481 state = *get_task_state(task);
59482 vsize = eip = esp = 0;
59483 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59484 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59485 gtime = task_gtime(task);
59486 }
59487
59488 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59489 + if (PAX_RAND_FLAGS(mm)) {
59490 + eip = 0;
59491 + esp = 0;
59492 + wchan = 0;
59493 + }
59494 +#endif
59495 +#ifdef CONFIG_GRKERNSEC_HIDESYM
59496 + wchan = 0;
59497 + eip =0;
59498 + esp =0;
59499 +#endif
59500 +
59501 /* scale priority and nice values from timeslices to -20..20 */
59502 /* to make it look like a "normal" Unix priority/nice value */
59503 priority = task_prio(task);
59504 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59505 seq_put_decimal_ull(m, ' ', vsize);
59506 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59507 seq_put_decimal_ull(m, ' ', rsslim);
59508 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59509 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59510 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59511 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59512 +#else
59513 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59514 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59515 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59516 +#endif
59517 seq_put_decimal_ull(m, ' ', esp);
59518 seq_put_decimal_ull(m, ' ', eip);
59519 /* The signal information here is obsolete.
59520 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59521 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59522 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59523
59524 - if (mm && permitted) {
59525 + if (mm && permitted
59526 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59527 + && !PAX_RAND_FLAGS(mm)
59528 +#endif
59529 + ) {
59530 seq_put_decimal_ull(m, ' ', mm->start_data);
59531 seq_put_decimal_ull(m, ' ', mm->end_data);
59532 seq_put_decimal_ull(m, ' ', mm->start_brk);
59533 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59534 struct pid *pid, struct task_struct *task)
59535 {
59536 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59537 - struct mm_struct *mm = get_task_mm(task);
59538 + struct mm_struct *mm;
59539
59540 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59541 + if (current->exec_id != m->exec_id) {
59542 + gr_log_badprocpid("statm");
59543 + return 0;
59544 + }
59545 +#endif
59546 + mm = get_task_mm(task);
59547 if (mm) {
59548 size = task_statm(mm, &shared, &text, &data, &resident);
59549 mmput(mm);
59550 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59551 return 0;
59552 }
59553
59554 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59555 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59556 +{
59557 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59558 +}
59559 +#endif
59560 +
59561 #ifdef CONFIG_CHECKPOINT_RESTORE
59562 static struct pid *
59563 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59564 diff --git a/fs/proc/base.c b/fs/proc/base.c
59565 index 1485e38..8ad4236 100644
59566 --- a/fs/proc/base.c
59567 +++ b/fs/proc/base.c
59568 @@ -113,6 +113,14 @@ struct pid_entry {
59569 union proc_op op;
59570 };
59571
59572 +struct getdents_callback {
59573 + struct linux_dirent __user * current_dir;
59574 + struct linux_dirent __user * previous;
59575 + struct file * file;
59576 + int count;
59577 + int error;
59578 +};
59579 +
59580 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59581 .name = (NAME), \
59582 .len = sizeof(NAME) - 1, \
59583 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59584 if (!mm->arg_end)
59585 goto out_mm; /* Shh! No looking before we're done */
59586
59587 + if (gr_acl_handle_procpidmem(task))
59588 + goto out_mm;
59589 +
59590 len = mm->arg_end - mm->arg_start;
59591
59592 if (len > PAGE_SIZE)
59593 @@ -237,12 +248,28 @@ out:
59594 return res;
59595 }
59596
59597 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59598 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59599 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59600 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59601 +#endif
59602 +
59603 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59604 {
59605 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59606 int res = PTR_ERR(mm);
59607 if (mm && !IS_ERR(mm)) {
59608 unsigned int nwords = 0;
59609 +
59610 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59611 + /* allow if we're currently ptracing this task */
59612 + if (PAX_RAND_FLAGS(mm) &&
59613 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59614 + mmput(mm);
59615 + return 0;
59616 + }
59617 +#endif
59618 +
59619 do {
59620 nwords += 2;
59621 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59622 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59623 }
59624
59625
59626 -#ifdef CONFIG_KALLSYMS
59627 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59628 /*
59629 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59630 * Returns the resolved symbol. If that fails, simply return the address.
59631 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59632 mutex_unlock(&task->signal->cred_guard_mutex);
59633 }
59634
59635 -#ifdef CONFIG_STACKTRACE
59636 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59637
59638 #define MAX_STACK_TRACE_DEPTH 64
59639
59640 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59641 return count;
59642 }
59643
59644 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59645 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59646 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59647 {
59648 long nr;
59649 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59650 /************************************************************************/
59651
59652 /* permission checks */
59653 -static int proc_fd_access_allowed(struct inode *inode)
59654 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59655 {
59656 struct task_struct *task;
59657 int allowed = 0;
59658 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59659 */
59660 task = get_proc_task(inode);
59661 if (task) {
59662 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59663 + if (log)
59664 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59665 + else
59666 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59667 put_task_struct(task);
59668 }
59669 return allowed;
59670 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59671 struct task_struct *task,
59672 int hide_pid_min)
59673 {
59674 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59675 + return false;
59676 +
59677 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59678 + rcu_read_lock();
59679 + {
59680 + const struct cred *tmpcred = current_cred();
59681 + const struct cred *cred = __task_cred(task);
59682 +
59683 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59684 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59685 + || in_group_p(grsec_proc_gid)
59686 +#endif
59687 + ) {
59688 + rcu_read_unlock();
59689 + return true;
59690 + }
59691 + }
59692 + rcu_read_unlock();
59693 +
59694 + if (!pid->hide_pid)
59695 + return false;
59696 +#endif
59697 +
59698 if (pid->hide_pid < hide_pid_min)
59699 return true;
59700 if (in_group_p(pid->pid_gid))
59701 return true;
59702 +
59703 return ptrace_may_access(task, PTRACE_MODE_READ);
59704 }
59705
59706 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59707 put_task_struct(task);
59708
59709 if (!has_perms) {
59710 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59711 + {
59712 +#else
59713 if (pid->hide_pid == 2) {
59714 +#endif
59715 /*
59716 * Let's make getdents(), stat(), and open()
59717 * consistent with each other. If a process
59718 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59719 if (!task)
59720 return -ESRCH;
59721
59722 + if (gr_acl_handle_procpidmem(task)) {
59723 + put_task_struct(task);
59724 + return -EPERM;
59725 + }
59726 +
59727 mm = mm_access(task, mode);
59728 put_task_struct(task);
59729
59730 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59731
59732 file->private_data = mm;
59733
59734 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59735 + file->f_version = current->exec_id;
59736 +#endif
59737 +
59738 return 0;
59739 }
59740
59741 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59742 ssize_t copied;
59743 char *page;
59744
59745 +#ifdef CONFIG_GRKERNSEC
59746 + if (write)
59747 + return -EPERM;
59748 +#endif
59749 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59750 + if (file->f_version != current->exec_id) {
59751 + gr_log_badprocpid("mem");
59752 + return 0;
59753 + }
59754 +#endif
59755 +
59756 if (!mm)
59757 return 0;
59758
59759 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59760 goto free;
59761
59762 while (count > 0) {
59763 - int this_len = min_t(int, count, PAGE_SIZE);
59764 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59765
59766 if (write && copy_from_user(page, buf, this_len)) {
59767 copied = -EFAULT;
59768 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59769 if (!mm)
59770 return 0;
59771
59772 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59773 + if (file->f_version != current->exec_id) {
59774 + gr_log_badprocpid("environ");
59775 + return 0;
59776 + }
59777 +#endif
59778 +
59779 page = (char *)__get_free_page(GFP_TEMPORARY);
59780 if (!page)
59781 return -ENOMEM;
59782 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59783 goto free;
59784 while (count > 0) {
59785 size_t this_len, max_len;
59786 - int retval;
59787 + ssize_t retval;
59788
59789 if (src >= (mm->env_end - mm->env_start))
59790 break;
59791 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59792 int error = -EACCES;
59793
59794 /* Are we allowed to snoop on the tasks file descriptors? */
59795 - if (!proc_fd_access_allowed(inode))
59796 + if (!proc_fd_access_allowed(inode, 0))
59797 goto out;
59798
59799 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59800 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59801 struct path path;
59802
59803 /* Are we allowed to snoop on the tasks file descriptors? */
59804 - if (!proc_fd_access_allowed(inode))
59805 - goto out;
59806 + /* logging this is needed for learning on chromium to work properly,
59807 + but we don't want to flood the logs from 'ps' which does a readlink
59808 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59809 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59810 + */
59811 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59812 + if (!proc_fd_access_allowed(inode,0))
59813 + goto out;
59814 + } else {
59815 + if (!proc_fd_access_allowed(inode,1))
59816 + goto out;
59817 + }
59818
59819 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59820 if (error)
59821 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59822 rcu_read_lock();
59823 cred = __task_cred(task);
59824 inode->i_uid = cred->euid;
59825 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59826 + inode->i_gid = grsec_proc_gid;
59827 +#else
59828 inode->i_gid = cred->egid;
59829 +#endif
59830 rcu_read_unlock();
59831 }
59832 security_task_to_inode(task, inode);
59833 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59834 return -ENOENT;
59835 }
59836 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59837 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59838 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59839 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59840 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59841 +#endif
59842 task_dumpable(task)) {
59843 cred = __task_cred(task);
59844 stat->uid = cred->euid;
59845 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59846 + stat->gid = grsec_proc_gid;
59847 +#else
59848 stat->gid = cred->egid;
59849 +#endif
59850 }
59851 }
59852 rcu_read_unlock();
59853 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59854
59855 if (task) {
59856 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59857 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59858 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59859 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59860 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59861 +#endif
59862 task_dumpable(task)) {
59863 rcu_read_lock();
59864 cred = __task_cred(task);
59865 inode->i_uid = cred->euid;
59866 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59867 + inode->i_gid = grsec_proc_gid;
59868 +#else
59869 inode->i_gid = cred->egid;
59870 +#endif
59871 rcu_read_unlock();
59872 } else {
59873 inode->i_uid = GLOBAL_ROOT_UID;
59874 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59875 if (!task)
59876 goto out_no_task;
59877
59878 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59879 + goto out;
59880 +
59881 /*
59882 * Yes, it does not scale. And it should not. Don't add
59883 * new entries into /proc/<tgid>/ without very good reasons.
59884 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59885 if (!task)
59886 return -ENOENT;
59887
59888 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59889 + goto out;
59890 +
59891 if (!dir_emit_dots(file, ctx))
59892 goto out;
59893
59894 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59895 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59896 #endif
59897 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59898 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59899 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59900 INF("syscall", S_IRUGO, proc_pid_syscall),
59901 #endif
59902 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59903 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59904 #ifdef CONFIG_SECURITY
59905 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59906 #endif
59907 -#ifdef CONFIG_KALLSYMS
59908 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59909 INF("wchan", S_IRUGO, proc_pid_wchan),
59910 #endif
59911 -#ifdef CONFIG_STACKTRACE
59912 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59913 ONE("stack", S_IRUGO, proc_pid_stack),
59914 #endif
59915 #ifdef CONFIG_SCHEDSTATS
59916 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59917 #ifdef CONFIG_HARDWALL
59918 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59919 #endif
59920 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59921 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59922 +#endif
59923 #ifdef CONFIG_USER_NS
59924 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59925 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59926 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59927 if (!inode)
59928 goto out;
59929
59930 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59931 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59932 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59933 + inode->i_gid = grsec_proc_gid;
59934 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59935 +#else
59936 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59937 +#endif
59938 inode->i_op = &proc_tgid_base_inode_operations;
59939 inode->i_fop = &proc_tgid_base_operations;
59940 inode->i_flags|=S_IMMUTABLE;
59941 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59942 if (!task)
59943 goto out;
59944
59945 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59946 + goto out_put_task;
59947 +
59948 result = proc_pid_instantiate(dir, dentry, task, NULL);
59949 +out_put_task:
59950 put_task_struct(task);
59951 out:
59952 return ERR_PTR(result);
59953 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59954 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59955 #endif
59956 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59957 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59958 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59959 INF("syscall", S_IRUGO, proc_pid_syscall),
59960 #endif
59961 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59962 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59963 #ifdef CONFIG_SECURITY
59964 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59965 #endif
59966 -#ifdef CONFIG_KALLSYMS
59967 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59968 INF("wchan", S_IRUGO, proc_pid_wchan),
59969 #endif
59970 -#ifdef CONFIG_STACKTRACE
59971 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59972 ONE("stack", S_IRUGO, proc_pid_stack),
59973 #endif
59974 #ifdef CONFIG_SCHEDSTATS
59975 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59976 index 82676e3..5f8518a 100644
59977 --- a/fs/proc/cmdline.c
59978 +++ b/fs/proc/cmdline.c
59979 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59980
59981 static int __init proc_cmdline_init(void)
59982 {
59983 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59984 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59985 +#else
59986 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59987 +#endif
59988 return 0;
59989 }
59990 module_init(proc_cmdline_init);
59991 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59992 index b143471..bb105e5 100644
59993 --- a/fs/proc/devices.c
59994 +++ b/fs/proc/devices.c
59995 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59996
59997 static int __init proc_devices_init(void)
59998 {
59999 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60000 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60001 +#else
60002 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60003 +#endif
60004 return 0;
60005 }
60006 module_init(proc_devices_init);
60007 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60008 index 985ea88..d118a0a 100644
60009 --- a/fs/proc/fd.c
60010 +++ b/fs/proc/fd.c
60011 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60012 if (!task)
60013 return -ENOENT;
60014
60015 - files = get_files_struct(task);
60016 + if (!gr_acl_handle_procpidmem(task))
60017 + files = get_files_struct(task);
60018 put_task_struct(task);
60019
60020 if (files) {
60021 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60022 */
60023 int proc_fd_permission(struct inode *inode, int mask)
60024 {
60025 + struct task_struct *task;
60026 int rv = generic_permission(inode, mask);
60027 - if (rv == 0)
60028 - return 0;
60029 +
60030 if (task_tgid(current) == proc_pid(inode))
60031 rv = 0;
60032 +
60033 + task = get_proc_task(inode);
60034 + if (task == NULL)
60035 + return rv;
60036 +
60037 + if (gr_acl_handle_procpidmem(task))
60038 + rv = -EACCES;
60039 +
60040 + put_task_struct(task);
60041 +
60042 return rv;
60043 }
60044
60045 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60046 index 8eaa1ba..cc6ff42 100644
60047 --- a/fs/proc/inode.c
60048 +++ b/fs/proc/inode.c
60049 @@ -23,11 +23,17 @@
60050 #include <linux/slab.h>
60051 #include <linux/mount.h>
60052 #include <linux/magic.h>
60053 +#include <linux/grsecurity.h>
60054
60055 #include <asm/uaccess.h>
60056
60057 #include "internal.h"
60058
60059 +#ifdef CONFIG_PROC_SYSCTL
60060 +extern const struct inode_operations proc_sys_inode_operations;
60061 +extern const struct inode_operations proc_sys_dir_operations;
60062 +#endif
60063 +
60064 static void proc_evict_inode(struct inode *inode)
60065 {
60066 struct proc_dir_entry *de;
60067 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60068 ns = PROC_I(inode)->ns.ns;
60069 if (ns_ops && ns)
60070 ns_ops->put(ns);
60071 +
60072 +#ifdef CONFIG_PROC_SYSCTL
60073 + if (inode->i_op == &proc_sys_inode_operations ||
60074 + inode->i_op == &proc_sys_dir_operations)
60075 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60076 +#endif
60077 +
60078 }
60079
60080 static struct kmem_cache * proc_inode_cachep;
60081 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60082 if (de->mode) {
60083 inode->i_mode = de->mode;
60084 inode->i_uid = de->uid;
60085 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60086 + inode->i_gid = grsec_proc_gid;
60087 +#else
60088 inode->i_gid = de->gid;
60089 +#endif
60090 }
60091 if (de->size)
60092 inode->i_size = de->size;
60093 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60094 index 651d09a..60c73ae 100644
60095 --- a/fs/proc/internal.h
60096 +++ b/fs/proc/internal.h
60097 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60098 struct pid *, struct task_struct *);
60099 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60100 struct pid *, struct task_struct *);
60101 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60102 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60103 +#endif
60104
60105 /*
60106 * base.c
60107 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60108 index 06ea155..9a798c7 100644
60109 --- a/fs/proc/kcore.c
60110 +++ b/fs/proc/kcore.c
60111 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60112 * the addresses in the elf_phdr on our list.
60113 */
60114 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60115 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60116 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60117 + if (tsz > buflen)
60118 tsz = buflen;
60119 -
60120 +
60121 while (buflen) {
60122 struct kcore_list *m;
60123
60124 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60125 kfree(elf_buf);
60126 } else {
60127 if (kern_addr_valid(start)) {
60128 - unsigned long n;
60129 + char *elf_buf;
60130 + mm_segment_t oldfs;
60131
60132 - n = copy_to_user(buffer, (char *)start, tsz);
60133 - /*
60134 - * We cannot distinguish between fault on source
60135 - * and fault on destination. When this happens
60136 - * we clear too and hope it will trigger the
60137 - * EFAULT again.
60138 - */
60139 - if (n) {
60140 - if (clear_user(buffer + tsz - n,
60141 - n))
60142 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60143 + if (!elf_buf)
60144 + return -ENOMEM;
60145 + oldfs = get_fs();
60146 + set_fs(KERNEL_DS);
60147 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60148 + set_fs(oldfs);
60149 + if (copy_to_user(buffer, elf_buf, tsz)) {
60150 + kfree(elf_buf);
60151 return -EFAULT;
60152 + }
60153 }
60154 + set_fs(oldfs);
60155 + kfree(elf_buf);
60156 } else {
60157 if (clear_user(buffer, tsz))
60158 return -EFAULT;
60159 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60160
60161 static int open_kcore(struct inode *inode, struct file *filp)
60162 {
60163 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60164 + return -EPERM;
60165 +#endif
60166 if (!capable(CAP_SYS_RAWIO))
60167 return -EPERM;
60168 if (kcore_need_update)
60169 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60170 index 59d85d6..ac6fc05 100644
60171 --- a/fs/proc/meminfo.c
60172 +++ b/fs/proc/meminfo.c
60173 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60174 vmi.used >> 10,
60175 vmi.largest_chunk >> 10
60176 #ifdef CONFIG_MEMORY_FAILURE
60177 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60178 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60179 #endif
60180 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60181 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60182 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60183 index ccfd99b..1b7e255 100644
60184 --- a/fs/proc/nommu.c
60185 +++ b/fs/proc/nommu.c
60186 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60187 if (len < 1)
60188 len = 1;
60189 seq_printf(m, "%*c", len, ' ');
60190 - seq_path(m, &file->f_path, "");
60191 + seq_path(m, &file->f_path, "\n\\");
60192 }
60193
60194 seq_putc(m, '\n');
60195 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
60196 index 4677bb7..408e936 100644
60197 --- a/fs/proc/proc_net.c
60198 +++ b/fs/proc/proc_net.c
60199 @@ -23,6 +23,7 @@
60200 #include <linux/nsproxy.h>
60201 #include <net/net_namespace.h>
60202 #include <linux/seq_file.h>
60203 +#include <linux/grsecurity.h>
60204
60205 #include "internal.h"
60206
60207 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
60208 struct task_struct *task;
60209 struct nsproxy *ns;
60210 struct net *net = NULL;
60211 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60212 + const struct cred *cred = current_cred();
60213 +#endif
60214 +
60215 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60216 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
60217 + return net;
60218 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60219 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
60220 + return net;
60221 +#endif
60222
60223 rcu_read_lock();
60224 task = pid_task(proc_pid(dir), PIDTYPE_PID);
60225 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
60226 index 7129046..6914844 100644
60227 --- a/fs/proc/proc_sysctl.c
60228 +++ b/fs/proc/proc_sysctl.c
60229 @@ -11,13 +11,21 @@
60230 #include <linux/namei.h>
60231 #include <linux/mm.h>
60232 #include <linux/module.h>
60233 +#include <linux/nsproxy.h>
60234 +#ifdef CONFIG_GRKERNSEC
60235 +#include <net/net_namespace.h>
60236 +#endif
60237 #include "internal.h"
60238
60239 +extern int gr_handle_chroot_sysctl(const int op);
60240 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
60241 + const int op);
60242 +
60243 static const struct dentry_operations proc_sys_dentry_operations;
60244 static const struct file_operations proc_sys_file_operations;
60245 -static const struct inode_operations proc_sys_inode_operations;
60246 +const struct inode_operations proc_sys_inode_operations;
60247 static const struct file_operations proc_sys_dir_file_operations;
60248 -static const struct inode_operations proc_sys_dir_operations;
60249 +const struct inode_operations proc_sys_dir_operations;
60250
60251 void proc_sys_poll_notify(struct ctl_table_poll *poll)
60252 {
60253 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
60254
60255 err = NULL;
60256 d_set_d_op(dentry, &proc_sys_dentry_operations);
60257 +
60258 + gr_handle_proc_create(dentry, inode);
60259 +
60260 d_add(dentry, inode);
60261
60262 out:
60263 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60264 struct inode *inode = file_inode(filp);
60265 struct ctl_table_header *head = grab_header(inode);
60266 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
60267 + int op = write ? MAY_WRITE : MAY_READ;
60268 ssize_t error;
60269 size_t res;
60270
60271 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60272 * and won't be until we finish.
60273 */
60274 error = -EPERM;
60275 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
60276 + if (sysctl_perm(head, table, op))
60277 goto out;
60278
60279 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
60280 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60281 if (!table->proc_handler)
60282 goto out;
60283
60284 +#ifdef CONFIG_GRKERNSEC
60285 + error = -EPERM;
60286 + if (gr_handle_chroot_sysctl(op))
60287 + goto out;
60288 + dget(filp->f_path.dentry);
60289 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
60290 + dput(filp->f_path.dentry);
60291 + goto out;
60292 + }
60293 + dput(filp->f_path.dentry);
60294 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
60295 + goto out;
60296 + if (write) {
60297 + if (current->nsproxy->net_ns != table->extra2) {
60298 + if (!capable(CAP_SYS_ADMIN))
60299 + goto out;
60300 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
60301 + goto out;
60302 + }
60303 +#endif
60304 +
60305 /* careful: calling conventions are nasty here */
60306 res = count;
60307 error = table->proc_handler(table, write, buf, &res, ppos);
60308 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
60309 return false;
60310 } else {
60311 d_set_d_op(child, &proc_sys_dentry_operations);
60312 +
60313 + gr_handle_proc_create(child, inode);
60314 +
60315 d_add(child, inode);
60316 }
60317 } else {
60318 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
60319 if ((*pos)++ < ctx->pos)
60320 return true;
60321
60322 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
60323 + return 0;
60324 +
60325 if (unlikely(S_ISLNK(table->mode)))
60326 res = proc_sys_link_fill_cache(file, ctx, head, table);
60327 else
60328 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
60329 if (IS_ERR(head))
60330 return PTR_ERR(head);
60331
60332 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
60333 + return -ENOENT;
60334 +
60335 generic_fillattr(inode, stat);
60336 if (table)
60337 stat->mode = (stat->mode & S_IFMT) | table->mode;
60338 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
60339 .llseek = generic_file_llseek,
60340 };
60341
60342 -static const struct inode_operations proc_sys_inode_operations = {
60343 +const struct inode_operations proc_sys_inode_operations = {
60344 .permission = proc_sys_permission,
60345 .setattr = proc_sys_setattr,
60346 .getattr = proc_sys_getattr,
60347 };
60348
60349 -static const struct inode_operations proc_sys_dir_operations = {
60350 +const struct inode_operations proc_sys_dir_operations = {
60351 .lookup = proc_sys_lookup,
60352 .permission = proc_sys_permission,
60353 .setattr = proc_sys_setattr,
60354 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
60355 static struct ctl_dir *new_dir(struct ctl_table_set *set,
60356 const char *name, int namelen)
60357 {
60358 - struct ctl_table *table;
60359 + ctl_table_no_const *table;
60360 struct ctl_dir *new;
60361 struct ctl_node *node;
60362 char *new_name;
60363 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
60364 return NULL;
60365
60366 node = (struct ctl_node *)(new + 1);
60367 - table = (struct ctl_table *)(node + 1);
60368 + table = (ctl_table_no_const *)(node + 1);
60369 new_name = (char *)(table + 2);
60370 memcpy(new_name, name, namelen);
60371 new_name[namelen] = '\0';
60372 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
60373 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
60374 struct ctl_table_root *link_root)
60375 {
60376 - struct ctl_table *link_table, *entry, *link;
60377 + ctl_table_no_const *link_table, *link;
60378 + struct ctl_table *entry;
60379 struct ctl_table_header *links;
60380 struct ctl_node *node;
60381 char *link_name;
60382 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
60383 return NULL;
60384
60385 node = (struct ctl_node *)(links + 1);
60386 - link_table = (struct ctl_table *)(node + nr_entries);
60387 + link_table = (ctl_table_no_const *)(node + nr_entries);
60388 link_name = (char *)&link_table[nr_entries + 1];
60389
60390 for (link = link_table, entry = table; entry->procname; link++, entry++) {
60391 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60392 struct ctl_table_header ***subheader, struct ctl_table_set *set,
60393 struct ctl_table *table)
60394 {
60395 - struct ctl_table *ctl_table_arg = NULL;
60396 - struct ctl_table *entry, *files;
60397 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
60398 + struct ctl_table *entry;
60399 int nr_files = 0;
60400 int nr_dirs = 0;
60401 int err = -ENOMEM;
60402 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60403 nr_files++;
60404 }
60405
60406 - files = table;
60407 /* If there are mixed files and directories we need a new table */
60408 if (nr_dirs && nr_files) {
60409 - struct ctl_table *new;
60410 + ctl_table_no_const *new;
60411 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
60412 GFP_KERNEL);
60413 if (!files)
60414 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60415 /* Register everything except a directory full of subdirectories */
60416 if (nr_files || !nr_dirs) {
60417 struct ctl_table_header *header;
60418 - header = __register_sysctl_table(set, path, files);
60419 + header = __register_sysctl_table(set, path, files ? files : table);
60420 if (!header) {
60421 kfree(ctl_table_arg);
60422 goto out;
60423 diff --git a/fs/proc/root.c b/fs/proc/root.c
60424 index 87dbcbe..55e1b4d 100644
60425 --- a/fs/proc/root.c
60426 +++ b/fs/proc/root.c
60427 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
60428 #ifdef CONFIG_PROC_DEVICETREE
60429 proc_device_tree_init();
60430 #endif
60431 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60432 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60433 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
60434 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60435 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
60436 +#endif
60437 +#else
60438 proc_mkdir("bus", NULL);
60439 +#endif
60440 proc_sys_init();
60441 }
60442
60443 diff --git a/fs/proc/self.c b/fs/proc/self.c
60444 index 6b6a993..807cccc 100644
60445 --- a/fs/proc/self.c
60446 +++ b/fs/proc/self.c
60447 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
60448 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
60449 void *cookie)
60450 {
60451 - char *s = nd_get_link(nd);
60452 + const char *s = nd_get_link(nd);
60453 if (!IS_ERR(s))
60454 kfree(s);
60455 }
60456 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
60457 index 390bdab..83c1e8a 100644
60458 --- a/fs/proc/task_mmu.c
60459 +++ b/fs/proc/task_mmu.c
60460 @@ -12,12 +12,19 @@
60461 #include <linux/swap.h>
60462 #include <linux/swapops.h>
60463 #include <linux/mmu_notifier.h>
60464 +#include <linux/grsecurity.h>
60465
60466 #include <asm/elf.h>
60467 #include <asm/uaccess.h>
60468 #include <asm/tlbflush.h>
60469 #include "internal.h"
60470
60471 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60472 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60473 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60474 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60475 +#endif
60476 +
60477 void task_mem(struct seq_file *m, struct mm_struct *mm)
60478 {
60479 unsigned long data, text, lib, swap;
60480 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60481 "VmExe:\t%8lu kB\n"
60482 "VmLib:\t%8lu kB\n"
60483 "VmPTE:\t%8lu kB\n"
60484 - "VmSwap:\t%8lu kB\n",
60485 - hiwater_vm << (PAGE_SHIFT-10),
60486 + "VmSwap:\t%8lu kB\n"
60487 +
60488 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60489 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
60490 +#endif
60491 +
60492 + ,hiwater_vm << (PAGE_SHIFT-10),
60493 total_vm << (PAGE_SHIFT-10),
60494 mm->locked_vm << (PAGE_SHIFT-10),
60495 mm->pinned_vm << (PAGE_SHIFT-10),
60496 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60497 data << (PAGE_SHIFT-10),
60498 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
60499 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60500 - swap << (PAGE_SHIFT-10));
60501 + swap << (PAGE_SHIFT-10)
60502 +
60503 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60504 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60505 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60506 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60507 +#else
60508 + , mm->context.user_cs_base
60509 + , mm->context.user_cs_limit
60510 +#endif
60511 +#endif
60512 +
60513 + );
60514 }
60515
60516 unsigned long task_vsize(struct mm_struct *mm)
60517 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60518 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60519 }
60520
60521 - /* We don't show the stack guard page in /proc/maps */
60522 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60523 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60524 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60525 +#else
60526 start = vma->vm_start;
60527 - if (stack_guard_page_start(vma, start))
60528 - start += PAGE_SIZE;
60529 end = vma->vm_end;
60530 - if (stack_guard_page_end(vma, end))
60531 - end -= PAGE_SIZE;
60532 +#endif
60533
60534 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60535 start,
60536 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60537 flags & VM_WRITE ? 'w' : '-',
60538 flags & VM_EXEC ? 'x' : '-',
60539 flags & VM_MAYSHARE ? 's' : 'p',
60540 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60541 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60542 +#else
60543 pgoff,
60544 +#endif
60545 MAJOR(dev), MINOR(dev), ino, &len);
60546
60547 /*
60548 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60549 */
60550 if (file) {
60551 pad_len_spaces(m, len);
60552 - seq_path(m, &file->f_path, "\n");
60553 + seq_path(m, &file->f_path, "\n\\");
60554 goto done;
60555 }
60556
60557 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60558 * Thread stack in /proc/PID/task/TID/maps or
60559 * the main process stack.
60560 */
60561 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60562 - vma->vm_end >= mm->start_stack)) {
60563 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60564 + (vma->vm_start <= mm->start_stack &&
60565 + vma->vm_end >= mm->start_stack)) {
60566 name = "[stack]";
60567 } else {
60568 /* Thread stack in /proc/PID/maps */
60569 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60570 struct proc_maps_private *priv = m->private;
60571 struct task_struct *task = priv->task;
60572
60573 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60574 + if (current->exec_id != m->exec_id) {
60575 + gr_log_badprocpid("maps");
60576 + return 0;
60577 + }
60578 +#endif
60579 +
60580 show_map_vma(m, vma, is_pid);
60581
60582 if (m->count < m->size) /* vma is copied successfully */
60583 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60584 .private = &mss,
60585 };
60586
60587 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60588 + if (current->exec_id != m->exec_id) {
60589 + gr_log_badprocpid("smaps");
60590 + return 0;
60591 + }
60592 +#endif
60593 memset(&mss, 0, sizeof mss);
60594 - mss.vma = vma;
60595 - /* mmap_sem is held in m_start */
60596 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60597 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60598 -
60599 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60600 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60601 +#endif
60602 + mss.vma = vma;
60603 + /* mmap_sem is held in m_start */
60604 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60605 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60606 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60607 + }
60608 +#endif
60609 show_map_vma(m, vma, is_pid);
60610
60611 seq_printf(m,
60612 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60613 "KernelPageSize: %8lu kB\n"
60614 "MMUPageSize: %8lu kB\n"
60615 "Locked: %8lu kB\n",
60616 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60617 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60618 +#else
60619 (vma->vm_end - vma->vm_start) >> 10,
60620 +#endif
60621 mss.resident >> 10,
60622 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60623 mss.shared_clean >> 10,
60624 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60625 int n;
60626 char buffer[50];
60627
60628 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60629 + if (current->exec_id != m->exec_id) {
60630 + gr_log_badprocpid("numa_maps");
60631 + return 0;
60632 + }
60633 +#endif
60634 +
60635 if (!mm)
60636 return 0;
60637
60638 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60639 if (n < 0)
60640 return n;
60641
60642 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60643 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60644 +#else
60645 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60646 +#endif
60647
60648 if (file) {
60649 seq_printf(m, " file=");
60650 - seq_path(m, &file->f_path, "\n\t= ");
60651 + seq_path(m, &file->f_path, "\n\t\\= ");
60652 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60653 seq_printf(m, " heap");
60654 } else {
60655 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60656 index 56123a6..5a2f6ec 100644
60657 --- a/fs/proc/task_nommu.c
60658 +++ b/fs/proc/task_nommu.c
60659 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60660 else
60661 bytes += kobjsize(mm);
60662
60663 - if (current->fs && current->fs->users > 1)
60664 + if (current->fs && atomic_read(&current->fs->users) > 1)
60665 sbytes += kobjsize(current->fs);
60666 else
60667 bytes += kobjsize(current->fs);
60668 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60669
60670 if (file) {
60671 pad_len_spaces(m, len);
60672 - seq_path(m, &file->f_path, "");
60673 + seq_path(m, &file->f_path, "\n\\");
60674 } else if (mm) {
60675 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60676
60677 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60678 index 9100d69..f1f9fc9 100644
60679 --- a/fs/proc/vmcore.c
60680 +++ b/fs/proc/vmcore.c
60681 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60682 nr_bytes = count;
60683
60684 /* If pfn is not ram, return zeros for sparse dump files */
60685 - if (pfn_is_ram(pfn) == 0)
60686 - memset(buf, 0, nr_bytes);
60687 - else {
60688 + if (pfn_is_ram(pfn) == 0) {
60689 + if (userbuf) {
60690 + if (clear_user((char __force_user *)buf, nr_bytes))
60691 + return -EFAULT;
60692 + } else
60693 + memset(buf, 0, nr_bytes);
60694 + } else {
60695 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60696 offset, userbuf);
60697 if (tmp < 0)
60698 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
60699 if (*fpos < m->offset + m->size) {
60700 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60701 start = m->paddr + *fpos - m->offset;
60702 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
60703 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
60704 if (tmp < 0)
60705 return tmp;
60706 buflen -= tsz;
60707 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60708 index b00fcc9..e0c6381 100644
60709 --- a/fs/qnx6/qnx6.h
60710 +++ b/fs/qnx6/qnx6.h
60711 @@ -74,7 +74,7 @@ enum {
60712 BYTESEX_BE,
60713 };
60714
60715 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60716 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60717 {
60718 if (sbi->s_bytesex == BYTESEX_LE)
60719 return le64_to_cpu((__force __le64)n);
60720 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60721 return (__force __fs64)cpu_to_be64(n);
60722 }
60723
60724 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60725 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60726 {
60727 if (sbi->s_bytesex == BYTESEX_LE)
60728 return le32_to_cpu((__force __le32)n);
60729 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60730 index 16e8abb..2dcf914 100644
60731 --- a/fs/quota/netlink.c
60732 +++ b/fs/quota/netlink.c
60733 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60734 void quota_send_warning(struct kqid qid, dev_t dev,
60735 const char warntype)
60736 {
60737 - static atomic_t seq;
60738 + static atomic_unchecked_t seq;
60739 struct sk_buff *skb;
60740 void *msg_head;
60741 int ret;
60742 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60743 "VFS: Not enough memory to send quota warning.\n");
60744 return;
60745 }
60746 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60747 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60748 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60749 if (!msg_head) {
60750 printk(KERN_ERR
60751 diff --git a/fs/read_write.c b/fs/read_write.c
60752 index e3cd280..a378473 100644
60753 --- a/fs/read_write.c
60754 +++ b/fs/read_write.c
60755 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60756
60757 old_fs = get_fs();
60758 set_fs(get_ds());
60759 - p = (__force const char __user *)buf;
60760 + p = (const char __force_user *)buf;
60761 if (count > MAX_RW_COUNT)
60762 count = MAX_RW_COUNT;
60763 if (file->f_op->write)
60764 diff --git a/fs/readdir.c b/fs/readdir.c
60765 index 93d71e5..6a14be8 100644
60766 --- a/fs/readdir.c
60767 +++ b/fs/readdir.c
60768 @@ -17,6 +17,7 @@
60769 #include <linux/security.h>
60770 #include <linux/syscalls.h>
60771 #include <linux/unistd.h>
60772 +#include <linux/namei.h>
60773
60774 #include <asm/uaccess.h>
60775
60776 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60777 struct readdir_callback {
60778 struct dir_context ctx;
60779 struct old_linux_dirent __user * dirent;
60780 + struct file * file;
60781 int result;
60782 };
60783
60784 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60785 buf->result = -EOVERFLOW;
60786 return -EOVERFLOW;
60787 }
60788 +
60789 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60790 + return 0;
60791 +
60792 buf->result++;
60793 dirent = buf->dirent;
60794 if (!access_ok(VERIFY_WRITE, dirent,
60795 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60796 if (!f.file)
60797 return -EBADF;
60798
60799 + buf.file = f.file;
60800 error = iterate_dir(f.file, &buf.ctx);
60801 if (buf.result)
60802 error = buf.result;
60803 @@ -142,6 +149,7 @@ struct getdents_callback {
60804 struct dir_context ctx;
60805 struct linux_dirent __user * current_dir;
60806 struct linux_dirent __user * previous;
60807 + struct file * file;
60808 int count;
60809 int error;
60810 };
60811 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60812 buf->error = -EOVERFLOW;
60813 return -EOVERFLOW;
60814 }
60815 +
60816 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60817 + return 0;
60818 +
60819 dirent = buf->previous;
60820 if (dirent) {
60821 if (__put_user(offset, &dirent->d_off))
60822 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60823 if (!f.file)
60824 return -EBADF;
60825
60826 + buf.file = f.file;
60827 error = iterate_dir(f.file, &buf.ctx);
60828 if (error >= 0)
60829 error = buf.error;
60830 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60831 struct dir_context ctx;
60832 struct linux_dirent64 __user * current_dir;
60833 struct linux_dirent64 __user * previous;
60834 + struct file *file;
60835 int count;
60836 int error;
60837 };
60838 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60839 buf->error = -EINVAL; /* only used if we fail.. */
60840 if (reclen > buf->count)
60841 return -EINVAL;
60842 +
60843 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60844 + return 0;
60845 +
60846 dirent = buf->previous;
60847 if (dirent) {
60848 if (__put_user(offset, &dirent->d_off))
60849 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60850 if (!f.file)
60851 return -EBADF;
60852
60853 + buf.file = f.file;
60854 error = iterate_dir(f.file, &buf.ctx);
60855 if (error >= 0)
60856 error = buf.error;
60857 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60858 index 2b7882b..1c5ef48 100644
60859 --- a/fs/reiserfs/do_balan.c
60860 +++ b/fs/reiserfs/do_balan.c
60861 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60862 return;
60863 }
60864
60865 - atomic_inc(&(fs_generation(tb->tb_sb)));
60866 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60867 do_balance_starts(tb);
60868
60869 /* balance leaf returns 0 except if combining L R and S into
60870 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60871 index a958444..42b2323 100644
60872 --- a/fs/reiserfs/procfs.c
60873 +++ b/fs/reiserfs/procfs.c
60874 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60875 "SMALL_TAILS " : "NO_TAILS ",
60876 replay_only(sb) ? "REPLAY_ONLY " : "",
60877 convert_reiserfs(sb) ? "CONV " : "",
60878 - atomic_read(&r->s_generation_counter),
60879 + atomic_read_unchecked(&r->s_generation_counter),
60880 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60881 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60882 SF(s_good_search_by_key_reada), SF(s_bmaps),
60883 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60884 index f8adaee..0eeeeca 100644
60885 --- a/fs/reiserfs/reiserfs.h
60886 +++ b/fs/reiserfs/reiserfs.h
60887 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60888 /* Comment? -Hans */
60889 wait_queue_head_t s_wait;
60890 /* To be obsoleted soon by per buffer seals.. -Hans */
60891 - atomic_t s_generation_counter; // increased by one every time the
60892 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60893 // tree gets re-balanced
60894 unsigned long s_properties; /* File system properties. Currently holds
60895 on-disk FS format */
60896 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60897 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60898
60899 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60900 -#define get_generation(s) atomic_read (&fs_generation(s))
60901 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60902 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60903 #define __fs_changed(gen,s) (gen != get_generation (s))
60904 #define fs_changed(gen,s) \
60905 diff --git a/fs/select.c b/fs/select.c
60906 index dfd5cb1..1754d57 100644
60907 --- a/fs/select.c
60908 +++ b/fs/select.c
60909 @@ -20,6 +20,7 @@
60910 #include <linux/export.h>
60911 #include <linux/slab.h>
60912 #include <linux/poll.h>
60913 +#include <linux/security.h>
60914 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60915 #include <linux/file.h>
60916 #include <linux/fdtable.h>
60917 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60918 struct poll_list *walk = head;
60919 unsigned long todo = nfds;
60920
60921 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60922 if (nfds > rlimit(RLIMIT_NOFILE))
60923 return -EINVAL;
60924
60925 diff --git a/fs/seq_file.c b/fs/seq_file.c
60926 index a290157..ec3211a 100644
60927 --- a/fs/seq_file.c
60928 +++ b/fs/seq_file.c
60929 @@ -10,6 +10,7 @@
60930 #include <linux/seq_file.h>
60931 #include <linux/slab.h>
60932 #include <linux/cred.h>
60933 +#include <linux/sched.h>
60934
60935 #include <asm/uaccess.h>
60936 #include <asm/page.h>
60937 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60938 #ifdef CONFIG_USER_NS
60939 p->user_ns = file->f_cred->user_ns;
60940 #endif
60941 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60942 + p->exec_id = current->exec_id;
60943 +#endif
60944
60945 /*
60946 * Wrappers around seq_open(e.g. swaps_open) need to be
60947 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60948 return 0;
60949 }
60950 if (!m->buf) {
60951 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60952 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60953 if (!m->buf)
60954 return -ENOMEM;
60955 }
60956 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60957 Eoverflow:
60958 m->op->stop(m, p);
60959 kfree(m->buf);
60960 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60961 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60962 return !m->buf ? -ENOMEM : -EAGAIN;
60963 }
60964
60965 @@ -152,7 +156,7 @@ Eoverflow:
60966 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60967 {
60968 struct seq_file *m = file->private_data;
60969 - size_t copied = 0;
60970 + ssize_t copied = 0;
60971 loff_t pos;
60972 size_t n;
60973 void *p;
60974 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60975
60976 /* grab buffer if we didn't have one */
60977 if (!m->buf) {
60978 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60979 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60980 if (!m->buf)
60981 goto Enomem;
60982 }
60983 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60984 goto Fill;
60985 m->op->stop(m, p);
60986 kfree(m->buf);
60987 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60988 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60989 if (!m->buf)
60990 goto Enomem;
60991 m->count = 0;
60992 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
60993 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60994 void *data)
60995 {
60996 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60997 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60998 int res = -ENOMEM;
60999
61000 if (op) {
61001 diff --git a/fs/splice.c b/fs/splice.c
61002 index 3b7ee65..87fc2e4 100644
61003 --- a/fs/splice.c
61004 +++ b/fs/splice.c
61005 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61006 pipe_lock(pipe);
61007
61008 for (;;) {
61009 - if (!pipe->readers) {
61010 + if (!atomic_read(&pipe->readers)) {
61011 send_sig(SIGPIPE, current, 0);
61012 if (!ret)
61013 ret = -EPIPE;
61014 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61015 page_nr++;
61016 ret += buf->len;
61017
61018 - if (pipe->files)
61019 + if (atomic_read(&pipe->files))
61020 do_wakeup = 1;
61021
61022 if (!--spd->nr_pages)
61023 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61024 do_wakeup = 0;
61025 }
61026
61027 - pipe->waiting_writers++;
61028 + atomic_inc(&pipe->waiting_writers);
61029 pipe_wait(pipe);
61030 - pipe->waiting_writers--;
61031 + atomic_dec(&pipe->waiting_writers);
61032 }
61033
61034 pipe_unlock(pipe);
61035 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61036 old_fs = get_fs();
61037 set_fs(get_ds());
61038 /* The cast to a user pointer is valid due to the set_fs() */
61039 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61040 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61041 set_fs(old_fs);
61042
61043 return res;
61044 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61045 old_fs = get_fs();
61046 set_fs(get_ds());
61047 /* The cast to a user pointer is valid due to the set_fs() */
61048 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61049 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61050 set_fs(old_fs);
61051
61052 return res;
61053 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61054 goto err;
61055
61056 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61057 - vec[i].iov_base = (void __user *) page_address(page);
61058 + vec[i].iov_base = (void __force_user *) page_address(page);
61059 vec[i].iov_len = this_len;
61060 spd.pages[i] = page;
61061 spd.nr_pages++;
61062 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61063 ops->release(pipe, buf);
61064 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61065 pipe->nrbufs--;
61066 - if (pipe->files)
61067 + if (atomic_read(&pipe->files))
61068 sd->need_wakeup = true;
61069 }
61070
61071 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61072 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61073 {
61074 while (!pipe->nrbufs) {
61075 - if (!pipe->writers)
61076 + if (!atomic_read(&pipe->writers))
61077 return 0;
61078
61079 - if (!pipe->waiting_writers && sd->num_spliced)
61080 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61081 return 0;
61082
61083 if (sd->flags & SPLICE_F_NONBLOCK)
61084 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61085 * out of the pipe right after the splice_to_pipe(). So set
61086 * PIPE_READERS appropriately.
61087 */
61088 - pipe->readers = 1;
61089 + atomic_set(&pipe->readers, 1);
61090
61091 current->splice_pipe = pipe;
61092 }
61093 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
61094
61095 partial[buffers].offset = off;
61096 partial[buffers].len = plen;
61097 + partial[buffers].private = 0;
61098
61099 off = 0;
61100 len -= plen;
61101 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61102 ret = -ERESTARTSYS;
61103 break;
61104 }
61105 - if (!pipe->writers)
61106 + if (!atomic_read(&pipe->writers))
61107 break;
61108 - if (!pipe->waiting_writers) {
61109 + if (!atomic_read(&pipe->waiting_writers)) {
61110 if (flags & SPLICE_F_NONBLOCK) {
61111 ret = -EAGAIN;
61112 break;
61113 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61114 pipe_lock(pipe);
61115
61116 while (pipe->nrbufs >= pipe->buffers) {
61117 - if (!pipe->readers) {
61118 + if (!atomic_read(&pipe->readers)) {
61119 send_sig(SIGPIPE, current, 0);
61120 ret = -EPIPE;
61121 break;
61122 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61123 ret = -ERESTARTSYS;
61124 break;
61125 }
61126 - pipe->waiting_writers++;
61127 + atomic_inc(&pipe->waiting_writers);
61128 pipe_wait(pipe);
61129 - pipe->waiting_writers--;
61130 + atomic_dec(&pipe->waiting_writers);
61131 }
61132
61133 pipe_unlock(pipe);
61134 @@ -1862,14 +1863,14 @@ retry:
61135 pipe_double_lock(ipipe, opipe);
61136
61137 do {
61138 - if (!opipe->readers) {
61139 + if (!atomic_read(&opipe->readers)) {
61140 send_sig(SIGPIPE, current, 0);
61141 if (!ret)
61142 ret = -EPIPE;
61143 break;
61144 }
61145
61146 - if (!ipipe->nrbufs && !ipipe->writers)
61147 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
61148 break;
61149
61150 /*
61151 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61152 pipe_double_lock(ipipe, opipe);
61153
61154 do {
61155 - if (!opipe->readers) {
61156 + if (!atomic_read(&opipe->readers)) {
61157 send_sig(SIGPIPE, current, 0);
61158 if (!ret)
61159 ret = -EPIPE;
61160 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61161 * return EAGAIN if we have the potential of some data in the
61162 * future, otherwise just return 0
61163 */
61164 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
61165 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
61166 ret = -EAGAIN;
61167
61168 pipe_unlock(ipipe);
61169 diff --git a/fs/stat.c b/fs/stat.c
61170 index d0ea7ef..f463f9d 100644
61171 --- a/fs/stat.c
61172 +++ b/fs/stat.c
61173 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
61174 stat->gid = inode->i_gid;
61175 stat->rdev = inode->i_rdev;
61176 stat->size = i_size_read(inode);
61177 - stat->atime = inode->i_atime;
61178 - stat->mtime = inode->i_mtime;
61179 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61180 + stat->atime = inode->i_ctime;
61181 + stat->mtime = inode->i_ctime;
61182 + } else {
61183 + stat->atime = inode->i_atime;
61184 + stat->mtime = inode->i_mtime;
61185 + }
61186 stat->ctime = inode->i_ctime;
61187 stat->blksize = (1 << inode->i_blkbits);
61188 stat->blocks = inode->i_blocks;
61189 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
61190 if (retval)
61191 return retval;
61192
61193 - if (inode->i_op->getattr)
61194 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
61195 + if (inode->i_op->getattr) {
61196 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
61197 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61198 + stat->atime = stat->ctime;
61199 + stat->mtime = stat->ctime;
61200 + }
61201 + return retval;
61202 + }
61203
61204 generic_fillattr(inode, stat);
61205 return 0;
61206 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
61207 index c590cab..6dfd6fc 100644
61208 --- a/fs/sysfs/bin.c
61209 +++ b/fs/sysfs/bin.c
61210 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
61211 return ret;
61212 }
61213
61214 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
61215 - void *buf, int len, int write)
61216 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
61217 + void *buf, size_t len, int write)
61218 {
61219 struct file *file = vma->vm_file;
61220 struct bin_buffer *bb = file->private_data;
61221 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
61222 - int ret;
61223 + ssize_t ret;
61224
61225 if (!bb->vm_ops)
61226 return -EINVAL;
61227 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
61228 index 4d83ced..049dc45 100644
61229 --- a/fs/sysfs/dir.c
61230 +++ b/fs/sysfs/dir.c
61231 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
61232 *
61233 * Returns 31 bit hash of ns + name (so it fits in an off_t )
61234 */
61235 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
61236 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
61237 {
61238 unsigned long hash = init_name_hash();
61239 unsigned int len = strlen(name);
61240 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
61241 struct sysfs_dirent *sd;
61242 int rc;
61243
61244 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
61245 + const char *parent_name = parent_sd->s_name;
61246 +
61247 + mode = S_IFDIR | S_IRWXU;
61248 +
61249 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
61250 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
61251 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
61252 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
61253 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
61254 +#endif
61255 +
61256 /* allocate */
61257 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
61258 if (!sd)
61259 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
61260 index 15ef5eb..e474372 100644
61261 --- a/fs/sysfs/file.c
61262 +++ b/fs/sysfs/file.c
61263 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
61264
61265 struct sysfs_open_dirent {
61266 atomic_t refcnt;
61267 - atomic_t event;
61268 + atomic_unchecked_t event;
61269 wait_queue_head_t poll;
61270 struct list_head buffers; /* goes through sysfs_buffer.list */
61271 };
61272 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
61273 if (!sysfs_get_active(attr_sd))
61274 return -ENODEV;
61275
61276 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
61277 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
61278 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
61279
61280 sysfs_put_active(attr_sd);
61281 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
61282 return -ENOMEM;
61283
61284 atomic_set(&new_od->refcnt, 0);
61285 - atomic_set(&new_od->event, 1);
61286 + atomic_set_unchecked(&new_od->event, 1);
61287 init_waitqueue_head(&new_od->poll);
61288 INIT_LIST_HEAD(&new_od->buffers);
61289 goto retry;
61290 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
61291
61292 sysfs_put_active(attr_sd);
61293
61294 - if (buffer->event != atomic_read(&od->event))
61295 + if (buffer->event != atomic_read_unchecked(&od->event))
61296 goto trigger;
61297
61298 return DEFAULT_POLLMASK;
61299 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
61300 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
61301 od = sd->s_attr.open;
61302 if (od) {
61303 - atomic_inc(&od->event);
61304 + atomic_inc_unchecked(&od->event);
61305 wake_up_interruptible(&od->poll);
61306 }
61307 }
61308 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
61309 index 2dd4507..62a215a 100644
61310 --- a/fs/sysfs/symlink.c
61311 +++ b/fs/sysfs/symlink.c
61312 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
61313 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
61314 void *cookie)
61315 {
61316 - char *page = nd_get_link(nd);
61317 + const char *page = nd_get_link(nd);
61318 if (!IS_ERR(page))
61319 free_page((unsigned long)page);
61320 }
61321 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
61322 index 69d4889..a810bd4 100644
61323 --- a/fs/sysv/sysv.h
61324 +++ b/fs/sysv/sysv.h
61325 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
61326 #endif
61327 }
61328
61329 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61330 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61331 {
61332 if (sbi->s_bytesex == BYTESEX_PDP)
61333 return PDP_swab((__force __u32)n);
61334 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
61335 index e18b988..f1d4ad0f 100644
61336 --- a/fs/ubifs/io.c
61337 +++ b/fs/ubifs/io.c
61338 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
61339 return err;
61340 }
61341
61342 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61343 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61344 {
61345 int err;
61346
61347 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
61348 index c175b4d..8f36a16 100644
61349 --- a/fs/udf/misc.c
61350 +++ b/fs/udf/misc.c
61351 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
61352
61353 u8 udf_tag_checksum(const struct tag *t)
61354 {
61355 - u8 *data = (u8 *)t;
61356 + const u8 *data = (const u8 *)t;
61357 u8 checksum = 0;
61358 int i;
61359 for (i = 0; i < sizeof(struct tag); ++i)
61360 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
61361 index 8d974c4..b82f6ec 100644
61362 --- a/fs/ufs/swab.h
61363 +++ b/fs/ufs/swab.h
61364 @@ -22,7 +22,7 @@ enum {
61365 BYTESEX_BE
61366 };
61367
61368 -static inline u64
61369 +static inline u64 __intentional_overflow(-1)
61370 fs64_to_cpu(struct super_block *sbp, __fs64 n)
61371 {
61372 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61373 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
61374 return (__force __fs64)cpu_to_be64(n);
61375 }
61376
61377 -static inline u32
61378 +static inline u32 __intentional_overflow(-1)
61379 fs32_to_cpu(struct super_block *sbp, __fs32 n)
61380 {
61381 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61382 diff --git a/fs/utimes.c b/fs/utimes.c
61383 index f4fb7ec..3fe03c0 100644
61384 --- a/fs/utimes.c
61385 +++ b/fs/utimes.c
61386 @@ -1,6 +1,7 @@
61387 #include <linux/compiler.h>
61388 #include <linux/file.h>
61389 #include <linux/fs.h>
61390 +#include <linux/security.h>
61391 #include <linux/linkage.h>
61392 #include <linux/mount.h>
61393 #include <linux/namei.h>
61394 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
61395 goto mnt_drop_write_and_out;
61396 }
61397 }
61398 +
61399 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
61400 + error = -EACCES;
61401 + goto mnt_drop_write_and_out;
61402 + }
61403 +
61404 mutex_lock(&inode->i_mutex);
61405 error = notify_change(path->dentry, &newattrs);
61406 mutex_unlock(&inode->i_mutex);
61407 diff --git a/fs/xattr.c b/fs/xattr.c
61408 index 3377dff..4d074d9 100644
61409 --- a/fs/xattr.c
61410 +++ b/fs/xattr.c
61411 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
61412 return rc;
61413 }
61414
61415 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
61416 +ssize_t
61417 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
61418 +{
61419 + struct inode *inode = dentry->d_inode;
61420 + ssize_t error;
61421 +
61422 + error = inode_permission(inode, MAY_EXEC);
61423 + if (error)
61424 + return error;
61425 +
61426 + if (inode->i_op->getxattr)
61427 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
61428 + else
61429 + error = -EOPNOTSUPP;
61430 +
61431 + return error;
61432 +}
61433 +EXPORT_SYMBOL(pax_getxattr);
61434 +#endif
61435 +
61436 ssize_t
61437 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
61438 {
61439 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
61440 * Extended attribute SET operations
61441 */
61442 static long
61443 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
61444 +setxattr(struct path *path, const char __user *name, const void __user *value,
61445 size_t size, int flags)
61446 {
61447 int error;
61448 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
61449 posix_acl_fix_xattr_from_user(kvalue, size);
61450 }
61451
61452 - error = vfs_setxattr(d, kname, kvalue, size, flags);
61453 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
61454 + error = -EACCES;
61455 + goto out;
61456 + }
61457 +
61458 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
61459 out:
61460 if (vvalue)
61461 vfree(vvalue);
61462 @@ -377,7 +403,7 @@ retry:
61463 return error;
61464 error = mnt_want_write(path.mnt);
61465 if (!error) {
61466 - error = setxattr(path.dentry, name, value, size, flags);
61467 + error = setxattr(&path, name, value, size, flags);
61468 mnt_drop_write(path.mnt);
61469 }
61470 path_put(&path);
61471 @@ -401,7 +427,7 @@ retry:
61472 return error;
61473 error = mnt_want_write(path.mnt);
61474 if (!error) {
61475 - error = setxattr(path.dentry, name, value, size, flags);
61476 + error = setxattr(&path, name, value, size, flags);
61477 mnt_drop_write(path.mnt);
61478 }
61479 path_put(&path);
61480 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
61481 const void __user *,value, size_t, size, int, flags)
61482 {
61483 struct fd f = fdget(fd);
61484 - struct dentry *dentry;
61485 int error = -EBADF;
61486
61487 if (!f.file)
61488 return error;
61489 - dentry = f.file->f_path.dentry;
61490 - audit_inode(NULL, dentry, 0);
61491 + audit_inode(NULL, f.file->f_path.dentry, 0);
61492 error = mnt_want_write_file(f.file);
61493 if (!error) {
61494 - error = setxattr(dentry, name, value, size, flags);
61495 + error = setxattr(&f.file->f_path, name, value, size, flags);
61496 mnt_drop_write_file(f.file);
61497 }
61498 fdput(f);
61499 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
61500 index 9fbea87..6b19972 100644
61501 --- a/fs/xattr_acl.c
61502 +++ b/fs/xattr_acl.c
61503 @@ -76,8 +76,8 @@ struct posix_acl *
61504 posix_acl_from_xattr(struct user_namespace *user_ns,
61505 const void *value, size_t size)
61506 {
61507 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
61508 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61509 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61510 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61511 int count;
61512 struct posix_acl *acl;
61513 struct posix_acl_entry *acl_e;
61514 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61515 index f47e65c..e7125d9 100644
61516 --- a/fs/xfs/xfs_bmap.c
61517 +++ b/fs/xfs/xfs_bmap.c
61518 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
61519
61520 #else
61521 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61522 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61523 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61524 #endif /* DEBUG */
61525
61526 /*
61527 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
61528 index 8f84153..7ce60d0 100644
61529 --- a/fs/xfs/xfs_dir2_readdir.c
61530 +++ b/fs/xfs/xfs_dir2_readdir.c
61531 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
61532 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
61533 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
61534 ctx->pos = off & 0x7fffffff;
61535 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61536 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61537 + char name[sfep->namelen];
61538 + memcpy(name, sfep->name, sfep->namelen);
61539 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
61540 + return 0;
61541 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61542 xfs_dir3_get_dtype(mp, filetype)))
61543 return 0;
61544 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
61545 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61546 index 668e8f4..9d38104 100644
61547 --- a/fs/xfs/xfs_ioctl.c
61548 +++ b/fs/xfs/xfs_ioctl.c
61549 @@ -127,7 +127,7 @@ xfs_find_handle(
61550 }
61551
61552 error = -EFAULT;
61553 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61554 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61555 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61556 goto out_put;
61557
61558 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61559 index 2b8952d..a60c6be 100644
61560 --- a/fs/xfs/xfs_iops.c
61561 +++ b/fs/xfs/xfs_iops.c
61562 @@ -401,7 +401,7 @@ xfs_vn_put_link(
61563 struct nameidata *nd,
61564 void *p)
61565 {
61566 - char *s = nd_get_link(nd);
61567 + const char *s = nd_get_link(nd);
61568
61569 if (!IS_ERR(s))
61570 kfree(s);
61571 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61572 new file mode 100644
61573 index 0000000..6d22fbe
61574 --- /dev/null
61575 +++ b/grsecurity/Kconfig
61576 @@ -0,0 +1,1112 @@
61577 +#
61578 +# grecurity configuration
61579 +#
61580 +menu "Memory Protections"
61581 +depends on GRKERNSEC
61582 +
61583 +config GRKERNSEC_KMEM
61584 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61585 + default y if GRKERNSEC_CONFIG_AUTO
61586 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61587 + help
61588 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61589 + be written to or read from to modify or leak the contents of the running
61590 + kernel. /dev/port will also not be allowed to be opened and support
61591 + for /dev/cpu/*/msr will be removed. If you have module
61592 + support disabled, enabling this will close up five ways that are
61593 + currently used to insert malicious code into the running kernel.
61594 +
61595 + Even with all these features enabled, we still highly recommend that
61596 + you use the RBAC system, as it is still possible for an attacker to
61597 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61598 +
61599 + If you are not using XFree86, you may be able to stop this additional
61600 + case by enabling the 'Disable privileged I/O' option. Though nothing
61601 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61602 + but only to video memory, which is the only writing we allow in this
61603 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61604 + not be allowed to mprotect it with PROT_WRITE later.
61605 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61606 + from working.
61607 +
61608 + It is highly recommended that you say Y here if you meet all the
61609 + conditions above.
61610 +
61611 +config GRKERNSEC_VM86
61612 + bool "Restrict VM86 mode"
61613 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61614 + depends on X86_32
61615 +
61616 + help
61617 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61618 + make use of a special execution mode on 32bit x86 processors called
61619 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61620 + video cards and will still work with this option enabled. The purpose
61621 + of the option is to prevent exploitation of emulation errors in
61622 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61623 + Nearly all users should be able to enable this option.
61624 +
61625 +config GRKERNSEC_IO
61626 + bool "Disable privileged I/O"
61627 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61628 + depends on X86
61629 + select RTC_CLASS
61630 + select RTC_INTF_DEV
61631 + select RTC_DRV_CMOS
61632 +
61633 + help
61634 + If you say Y here, all ioperm and iopl calls will return an error.
61635 + Ioperm and iopl can be used to modify the running kernel.
61636 + Unfortunately, some programs need this access to operate properly,
61637 + the most notable of which are XFree86 and hwclock. hwclock can be
61638 + remedied by having RTC support in the kernel, so real-time
61639 + clock support is enabled if this option is enabled, to ensure
61640 + that hwclock operates correctly. XFree86 still will not
61641 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61642 + IF YOU USE XFree86. If you use XFree86 and you still want to
61643 + protect your kernel against modification, use the RBAC system.
61644 +
61645 +config GRKERNSEC_JIT_HARDEN
61646 + bool "Harden BPF JIT against spray attacks"
61647 + default y if GRKERNSEC_CONFIG_AUTO
61648 + depends on BPF_JIT
61649 + help
61650 + If you say Y here, the native code generated by the kernel's Berkeley
61651 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61652 + attacks that attempt to fit attacker-beneficial instructions in
61653 + 32bit immediate fields of JIT-generated native instructions. The
61654 + attacker will generally aim to cause an unintended instruction sequence
61655 + of JIT-generated native code to execute by jumping into the middle of
61656 + a generated instruction. This feature effectively randomizes the 32bit
61657 + immediate constants present in the generated code to thwart such attacks.
61658 +
61659 + If you're using KERNEXEC, it's recommended that you enable this option
61660 + to supplement the hardening of the kernel.
61661 +
61662 +config GRKERNSEC_PERF_HARDEN
61663 + bool "Disable unprivileged PERF_EVENTS usage by default"
61664 + default y if GRKERNSEC_CONFIG_AUTO
61665 + depends on PERF_EVENTS
61666 + help
61667 + If you say Y here, the range of acceptable values for the
61668 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61669 + default to a new value: 3. When the sysctl is set to this value, no
61670 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61671 +
61672 + Though PERF_EVENTS can be used legitimately for performance monitoring
61673 + and low-level application profiling, it is forced on regardless of
61674 + configuration, has been at fault for several vulnerabilities, and
61675 + creates new opportunities for side channels and other information leaks.
61676 +
61677 + This feature puts PERF_EVENTS into a secure default state and permits
61678 + the administrator to change out of it temporarily if unprivileged
61679 + application profiling is needed.
61680 +
61681 +config GRKERNSEC_RAND_THREADSTACK
61682 + bool "Insert random gaps between thread stacks"
61683 + default y if GRKERNSEC_CONFIG_AUTO
61684 + depends on PAX_RANDMMAP && !PPC
61685 + help
61686 + If you say Y here, a random-sized gap will be enforced between allocated
61687 + thread stacks. Glibc's NPTL and other threading libraries that
61688 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61689 + The implementation currently provides 8 bits of entropy for the gap.
61690 +
61691 + Many distributions do not compile threaded remote services with the
61692 + -fstack-check argument to GCC, causing the variable-sized stack-based
61693 + allocator, alloca(), to not probe the stack on allocation. This
61694 + permits an unbounded alloca() to skip over any guard page and potentially
61695 + modify another thread's stack reliably. An enforced random gap
61696 + reduces the reliability of such an attack and increases the chance
61697 + that such a read/write to another thread's stack instead lands in
61698 + an unmapped area, causing a crash and triggering grsecurity's
61699 + anti-bruteforcing logic.
61700 +
61701 +config GRKERNSEC_PROC_MEMMAP
61702 + bool "Harden ASLR against information leaks and entropy reduction"
61703 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61704 + depends on PAX_NOEXEC || PAX_ASLR
61705 + help
61706 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61707 + give no information about the addresses of its mappings if
61708 + PaX features that rely on random addresses are enabled on the task.
61709 + In addition to sanitizing this information and disabling other
61710 + dangerous sources of information, this option causes reads of sensitive
61711 + /proc/<pid> entries where the file descriptor was opened in a different
61712 + task than the one performing the read. Such attempts are logged.
61713 + This option also limits argv/env strings for suid/sgid binaries
61714 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61715 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61716 + binaries to prevent alternative mmap layouts from being abused.
61717 +
61718 + If you use PaX it is essential that you say Y here as it closes up
61719 + several holes that make full ASLR useless locally.
61720 +
61721 +config GRKERNSEC_BRUTE
61722 + bool "Deter exploit bruteforcing"
61723 + default y if GRKERNSEC_CONFIG_AUTO
61724 + help
61725 + If you say Y here, attempts to bruteforce exploits against forking
61726 + daemons such as apache or sshd, as well as against suid/sgid binaries
61727 + will be deterred. When a child of a forking daemon is killed by PaX
61728 + or crashes due to an illegal instruction or other suspicious signal,
61729 + the parent process will be delayed 30 seconds upon every subsequent
61730 + fork until the administrator is able to assess the situation and
61731 + restart the daemon.
61732 + In the suid/sgid case, the attempt is logged, the user has all their
61733 + existing instances of the suid/sgid binary terminated and will
61734 + be unable to execute any suid/sgid binaries for 15 minutes.
61735 +
61736 + It is recommended that you also enable signal logging in the auditing
61737 + section so that logs are generated when a process triggers a suspicious
61738 + signal.
61739 + If the sysctl option is enabled, a sysctl option with name
61740 + "deter_bruteforce" is created.
61741 +
61742 +
61743 +config GRKERNSEC_MODHARDEN
61744 + bool "Harden module auto-loading"
61745 + default y if GRKERNSEC_CONFIG_AUTO
61746 + depends on MODULES
61747 + help
61748 + If you say Y here, module auto-loading in response to use of some
61749 + feature implemented by an unloaded module will be restricted to
61750 + root users. Enabling this option helps defend against attacks
61751 + by unprivileged users who abuse the auto-loading behavior to
61752 + cause a vulnerable module to load that is then exploited.
61753 +
61754 + If this option prevents a legitimate use of auto-loading for a
61755 + non-root user, the administrator can execute modprobe manually
61756 + with the exact name of the module mentioned in the alert log.
61757 + Alternatively, the administrator can add the module to the list
61758 + of modules loaded at boot by modifying init scripts.
61759 +
61760 + Modification of init scripts will most likely be needed on
61761 + Ubuntu servers with encrypted home directory support enabled,
61762 + as the first non-root user logging in will cause the ecb(aes),
61763 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61764 +
61765 +config GRKERNSEC_HIDESYM
61766 + bool "Hide kernel symbols"
61767 + default y if GRKERNSEC_CONFIG_AUTO
61768 + select PAX_USERCOPY_SLABS
61769 + help
61770 + If you say Y here, getting information on loaded modules, and
61771 + displaying all kernel symbols through a syscall will be restricted
61772 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61773 + /proc/kallsyms will be restricted to the root user. The RBAC
61774 + system can hide that entry even from root.
61775 +
61776 + This option also prevents leaking of kernel addresses through
61777 + several /proc entries.
61778 +
61779 + Note that this option is only effective provided the following
61780 + conditions are met:
61781 + 1) The kernel using grsecurity is not precompiled by some distribution
61782 + 2) You have also enabled GRKERNSEC_DMESG
61783 + 3) You are using the RBAC system and hiding other files such as your
61784 + kernel image and System.map. Alternatively, enabling this option
61785 + causes the permissions on /boot, /lib/modules, and the kernel
61786 + source directory to change at compile time to prevent
61787 + reading by non-root users.
61788 + If the above conditions are met, this option will aid in providing a
61789 + useful protection against local kernel exploitation of overflows
61790 + and arbitrary read/write vulnerabilities.
61791 +
61792 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61793 + in addition to this feature.
61794 +
61795 +config GRKERNSEC_KERN_LOCKOUT
61796 + bool "Active kernel exploit response"
61797 + default y if GRKERNSEC_CONFIG_AUTO
61798 + depends on X86 || ARM || PPC || SPARC
61799 + help
61800 + If you say Y here, when a PaX alert is triggered due to suspicious
61801 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61802 + or an OOPS occurs due to bad memory accesses, instead of just
61803 + terminating the offending process (and potentially allowing
61804 + a subsequent exploit from the same user), we will take one of two
61805 + actions:
61806 + If the user was root, we will panic the system
61807 + If the user was non-root, we will log the attempt, terminate
61808 + all processes owned by the user, then prevent them from creating
61809 + any new processes until the system is restarted
61810 + This deters repeated kernel exploitation/bruteforcing attempts
61811 + and is useful for later forensics.
61812 +
61813 +config GRKERNSEC_OLD_ARM_USERLAND
61814 + bool "Old ARM userland compatibility"
61815 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61816 + help
61817 + If you say Y here, stubs of executable code to perform such operations
61818 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61819 + table. This is unfortunately needed for old ARM userland meant to run
61820 + across a wide range of processors. Without this option enabled,
61821 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61822 + which is enough for Linaro userlands or other userlands designed for v6
61823 + and newer ARM CPUs. It's recommended that you try without this option enabled
61824 + first, and only enable it if your userland does not boot (it will likely fail
61825 + at init time).
61826 +
61827 +endmenu
61828 +menu "Role Based Access Control Options"
61829 +depends on GRKERNSEC
61830 +
61831 +config GRKERNSEC_RBAC_DEBUG
61832 + bool
61833 +
61834 +config GRKERNSEC_NO_RBAC
61835 + bool "Disable RBAC system"
61836 + help
61837 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61838 + preventing the RBAC system from being enabled. You should only say Y
61839 + here if you have no intention of using the RBAC system, so as to prevent
61840 + an attacker with root access from misusing the RBAC system to hide files
61841 + and processes when loadable module support and /dev/[k]mem have been
61842 + locked down.
61843 +
61844 +config GRKERNSEC_ACL_HIDEKERN
61845 + bool "Hide kernel processes"
61846 + help
61847 + If you say Y here, all kernel threads will be hidden to all
61848 + processes but those whose subject has the "view hidden processes"
61849 + flag.
61850 +
61851 +config GRKERNSEC_ACL_MAXTRIES
61852 + int "Maximum tries before password lockout"
61853 + default 3
61854 + help
61855 + This option enforces the maximum number of times a user can attempt
61856 + to authorize themselves with the grsecurity RBAC system before being
61857 + denied the ability to attempt authorization again for a specified time.
61858 + The lower the number, the harder it will be to brute-force a password.
61859 +
61860 +config GRKERNSEC_ACL_TIMEOUT
61861 + int "Time to wait after max password tries, in seconds"
61862 + default 30
61863 + help
61864 + This option specifies the time the user must wait after attempting to
61865 + authorize to the RBAC system with the maximum number of invalid
61866 + passwords. The higher the number, the harder it will be to brute-force
61867 + a password.
61868 +
61869 +endmenu
61870 +menu "Filesystem Protections"
61871 +depends on GRKERNSEC
61872 +
61873 +config GRKERNSEC_PROC
61874 + bool "Proc restrictions"
61875 + default y if GRKERNSEC_CONFIG_AUTO
61876 + help
61877 + If you say Y here, the permissions of the /proc filesystem
61878 + will be altered to enhance system security and privacy. You MUST
61879 + choose either a user only restriction or a user and group restriction.
61880 + Depending upon the option you choose, you can either restrict users to
61881 + see only the processes they themselves run, or choose a group that can
61882 + view all processes and files normally restricted to root if you choose
61883 + the "restrict to user only" option. NOTE: If you're running identd or
61884 + ntpd as a non-root user, you will have to run it as the group you
61885 + specify here.
61886 +
61887 +config GRKERNSEC_PROC_USER
61888 + bool "Restrict /proc to user only"
61889 + depends on GRKERNSEC_PROC
61890 + help
61891 + If you say Y here, non-root users will only be able to view their own
61892 + processes, and restricts them from viewing network-related information,
61893 + and viewing kernel symbol and module information.
61894 +
61895 +config GRKERNSEC_PROC_USERGROUP
61896 + bool "Allow special group"
61897 + default y if GRKERNSEC_CONFIG_AUTO
61898 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61899 + help
61900 + If you say Y here, you will be able to select a group that will be
61901 + able to view all processes and network-related information. If you've
61902 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61903 + remain hidden. This option is useful if you want to run identd as
61904 + a non-root user. The group you select may also be chosen at boot time
61905 + via "grsec_proc_gid=" on the kernel commandline.
61906 +
61907 +config GRKERNSEC_PROC_GID
61908 + int "GID for special group"
61909 + depends on GRKERNSEC_PROC_USERGROUP
61910 + default 1001
61911 +
61912 +config GRKERNSEC_PROC_ADD
61913 + bool "Additional restrictions"
61914 + default y if GRKERNSEC_CONFIG_AUTO
61915 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61916 + help
61917 + If you say Y here, additional restrictions will be placed on
61918 + /proc that keep normal users from viewing device information and
61919 + slabinfo information that could be useful for exploits.
61920 +
61921 +config GRKERNSEC_LINK
61922 + bool "Linking restrictions"
61923 + default y if GRKERNSEC_CONFIG_AUTO
61924 + help
61925 + If you say Y here, /tmp race exploits will be prevented, since users
61926 + will no longer be able to follow symlinks owned by other users in
61927 + world-writable +t directories (e.g. /tmp), unless the owner of the
61928 + symlink is the owner of the directory. users will also not be
61929 + able to hardlink to files they do not own. If the sysctl option is
61930 + enabled, a sysctl option with name "linking_restrictions" is created.
61931 +
61932 +config GRKERNSEC_SYMLINKOWN
61933 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61934 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61935 + help
61936 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61937 + that prevents it from being used as a security feature. As Apache
61938 + verifies the symlink by performing a stat() against the target of
61939 + the symlink before it is followed, an attacker can setup a symlink
61940 + to point to a same-owned file, then replace the symlink with one
61941 + that targets another user's file just after Apache "validates" the
61942 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61943 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61944 + will be in place for the group you specify. If the sysctl option
61945 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61946 + created.
61947 +
61948 +config GRKERNSEC_SYMLINKOWN_GID
61949 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61950 + depends on GRKERNSEC_SYMLINKOWN
61951 + default 1006
61952 + help
61953 + Setting this GID determines what group kernel-enforced
61954 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61955 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61956 +
61957 +config GRKERNSEC_FIFO
61958 + bool "FIFO restrictions"
61959 + default y if GRKERNSEC_CONFIG_AUTO
61960 + help
61961 + If you say Y here, users will not be able to write to FIFOs they don't
61962 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61963 + the FIFO is the same owner of the directory it's held in. If the sysctl
61964 + option is enabled, a sysctl option with name "fifo_restrictions" is
61965 + created.
61966 +
61967 +config GRKERNSEC_SYSFS_RESTRICT
61968 + bool "Sysfs/debugfs restriction"
61969 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61970 + depends on SYSFS
61971 + help
61972 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61973 + any filesystem normally mounted under it (e.g. debugfs) will be
61974 + mostly accessible only by root. These filesystems generally provide access
61975 + to hardware and debug information that isn't appropriate for unprivileged
61976 + users of the system. Sysfs and debugfs have also become a large source
61977 + of new vulnerabilities, ranging from infoleaks to local compromise.
61978 + There has been very little oversight with an eye toward security involved
61979 + in adding new exporters of information to these filesystems, so their
61980 + use is discouraged.
61981 + For reasons of compatibility, a few directories have been whitelisted
61982 + for access by non-root users:
61983 + /sys/fs/selinux
61984 + /sys/fs/fuse
61985 + /sys/devices/system/cpu
61986 +
61987 +config GRKERNSEC_ROFS
61988 + bool "Runtime read-only mount protection"
61989 + depends on SYSCTL
61990 + help
61991 + If you say Y here, a sysctl option with name "romount_protect" will
61992 + be created. By setting this option to 1 at runtime, filesystems
61993 + will be protected in the following ways:
61994 + * No new writable mounts will be allowed
61995 + * Existing read-only mounts won't be able to be remounted read/write
61996 + * Write operations will be denied on all block devices
61997 + This option acts independently of grsec_lock: once it is set to 1,
61998 + it cannot be turned off. Therefore, please be mindful of the resulting
61999 + behavior if this option is enabled in an init script on a read-only
62000 + filesystem. This feature is mainly intended for secure embedded systems.
62001 +
62002 +config GRKERNSEC_DEVICE_SIDECHANNEL
62003 + bool "Eliminate stat/notify-based device sidechannels"
62004 + default y if GRKERNSEC_CONFIG_AUTO
62005 + help
62006 + If you say Y here, timing analyses on block or character
62007 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62008 + will be thwarted for unprivileged users. If a process without
62009 + CAP_MKNOD stats such a device, the last access and last modify times
62010 + will match the device's create time. No access or modify events
62011 + will be triggered through inotify/dnotify/fanotify for such devices.
62012 + This feature will prevent attacks that may at a minimum
62013 + allow an attacker to determine the administrator's password length.
62014 +
62015 +config GRKERNSEC_CHROOT
62016 + bool "Chroot jail restrictions"
62017 + default y if GRKERNSEC_CONFIG_AUTO
62018 + help
62019 + If you say Y here, you will be able to choose several options that will
62020 + make breaking out of a chrooted jail much more difficult. If you
62021 + encounter no software incompatibilities with the following options, it
62022 + is recommended that you enable each one.
62023 +
62024 +config GRKERNSEC_CHROOT_MOUNT
62025 + bool "Deny mounts"
62026 + default y if GRKERNSEC_CONFIG_AUTO
62027 + depends on GRKERNSEC_CHROOT
62028 + help
62029 + If you say Y here, processes inside a chroot will not be able to
62030 + mount or remount filesystems. If the sysctl option is enabled, a
62031 + sysctl option with name "chroot_deny_mount" is created.
62032 +
62033 +config GRKERNSEC_CHROOT_DOUBLE
62034 + bool "Deny double-chroots"
62035 + default y if GRKERNSEC_CONFIG_AUTO
62036 + depends on GRKERNSEC_CHROOT
62037 + help
62038 + If you say Y here, processes inside a chroot will not be able to chroot
62039 + again outside the chroot. This is a widely used method of breaking
62040 + out of a chroot jail and should not be allowed. If the sysctl
62041 + option is enabled, a sysctl option with name
62042 + "chroot_deny_chroot" is created.
62043 +
62044 +config GRKERNSEC_CHROOT_PIVOT
62045 + bool "Deny pivot_root in chroot"
62046 + default y if GRKERNSEC_CONFIG_AUTO
62047 + depends on GRKERNSEC_CHROOT
62048 + help
62049 + If you say Y here, processes inside a chroot will not be able to use
62050 + a function called pivot_root() that was introduced in Linux 2.3.41. It
62051 + works similar to chroot in that it changes the root filesystem. This
62052 + function could be misused in a chrooted process to attempt to break out
62053 + of the chroot, and therefore should not be allowed. If the sysctl
62054 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
62055 + created.
62056 +
62057 +config GRKERNSEC_CHROOT_CHDIR
62058 + bool "Enforce chdir(\"/\") on all chroots"
62059 + default y if GRKERNSEC_CONFIG_AUTO
62060 + depends on GRKERNSEC_CHROOT
62061 + help
62062 + If you say Y here, the current working directory of all newly-chrooted
62063 + applications will be set to the the root directory of the chroot.
62064 + The man page on chroot(2) states:
62065 + Note that this call does not change the current working
62066 + directory, so that `.' can be outside the tree rooted at
62067 + `/'. In particular, the super-user can escape from a
62068 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
62069 +
62070 + It is recommended that you say Y here, since it's not known to break
62071 + any software. If the sysctl option is enabled, a sysctl option with
62072 + name "chroot_enforce_chdir" is created.
62073 +
62074 +config GRKERNSEC_CHROOT_CHMOD
62075 + bool "Deny (f)chmod +s"
62076 + default y if GRKERNSEC_CONFIG_AUTO
62077 + depends on GRKERNSEC_CHROOT
62078 + help
62079 + If you say Y here, processes inside a chroot will not be able to chmod
62080 + or fchmod files to make them have suid or sgid bits. This protects
62081 + against another published method of breaking a chroot. If the sysctl
62082 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
62083 + created.
62084 +
62085 +config GRKERNSEC_CHROOT_FCHDIR
62086 + bool "Deny fchdir out of chroot"
62087 + default y if GRKERNSEC_CONFIG_AUTO
62088 + depends on GRKERNSEC_CHROOT
62089 + help
62090 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
62091 + to a file descriptor of the chrooting process that points to a directory
62092 + outside the filesystem will be stopped. If the sysctl option
62093 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
62094 +
62095 +config GRKERNSEC_CHROOT_MKNOD
62096 + bool "Deny mknod"
62097 + default y if GRKERNSEC_CONFIG_AUTO
62098 + depends on GRKERNSEC_CHROOT
62099 + help
62100 + If you say Y here, processes inside a chroot will not be allowed to
62101 + mknod. The problem with using mknod inside a chroot is that it
62102 + would allow an attacker to create a device entry that is the same
62103 + as one on the physical root of your system, which could range from
62104 + anything from the console device to a device for your harddrive (which
62105 + they could then use to wipe the drive or steal data). It is recommended
62106 + that you say Y here, unless you run into software incompatibilities.
62107 + If the sysctl option is enabled, a sysctl option with name
62108 + "chroot_deny_mknod" is created.
62109 +
62110 +config GRKERNSEC_CHROOT_SHMAT
62111 + bool "Deny shmat() out of chroot"
62112 + default y if GRKERNSEC_CONFIG_AUTO
62113 + depends on GRKERNSEC_CHROOT
62114 + help
62115 + If you say Y here, processes inside a chroot will not be able to attach
62116 + to shared memory segments that were created outside of the chroot jail.
62117 + It is recommended that you say Y here. If the sysctl option is enabled,
62118 + a sysctl option with name "chroot_deny_shmat" is created.
62119 +
62120 +config GRKERNSEC_CHROOT_UNIX
62121 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
62122 + default y if GRKERNSEC_CONFIG_AUTO
62123 + depends on GRKERNSEC_CHROOT
62124 + help
62125 + If you say Y here, processes inside a chroot will not be able to
62126 + connect to abstract (meaning not belonging to a filesystem) Unix
62127 + domain sockets that were bound outside of a chroot. It is recommended
62128 + that you say Y here. If the sysctl option is enabled, a sysctl option
62129 + with name "chroot_deny_unix" is created.
62130 +
62131 +config GRKERNSEC_CHROOT_FINDTASK
62132 + bool "Protect outside processes"
62133 + default y if GRKERNSEC_CONFIG_AUTO
62134 + depends on GRKERNSEC_CHROOT
62135 + help
62136 + If you say Y here, processes inside a chroot will not be able to
62137 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
62138 + getsid, or view any process outside of the chroot. If the sysctl
62139 + option is enabled, a sysctl option with name "chroot_findtask" is
62140 + created.
62141 +
62142 +config GRKERNSEC_CHROOT_NICE
62143 + bool "Restrict priority changes"
62144 + default y if GRKERNSEC_CONFIG_AUTO
62145 + depends on GRKERNSEC_CHROOT
62146 + help
62147 + If you say Y here, processes inside a chroot will not be able to raise
62148 + the priority of processes in the chroot, or alter the priority of
62149 + processes outside the chroot. This provides more security than simply
62150 + removing CAP_SYS_NICE from the process' capability set. If the
62151 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
62152 + is created.
62153 +
62154 +config GRKERNSEC_CHROOT_SYSCTL
62155 + bool "Deny sysctl writes"
62156 + default y if GRKERNSEC_CONFIG_AUTO
62157 + depends on GRKERNSEC_CHROOT
62158 + help
62159 + If you say Y here, an attacker in a chroot will not be able to
62160 + write to sysctl entries, either by sysctl(2) or through a /proc
62161 + interface. It is strongly recommended that you say Y here. If the
62162 + sysctl option is enabled, a sysctl option with name
62163 + "chroot_deny_sysctl" is created.
62164 +
62165 +config GRKERNSEC_CHROOT_CAPS
62166 + bool "Capability restrictions"
62167 + default y if GRKERNSEC_CONFIG_AUTO
62168 + depends on GRKERNSEC_CHROOT
62169 + help
62170 + If you say Y here, the capabilities on all processes within a
62171 + chroot jail will be lowered to stop module insertion, raw i/o,
62172 + system and net admin tasks, rebooting the system, modifying immutable
62173 + files, modifying IPC owned by another, and changing the system time.
62174 + This is left an option because it can break some apps. Disable this
62175 + if your chrooted apps are having problems performing those kinds of
62176 + tasks. If the sysctl option is enabled, a sysctl option with
62177 + name "chroot_caps" is created.
62178 +
62179 +config GRKERNSEC_CHROOT_INITRD
62180 + bool "Exempt initrd tasks from restrictions"
62181 + default y if GRKERNSEC_CONFIG_AUTO
62182 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
62183 + help
62184 + If you say Y here, tasks started prior to init will be exempted from
62185 + grsecurity's chroot restrictions. This option is mainly meant to
62186 + resolve Plymouth's performing privileged operations unnecessarily
62187 + in a chroot.
62188 +
62189 +endmenu
62190 +menu "Kernel Auditing"
62191 +depends on GRKERNSEC
62192 +
62193 +config GRKERNSEC_AUDIT_GROUP
62194 + bool "Single group for auditing"
62195 + help
62196 + If you say Y here, the exec and chdir logging features will only operate
62197 + on a group you specify. This option is recommended if you only want to
62198 + watch certain users instead of having a large amount of logs from the
62199 + entire system. If the sysctl option is enabled, a sysctl option with
62200 + name "audit_group" is created.
62201 +
62202 +config GRKERNSEC_AUDIT_GID
62203 + int "GID for auditing"
62204 + depends on GRKERNSEC_AUDIT_GROUP
62205 + default 1007
62206 +
62207 +config GRKERNSEC_EXECLOG
62208 + bool "Exec logging"
62209 + help
62210 + If you say Y here, all execve() calls will be logged (since the
62211 + other exec*() calls are frontends to execve(), all execution
62212 + will be logged). Useful for shell-servers that like to keep track
62213 + of their users. If the sysctl option is enabled, a sysctl option with
62214 + name "exec_logging" is created.
62215 + WARNING: This option when enabled will produce a LOT of logs, especially
62216 + on an active system.
62217 +
62218 +config GRKERNSEC_RESLOG
62219 + bool "Resource logging"
62220 + default y if GRKERNSEC_CONFIG_AUTO
62221 + help
62222 + If you say Y here, all attempts to overstep resource limits will
62223 + be logged with the resource name, the requested size, and the current
62224 + limit. It is highly recommended that you say Y here. If the sysctl
62225 + option is enabled, a sysctl option with name "resource_logging" is
62226 + created. If the RBAC system is enabled, the sysctl value is ignored.
62227 +
62228 +config GRKERNSEC_CHROOT_EXECLOG
62229 + bool "Log execs within chroot"
62230 + help
62231 + If you say Y here, all executions inside a chroot jail will be logged
62232 + to syslog. This can cause a large amount of logs if certain
62233 + applications (eg. djb's daemontools) are installed on the system, and
62234 + is therefore left as an option. If the sysctl option is enabled, a
62235 + sysctl option with name "chroot_execlog" is created.
62236 +
62237 +config GRKERNSEC_AUDIT_PTRACE
62238 + bool "Ptrace logging"
62239 + help
62240 + If you say Y here, all attempts to attach to a process via ptrace
62241 + will be logged. If the sysctl option is enabled, a sysctl option
62242 + with name "audit_ptrace" is created.
62243 +
62244 +config GRKERNSEC_AUDIT_CHDIR
62245 + bool "Chdir logging"
62246 + help
62247 + If you say Y here, all chdir() calls will be logged. If the sysctl
62248 + option is enabled, a sysctl option with name "audit_chdir" is created.
62249 +
62250 +config GRKERNSEC_AUDIT_MOUNT
62251 + bool "(Un)Mount logging"
62252 + help
62253 + If you say Y here, all mounts and unmounts will be logged. If the
62254 + sysctl option is enabled, a sysctl option with name "audit_mount" is
62255 + created.
62256 +
62257 +config GRKERNSEC_SIGNAL
62258 + bool "Signal logging"
62259 + default y if GRKERNSEC_CONFIG_AUTO
62260 + help
62261 + If you say Y here, certain important signals will be logged, such as
62262 + SIGSEGV, which will as a result inform you of when a error in a program
62263 + occurred, which in some cases could mean a possible exploit attempt.
62264 + If the sysctl option is enabled, a sysctl option with name
62265 + "signal_logging" is created.
62266 +
62267 +config GRKERNSEC_FORKFAIL
62268 + bool "Fork failure logging"
62269 + help
62270 + If you say Y here, all failed fork() attempts will be logged.
62271 + This could suggest a fork bomb, or someone attempting to overstep
62272 + their process limit. If the sysctl option is enabled, a sysctl option
62273 + with name "forkfail_logging" is created.
62274 +
62275 +config GRKERNSEC_TIME
62276 + bool "Time change logging"
62277 + default y if GRKERNSEC_CONFIG_AUTO
62278 + help
62279 + If you say Y here, any changes of the system clock will be logged.
62280 + If the sysctl option is enabled, a sysctl option with name
62281 + "timechange_logging" is created.
62282 +
62283 +config GRKERNSEC_PROC_IPADDR
62284 + bool "/proc/<pid>/ipaddr support"
62285 + default y if GRKERNSEC_CONFIG_AUTO
62286 + help
62287 + If you say Y here, a new entry will be added to each /proc/<pid>
62288 + directory that contains the IP address of the person using the task.
62289 + The IP is carried across local TCP and AF_UNIX stream sockets.
62290 + This information can be useful for IDS/IPSes to perform remote response
62291 + to a local attack. The entry is readable by only the owner of the
62292 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
62293 + the RBAC system), and thus does not create privacy concerns.
62294 +
62295 +config GRKERNSEC_RWXMAP_LOG
62296 + bool 'Denied RWX mmap/mprotect logging'
62297 + default y if GRKERNSEC_CONFIG_AUTO
62298 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
62299 + help
62300 + If you say Y here, calls to mmap() and mprotect() with explicit
62301 + usage of PROT_WRITE and PROT_EXEC together will be logged when
62302 + denied by the PAX_MPROTECT feature. This feature will also
62303 + log other problematic scenarios that can occur when PAX_MPROTECT
62304 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
62305 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
62306 + is created.
62307 +
62308 +endmenu
62309 +
62310 +menu "Executable Protections"
62311 +depends on GRKERNSEC
62312 +
62313 +config GRKERNSEC_DMESG
62314 + bool "Dmesg(8) restriction"
62315 + default y if GRKERNSEC_CONFIG_AUTO
62316 + help
62317 + If you say Y here, non-root users will not be able to use dmesg(8)
62318 + to view the contents of the kernel's circular log buffer.
62319 + The kernel's log buffer often contains kernel addresses and other
62320 + identifying information useful to an attacker in fingerprinting a
62321 + system for a targeted exploit.
62322 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
62323 + created.
62324 +
62325 +config GRKERNSEC_HARDEN_PTRACE
62326 + bool "Deter ptrace-based process snooping"
62327 + default y if GRKERNSEC_CONFIG_AUTO
62328 + help
62329 + If you say Y here, TTY sniffers and other malicious monitoring
62330 + programs implemented through ptrace will be defeated. If you
62331 + have been using the RBAC system, this option has already been
62332 + enabled for several years for all users, with the ability to make
62333 + fine-grained exceptions.
62334 +
62335 + This option only affects the ability of non-root users to ptrace
62336 + processes that are not a descendent of the ptracing process.
62337 + This means that strace ./binary and gdb ./binary will still work,
62338 + but attaching to arbitrary processes will not. If the sysctl
62339 + option is enabled, a sysctl option with name "harden_ptrace" is
62340 + created.
62341 +
62342 +config GRKERNSEC_PTRACE_READEXEC
62343 + bool "Require read access to ptrace sensitive binaries"
62344 + default y if GRKERNSEC_CONFIG_AUTO
62345 + help
62346 + If you say Y here, unprivileged users will not be able to ptrace unreadable
62347 + binaries. This option is useful in environments that
62348 + remove the read bits (e.g. file mode 4711) from suid binaries to
62349 + prevent infoleaking of their contents. This option adds
62350 + consistency to the use of that file mode, as the binary could normally
62351 + be read out when run without privileges while ptracing.
62352 +
62353 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
62354 + is created.
62355 +
62356 +config GRKERNSEC_SETXID
62357 + bool "Enforce consistent multithreaded privileges"
62358 + default y if GRKERNSEC_CONFIG_AUTO
62359 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
62360 + help
62361 + If you say Y here, a change from a root uid to a non-root uid
62362 + in a multithreaded application will cause the resulting uids,
62363 + gids, supplementary groups, and capabilities in that thread
62364 + to be propagated to the other threads of the process. In most
62365 + cases this is unnecessary, as glibc will emulate this behavior
62366 + on behalf of the application. Other libcs do not act in the
62367 + same way, allowing the other threads of the process to continue
62368 + running with root privileges. If the sysctl option is enabled,
62369 + a sysctl option with name "consistent_setxid" is created.
62370 +
62371 +config GRKERNSEC_HARDEN_IPC
62372 + bool "Disallow access to world-accessible IPC objects"
62373 + default y if GRKERNSEC_CONFIG_AUTO
62374 + depends on SYSVIPC
62375 + help
62376 + If you say Y here, access to overly-permissive IPC (shared memory,
62377 + message queues, and semaphores) will be denied for processes whose
62378 + effective user or group would not grant them permission. It's a
62379 + common error to grant too much permission to these objects, with
62380 + impact ranging from denial of service and information leaking to
62381 + privilege escalation. This feature was developed in response to
62382 + research by Tim Brown:
62383 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
62384 + who found hundreds of such insecure usages. Processes with
62385 + CAP_IPC_OWNER are still permitted to access these IPC objects.
62386 + If the sysctl option is enabled, a sysctl option with name
62387 + "harden_ipc" is created.
62388 +
62389 +config GRKERNSEC_TPE
62390 + bool "Trusted Path Execution (TPE)"
62391 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62392 + help
62393 + If you say Y here, you will be able to choose a gid to add to the
62394 + supplementary groups of users you want to mark as "untrusted."
62395 + These users will not be able to execute any files that are not in
62396 + root-owned directories writable only by root. If the sysctl option
62397 + is enabled, a sysctl option with name "tpe" is created.
62398 +
62399 +config GRKERNSEC_TPE_ALL
62400 + bool "Partially restrict all non-root users"
62401 + depends on GRKERNSEC_TPE
62402 + help
62403 + If you say Y here, all non-root users will be covered under
62404 + a weaker TPE restriction. This is separate from, and in addition to,
62405 + the main TPE options that you have selected elsewhere. Thus, if a
62406 + "trusted" GID is chosen, this restriction applies to even that GID.
62407 + Under this restriction, all non-root users will only be allowed to
62408 + execute files in directories they own that are not group or
62409 + world-writable, or in directories owned by root and writable only by
62410 + root. If the sysctl option is enabled, a sysctl option with name
62411 + "tpe_restrict_all" is created.
62412 +
62413 +config GRKERNSEC_TPE_INVERT
62414 + bool "Invert GID option"
62415 + depends on GRKERNSEC_TPE
62416 + help
62417 + If you say Y here, the group you specify in the TPE configuration will
62418 + decide what group TPE restrictions will be *disabled* for. This
62419 + option is useful if you want TPE restrictions to be applied to most
62420 + users on the system. If the sysctl option is enabled, a sysctl option
62421 + with name "tpe_invert" is created. Unlike other sysctl options, this
62422 + entry will default to on for backward-compatibility.
62423 +
62424 +config GRKERNSEC_TPE_GID
62425 + int
62426 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
62427 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
62428 +
62429 +config GRKERNSEC_TPE_UNTRUSTED_GID
62430 + int "GID for TPE-untrusted users"
62431 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
62432 + default 1005
62433 + help
62434 + Setting this GID determines what group TPE restrictions will be
62435 + *enabled* for. If the sysctl option is enabled, a sysctl option
62436 + with name "tpe_gid" is created.
62437 +
62438 +config GRKERNSEC_TPE_TRUSTED_GID
62439 + int "GID for TPE-trusted users"
62440 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
62441 + default 1005
62442 + help
62443 + Setting this GID determines what group TPE restrictions will be
62444 + *disabled* for. If the sysctl option is enabled, a sysctl option
62445 + with name "tpe_gid" is created.
62446 +
62447 +endmenu
62448 +menu "Network Protections"
62449 +depends on GRKERNSEC
62450 +
62451 +config GRKERNSEC_RANDNET
62452 + bool "Larger entropy pools"
62453 + default y if GRKERNSEC_CONFIG_AUTO
62454 + help
62455 + If you say Y here, the entropy pools used for many features of Linux
62456 + and grsecurity will be doubled in size. Since several grsecurity
62457 + features use additional randomness, it is recommended that you say Y
62458 + here. Saying Y here has a similar effect as modifying
62459 + /proc/sys/kernel/random/poolsize.
62460 +
62461 +config GRKERNSEC_BLACKHOLE
62462 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
62463 + default y if GRKERNSEC_CONFIG_AUTO
62464 + depends on NET
62465 + help
62466 + If you say Y here, neither TCP resets nor ICMP
62467 + destination-unreachable packets will be sent in response to packets
62468 + sent to ports for which no associated listening process exists.
62469 + This feature supports both IPV4 and IPV6 and exempts the
62470 + loopback interface from blackholing. Enabling this feature
62471 + makes a host more resilient to DoS attacks and reduces network
62472 + visibility against scanners.
62473 +
62474 + The blackhole feature as-implemented is equivalent to the FreeBSD
62475 + blackhole feature, as it prevents RST responses to all packets, not
62476 + just SYNs. Under most application behavior this causes no
62477 + problems, but applications (like haproxy) may not close certain
62478 + connections in a way that cleanly terminates them on the remote
62479 + end, leaving the remote host in LAST_ACK state. Because of this
62480 + side-effect and to prevent intentional LAST_ACK DoSes, this
62481 + feature also adds automatic mitigation against such attacks.
62482 + The mitigation drastically reduces the amount of time a socket
62483 + can spend in LAST_ACK state. If you're using haproxy and not
62484 + all servers it connects to have this option enabled, consider
62485 + disabling this feature on the haproxy host.
62486 +
62487 + If the sysctl option is enabled, two sysctl options with names
62488 + "ip_blackhole" and "lastack_retries" will be created.
62489 + While "ip_blackhole" takes the standard zero/non-zero on/off
62490 + toggle, "lastack_retries" uses the same kinds of values as
62491 + "tcp_retries1" and "tcp_retries2". The default value of 4
62492 + prevents a socket from lasting more than 45 seconds in LAST_ACK
62493 + state.
62494 +
62495 +config GRKERNSEC_NO_SIMULT_CONNECT
62496 + bool "Disable TCP Simultaneous Connect"
62497 + default y if GRKERNSEC_CONFIG_AUTO
62498 + depends on NET
62499 + help
62500 + If you say Y here, a feature by Willy Tarreau will be enabled that
62501 + removes a weakness in Linux's strict implementation of TCP that
62502 + allows two clients to connect to each other without either entering
62503 + a listening state. The weakness allows an attacker to easily prevent
62504 + a client from connecting to a known server provided the source port
62505 + for the connection is guessed correctly.
62506 +
62507 + As the weakness could be used to prevent an antivirus or IPS from
62508 + fetching updates, or prevent an SSL gateway from fetching a CRL,
62509 + it should be eliminated by enabling this option. Though Linux is
62510 + one of few operating systems supporting simultaneous connect, it
62511 + has no legitimate use in practice and is rarely supported by firewalls.
62512 +
62513 +config GRKERNSEC_SOCKET
62514 + bool "Socket restrictions"
62515 + depends on NET
62516 + help
62517 + If you say Y here, you will be able to choose from several options.
62518 + If you assign a GID on your system and add it to the supplementary
62519 + groups of users you want to restrict socket access to, this patch
62520 + will perform up to three things, based on the option(s) you choose.
62521 +
62522 +config GRKERNSEC_SOCKET_ALL
62523 + bool "Deny any sockets to group"
62524 + depends on GRKERNSEC_SOCKET
62525 + help
62526 + If you say Y here, you will be able to choose a GID of whose users will
62527 + be unable to connect to other hosts from your machine or run server
62528 + applications from your machine. If the sysctl option is enabled, a
62529 + sysctl option with name "socket_all" is created.
62530 +
62531 +config GRKERNSEC_SOCKET_ALL_GID
62532 + int "GID to deny all sockets for"
62533 + depends on GRKERNSEC_SOCKET_ALL
62534 + default 1004
62535 + help
62536 + Here you can choose the GID to disable socket access for. Remember to
62537 + add the users you want socket access disabled for to the GID
62538 + specified here. If the sysctl option is enabled, a sysctl option
62539 + with name "socket_all_gid" is created.
62540 +
62541 +config GRKERNSEC_SOCKET_CLIENT
62542 + bool "Deny client sockets to group"
62543 + depends on GRKERNSEC_SOCKET
62544 + help
62545 + If you say Y here, you will be able to choose a GID of whose users will
62546 + be unable to connect to other hosts from your machine, but will be
62547 + able to run servers. If this option is enabled, all users in the group
62548 + you specify will have to use passive mode when initiating ftp transfers
62549 + from the shell on your machine. If the sysctl option is enabled, a
62550 + sysctl option with name "socket_client" is created.
62551 +
62552 +config GRKERNSEC_SOCKET_CLIENT_GID
62553 + int "GID to deny client sockets for"
62554 + depends on GRKERNSEC_SOCKET_CLIENT
62555 + default 1003
62556 + help
62557 + Here you can choose the GID to disable client socket access for.
62558 + Remember to add the users you want client socket access disabled for to
62559 + the GID specified here. If the sysctl option is enabled, a sysctl
62560 + option with name "socket_client_gid" is created.
62561 +
62562 +config GRKERNSEC_SOCKET_SERVER
62563 + bool "Deny server sockets to group"
62564 + depends on GRKERNSEC_SOCKET
62565 + help
62566 + If you say Y here, you will be able to choose a GID of whose users will
62567 + be unable to run server applications from your machine. If the sysctl
62568 + option is enabled, a sysctl option with name "socket_server" is created.
62569 +
62570 +config GRKERNSEC_SOCKET_SERVER_GID
62571 + int "GID to deny server sockets for"
62572 + depends on GRKERNSEC_SOCKET_SERVER
62573 + default 1002
62574 + help
62575 + Here you can choose the GID to disable server socket access for.
62576 + Remember to add the users you want server socket access disabled for to
62577 + the GID specified here. If the sysctl option is enabled, a sysctl
62578 + option with name "socket_server_gid" is created.
62579 +
62580 +endmenu
62581 +
62582 +menu "Physical Protections"
62583 +depends on GRKERNSEC
62584 +
62585 +config GRKERNSEC_DENYUSB
62586 + bool "Deny new USB connections after toggle"
62587 + default y if GRKERNSEC_CONFIG_AUTO
62588 + depends on SYSCTL && USB_SUPPORT
62589 + help
62590 + If you say Y here, a new sysctl option with name "deny_new_usb"
62591 + will be created. Setting its value to 1 will prevent any new
62592 + USB devices from being recognized by the OS. Any attempted USB
62593 + device insertion will be logged. This option is intended to be
62594 + used against custom USB devices designed to exploit vulnerabilities
62595 + in various USB device drivers.
62596 +
62597 + For greatest effectiveness, this sysctl should be set after any
62598 + relevant init scripts. This option is safe to enable in distros
62599 + as each user can choose whether or not to toggle the sysctl.
62600 +
62601 +config GRKERNSEC_DENYUSB_FORCE
62602 + bool "Reject all USB devices not connected at boot"
62603 + select USB
62604 + depends on GRKERNSEC_DENYUSB
62605 + help
62606 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62607 + that doesn't involve a sysctl entry. This option should only be
62608 + enabled if you're sure you want to deny all new USB connections
62609 + at runtime and don't want to modify init scripts. This should not
62610 + be enabled by distros. It forces the core USB code to be built
62611 + into the kernel image so that all devices connected at boot time
62612 + can be recognized and new USB device connections can be prevented
62613 + prior to init running.
62614 +
62615 +endmenu
62616 +
62617 +menu "Sysctl Support"
62618 +depends on GRKERNSEC && SYSCTL
62619 +
62620 +config GRKERNSEC_SYSCTL
62621 + bool "Sysctl support"
62622 + default y if GRKERNSEC_CONFIG_AUTO
62623 + help
62624 + If you say Y here, you will be able to change the options that
62625 + grsecurity runs with at bootup, without having to recompile your
62626 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62627 + to enable (1) or disable (0) various features. All the sysctl entries
62628 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62629 + All features enabled in the kernel configuration are disabled at boot
62630 + if you do not say Y to the "Turn on features by default" option.
62631 + All options should be set at startup, and the grsec_lock entry should
62632 + be set to a non-zero value after all the options are set.
62633 + *THIS IS EXTREMELY IMPORTANT*
62634 +
62635 +config GRKERNSEC_SYSCTL_DISTRO
62636 + bool "Extra sysctl support for distro makers (READ HELP)"
62637 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62638 + help
62639 + If you say Y here, additional sysctl options will be created
62640 + for features that affect processes running as root. Therefore,
62641 + it is critical when using this option that the grsec_lock entry be
62642 + enabled after boot. Only distros with prebuilt kernel packages
62643 + with this option enabled that can ensure grsec_lock is enabled
62644 + after boot should use this option.
62645 + *Failure to set grsec_lock after boot makes all grsec features
62646 + this option covers useless*
62647 +
62648 + Currently this option creates the following sysctl entries:
62649 + "Disable Privileged I/O": "disable_priv_io"
62650 +
62651 +config GRKERNSEC_SYSCTL_ON
62652 + bool "Turn on features by default"
62653 + default y if GRKERNSEC_CONFIG_AUTO
62654 + depends on GRKERNSEC_SYSCTL
62655 + help
62656 + If you say Y here, instead of having all features enabled in the
62657 + kernel configuration disabled at boot time, the features will be
62658 + enabled at boot time. It is recommended you say Y here unless
62659 + there is some reason you would want all sysctl-tunable features to
62660 + be disabled by default. As mentioned elsewhere, it is important
62661 + to enable the grsec_lock entry once you have finished modifying
62662 + the sysctl entries.
62663 +
62664 +endmenu
62665 +menu "Logging Options"
62666 +depends on GRKERNSEC
62667 +
62668 +config GRKERNSEC_FLOODTIME
62669 + int "Seconds in between log messages (minimum)"
62670 + default 10
62671 + help
62672 + This option allows you to enforce the number of seconds between
62673 + grsecurity log messages. The default should be suitable for most
62674 + people, however, if you choose to change it, choose a value small enough
62675 + to allow informative logs to be produced, but large enough to
62676 + prevent flooding.
62677 +
62678 +config GRKERNSEC_FLOODBURST
62679 + int "Number of messages in a burst (maximum)"
62680 + default 6
62681 + help
62682 + This option allows you to choose the maximum number of messages allowed
62683 + within the flood time interval you chose in a separate option. The
62684 + default should be suitable for most people, however if you find that
62685 + many of your logs are being interpreted as flooding, you may want to
62686 + raise this value.
62687 +
62688 +endmenu
62689 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62690 new file mode 100644
62691 index 0000000..85beb79
62692 --- /dev/null
62693 +++ b/grsecurity/Makefile
62694 @@ -0,0 +1,43 @@
62695 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62696 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62697 +# into an RBAC system
62698 +#
62699 +# All code in this directory and various hooks inserted throughout the kernel
62700 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62701 +# under the GPL v2 or higher
62702 +
62703 +KBUILD_CFLAGS += -Werror
62704 +
62705 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62706 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62707 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62708 + grsec_usb.o grsec_ipc.o
62709 +
62710 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62711 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62712 + gracl_learn.o grsec_log.o gracl_policy.o
62713 +ifdef CONFIG_COMPAT
62714 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62715 +endif
62716 +
62717 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62718 +
62719 +ifdef CONFIG_NET
62720 +obj-y += grsec_sock.o
62721 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62722 +endif
62723 +
62724 +ifndef CONFIG_GRKERNSEC
62725 +obj-y += grsec_disabled.o
62726 +endif
62727 +
62728 +ifdef CONFIG_GRKERNSEC_HIDESYM
62729 +extra-y := grsec_hidesym.o
62730 +$(obj)/grsec_hidesym.o:
62731 + @-chmod -f 500 /boot
62732 + @-chmod -f 500 /lib/modules
62733 + @-chmod -f 500 /lib64/modules
62734 + @-chmod -f 500 /lib32/modules
62735 + @-chmod -f 700 .
62736 + @echo ' grsec: protected kernel image paths'
62737 +endif
62738 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62739 new file mode 100644
62740 index 0000000..857c960
62741 --- /dev/null
62742 +++ b/grsecurity/gracl.c
62743 @@ -0,0 +1,2623 @@
62744 +#include <linux/kernel.h>
62745 +#include <linux/module.h>
62746 +#include <linux/sched.h>
62747 +#include <linux/mm.h>
62748 +#include <linux/file.h>
62749 +#include <linux/fs.h>
62750 +#include <linux/namei.h>
62751 +#include <linux/mount.h>
62752 +#include <linux/tty.h>
62753 +#include <linux/proc_fs.h>
62754 +#include <linux/lglock.h>
62755 +#include <linux/slab.h>
62756 +#include <linux/vmalloc.h>
62757 +#include <linux/types.h>
62758 +#include <linux/sysctl.h>
62759 +#include <linux/netdevice.h>
62760 +#include <linux/ptrace.h>
62761 +#include <linux/gracl.h>
62762 +#include <linux/gralloc.h>
62763 +#include <linux/security.h>
62764 +#include <linux/grinternal.h>
62765 +#include <linux/pid_namespace.h>
62766 +#include <linux/stop_machine.h>
62767 +#include <linux/fdtable.h>
62768 +#include <linux/percpu.h>
62769 +#include <linux/lglock.h>
62770 +#include <linux/hugetlb.h>
62771 +#include <linux/posix-timers.h>
62772 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62773 +#include <linux/magic.h>
62774 +#include <linux/pagemap.h>
62775 +#include "../fs/btrfs/async-thread.h"
62776 +#include "../fs/btrfs/ctree.h"
62777 +#include "../fs/btrfs/btrfs_inode.h"
62778 +#endif
62779 +#include "../fs/mount.h"
62780 +
62781 +#include <asm/uaccess.h>
62782 +#include <asm/errno.h>
62783 +#include <asm/mman.h>
62784 +
62785 +#define FOR_EACH_ROLE_START(role) \
62786 + role = running_polstate.role_list; \
62787 + while (role) {
62788 +
62789 +#define FOR_EACH_ROLE_END(role) \
62790 + role = role->prev; \
62791 + }
62792 +
62793 +extern struct lglock vfsmount_lock;
62794 +
62795 +extern struct path gr_real_root;
62796 +
62797 +static struct gr_policy_state running_polstate;
62798 +struct gr_policy_state *polstate = &running_polstate;
62799 +extern struct gr_alloc_state *current_alloc_state;
62800 +
62801 +extern char *gr_shared_page[4];
62802 +DEFINE_RWLOCK(gr_inode_lock);
62803 +
62804 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62805 +
62806 +#ifdef CONFIG_NET
62807 +extern struct vfsmount *sock_mnt;
62808 +#endif
62809 +
62810 +extern struct vfsmount *pipe_mnt;
62811 +extern struct vfsmount *shm_mnt;
62812 +
62813 +#ifdef CONFIG_HUGETLBFS
62814 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62815 +#endif
62816 +
62817 +extern u16 acl_sp_role_value;
62818 +extern struct acl_object_label *fakefs_obj_rw;
62819 +extern struct acl_object_label *fakefs_obj_rwx;
62820 +
62821 +int gr_acl_is_enabled(void)
62822 +{
62823 + return (gr_status & GR_READY);
62824 +}
62825 +
62826 +void gr_enable_rbac_system(void)
62827 +{
62828 + pax_open_kernel();
62829 + gr_status |= GR_READY;
62830 + pax_close_kernel();
62831 +}
62832 +
62833 +int gr_rbac_disable(void *unused)
62834 +{
62835 + pax_open_kernel();
62836 + gr_status &= ~GR_READY;
62837 + pax_close_kernel();
62838 +
62839 + return 0;
62840 +}
62841 +
62842 +static inline dev_t __get_dev(const struct dentry *dentry)
62843 +{
62844 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62845 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62846 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62847 + else
62848 +#endif
62849 + return dentry->d_sb->s_dev;
62850 +}
62851 +
62852 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62853 +{
62854 + return __get_dev(dentry);
62855 +}
62856 +
62857 +static char gr_task_roletype_to_char(struct task_struct *task)
62858 +{
62859 + switch (task->role->roletype &
62860 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62861 + GR_ROLE_SPECIAL)) {
62862 + case GR_ROLE_DEFAULT:
62863 + return 'D';
62864 + case GR_ROLE_USER:
62865 + return 'U';
62866 + case GR_ROLE_GROUP:
62867 + return 'G';
62868 + case GR_ROLE_SPECIAL:
62869 + return 'S';
62870 + }
62871 +
62872 + return 'X';
62873 +}
62874 +
62875 +char gr_roletype_to_char(void)
62876 +{
62877 + return gr_task_roletype_to_char(current);
62878 +}
62879 +
62880 +__inline__ int
62881 +gr_acl_tpe_check(void)
62882 +{
62883 + if (unlikely(!(gr_status & GR_READY)))
62884 + return 0;
62885 + if (current->role->roletype & GR_ROLE_TPE)
62886 + return 1;
62887 + else
62888 + return 0;
62889 +}
62890 +
62891 +int
62892 +gr_handle_rawio(const struct inode *inode)
62893 +{
62894 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62895 + if (inode && S_ISBLK(inode->i_mode) &&
62896 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62897 + !capable(CAP_SYS_RAWIO))
62898 + return 1;
62899 +#endif
62900 + return 0;
62901 +}
62902 +
62903 +int
62904 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62905 +{
62906 + if (likely(lena != lenb))
62907 + return 0;
62908 +
62909 + return !memcmp(a, b, lena);
62910 +}
62911 +
62912 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62913 +{
62914 + *buflen -= namelen;
62915 + if (*buflen < 0)
62916 + return -ENAMETOOLONG;
62917 + *buffer -= namelen;
62918 + memcpy(*buffer, str, namelen);
62919 + return 0;
62920 +}
62921 +
62922 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62923 +{
62924 + return prepend(buffer, buflen, name->name, name->len);
62925 +}
62926 +
62927 +static int prepend_path(const struct path *path, struct path *root,
62928 + char **buffer, int *buflen)
62929 +{
62930 + struct dentry *dentry = path->dentry;
62931 + struct vfsmount *vfsmnt = path->mnt;
62932 + struct mount *mnt = real_mount(vfsmnt);
62933 + bool slash = false;
62934 + int error = 0;
62935 +
62936 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62937 + struct dentry * parent;
62938 +
62939 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62940 + /* Global root? */
62941 + if (!mnt_has_parent(mnt)) {
62942 + goto out;
62943 + }
62944 + dentry = mnt->mnt_mountpoint;
62945 + mnt = mnt->mnt_parent;
62946 + vfsmnt = &mnt->mnt;
62947 + continue;
62948 + }
62949 + parent = dentry->d_parent;
62950 + prefetch(parent);
62951 + spin_lock(&dentry->d_lock);
62952 + error = prepend_name(buffer, buflen, &dentry->d_name);
62953 + spin_unlock(&dentry->d_lock);
62954 + if (!error)
62955 + error = prepend(buffer, buflen, "/", 1);
62956 + if (error)
62957 + break;
62958 +
62959 + slash = true;
62960 + dentry = parent;
62961 + }
62962 +
62963 +out:
62964 + if (!error && !slash)
62965 + error = prepend(buffer, buflen, "/", 1);
62966 +
62967 + return error;
62968 +}
62969 +
62970 +/* this must be called with vfsmount_lock and rename_lock held */
62971 +
62972 +static char *__our_d_path(const struct path *path, struct path *root,
62973 + char *buf, int buflen)
62974 +{
62975 + char *res = buf + buflen;
62976 + int error;
62977 +
62978 + prepend(&res, &buflen, "\0", 1);
62979 + error = prepend_path(path, root, &res, &buflen);
62980 + if (error)
62981 + return ERR_PTR(error);
62982 +
62983 + return res;
62984 +}
62985 +
62986 +static char *
62987 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62988 +{
62989 + char *retval;
62990 +
62991 + retval = __our_d_path(path, root, buf, buflen);
62992 + if (unlikely(IS_ERR(retval)))
62993 + retval = strcpy(buf, "<path too long>");
62994 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62995 + retval[1] = '\0';
62996 +
62997 + return retval;
62998 +}
62999 +
63000 +static char *
63001 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63002 + char *buf, int buflen)
63003 +{
63004 + struct path path;
63005 + char *res;
63006 +
63007 + path.dentry = (struct dentry *)dentry;
63008 + path.mnt = (struct vfsmount *)vfsmnt;
63009 +
63010 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
63011 + by the RBAC system */
63012 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
63013 +
63014 + return res;
63015 +}
63016 +
63017 +static char *
63018 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63019 + char *buf, int buflen)
63020 +{
63021 + char *res;
63022 + struct path path;
63023 + struct path root;
63024 + struct task_struct *reaper = init_pid_ns.child_reaper;
63025 +
63026 + path.dentry = (struct dentry *)dentry;
63027 + path.mnt = (struct vfsmount *)vfsmnt;
63028 +
63029 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
63030 + get_fs_root(reaper->fs, &root);
63031 +
63032 + br_read_lock(&vfsmount_lock);
63033 + write_seqlock(&rename_lock);
63034 + res = gen_full_path(&path, &root, buf, buflen);
63035 + write_sequnlock(&rename_lock);
63036 + br_read_unlock(&vfsmount_lock);
63037 +
63038 + path_put(&root);
63039 + return res;
63040 +}
63041 +
63042 +char *
63043 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63044 +{
63045 + char *ret;
63046 + br_read_lock(&vfsmount_lock);
63047 + write_seqlock(&rename_lock);
63048 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63049 + PAGE_SIZE);
63050 + write_sequnlock(&rename_lock);
63051 + br_read_unlock(&vfsmount_lock);
63052 + return ret;
63053 +}
63054 +
63055 +static char *
63056 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63057 +{
63058 + char *ret;
63059 + char *buf;
63060 + int buflen;
63061 +
63062 + br_read_lock(&vfsmount_lock);
63063 + write_seqlock(&rename_lock);
63064 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
63065 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
63066 + buflen = (int)(ret - buf);
63067 + if (buflen >= 5)
63068 + prepend(&ret, &buflen, "/proc", 5);
63069 + else
63070 + ret = strcpy(buf, "<path too long>");
63071 + write_sequnlock(&rename_lock);
63072 + br_read_unlock(&vfsmount_lock);
63073 + return ret;
63074 +}
63075 +
63076 +char *
63077 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
63078 +{
63079 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63080 + PAGE_SIZE);
63081 +}
63082 +
63083 +char *
63084 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
63085 +{
63086 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
63087 + PAGE_SIZE);
63088 +}
63089 +
63090 +char *
63091 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
63092 +{
63093 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
63094 + PAGE_SIZE);
63095 +}
63096 +
63097 +char *
63098 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
63099 +{
63100 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
63101 + PAGE_SIZE);
63102 +}
63103 +
63104 +char *
63105 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
63106 +{
63107 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
63108 + PAGE_SIZE);
63109 +}
63110 +
63111 +__inline__ __u32
63112 +to_gr_audit(const __u32 reqmode)
63113 +{
63114 + /* masks off auditable permission flags, then shifts them to create
63115 + auditing flags, and adds the special case of append auditing if
63116 + we're requesting write */
63117 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
63118 +}
63119 +
63120 +struct acl_role_label *
63121 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
63122 + const gid_t gid)
63123 +{
63124 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
63125 + struct acl_role_label *match;
63126 + struct role_allowed_ip *ipp;
63127 + unsigned int x;
63128 + u32 curr_ip = task->signal->saved_ip;
63129 +
63130 + match = state->acl_role_set.r_hash[index];
63131 +
63132 + while (match) {
63133 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
63134 + for (x = 0; x < match->domain_child_num; x++) {
63135 + if (match->domain_children[x] == uid)
63136 + goto found;
63137 + }
63138 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
63139 + break;
63140 + match = match->next;
63141 + }
63142 +found:
63143 + if (match == NULL) {
63144 + try_group:
63145 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
63146 + match = state->acl_role_set.r_hash[index];
63147 +
63148 + while (match) {
63149 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
63150 + for (x = 0; x < match->domain_child_num; x++) {
63151 + if (match->domain_children[x] == gid)
63152 + goto found2;
63153 + }
63154 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
63155 + break;
63156 + match = match->next;
63157 + }
63158 +found2:
63159 + if (match == NULL)
63160 + match = state->default_role;
63161 + if (match->allowed_ips == NULL)
63162 + return match;
63163 + else {
63164 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63165 + if (likely
63166 + ((ntohl(curr_ip) & ipp->netmask) ==
63167 + (ntohl(ipp->addr) & ipp->netmask)))
63168 + return match;
63169 + }
63170 + match = state->default_role;
63171 + }
63172 + } else if (match->allowed_ips == NULL) {
63173 + return match;
63174 + } else {
63175 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63176 + if (likely
63177 + ((ntohl(curr_ip) & ipp->netmask) ==
63178 + (ntohl(ipp->addr) & ipp->netmask)))
63179 + return match;
63180 + }
63181 + goto try_group;
63182 + }
63183 +
63184 + return match;
63185 +}
63186 +
63187 +static struct acl_role_label *
63188 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
63189 + const gid_t gid)
63190 +{
63191 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
63192 +}
63193 +
63194 +struct acl_subject_label *
63195 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
63196 + const struct acl_role_label *role)
63197 +{
63198 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63199 + struct acl_subject_label *match;
63200 +
63201 + match = role->subj_hash[index];
63202 +
63203 + while (match && (match->inode != ino || match->device != dev ||
63204 + (match->mode & GR_DELETED))) {
63205 + match = match->next;
63206 + }
63207 +
63208 + if (match && !(match->mode & GR_DELETED))
63209 + return match;
63210 + else
63211 + return NULL;
63212 +}
63213 +
63214 +struct acl_subject_label *
63215 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
63216 + const struct acl_role_label *role)
63217 +{
63218 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63219 + struct acl_subject_label *match;
63220 +
63221 + match = role->subj_hash[index];
63222 +
63223 + while (match && (match->inode != ino || match->device != dev ||
63224 + !(match->mode & GR_DELETED))) {
63225 + match = match->next;
63226 + }
63227 +
63228 + if (match && (match->mode & GR_DELETED))
63229 + return match;
63230 + else
63231 + return NULL;
63232 +}
63233 +
63234 +static struct acl_object_label *
63235 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
63236 + const struct acl_subject_label *subj)
63237 +{
63238 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63239 + struct acl_object_label *match;
63240 +
63241 + match = subj->obj_hash[index];
63242 +
63243 + while (match && (match->inode != ino || match->device != dev ||
63244 + (match->mode & GR_DELETED))) {
63245 + match = match->next;
63246 + }
63247 +
63248 + if (match && !(match->mode & GR_DELETED))
63249 + return match;
63250 + else
63251 + return NULL;
63252 +}
63253 +
63254 +static struct acl_object_label *
63255 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
63256 + const struct acl_subject_label *subj)
63257 +{
63258 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63259 + struct acl_object_label *match;
63260 +
63261 + match = subj->obj_hash[index];
63262 +
63263 + while (match && (match->inode != ino || match->device != dev ||
63264 + !(match->mode & GR_DELETED))) {
63265 + match = match->next;
63266 + }
63267 +
63268 + if (match && (match->mode & GR_DELETED))
63269 + return match;
63270 +
63271 + match = subj->obj_hash[index];
63272 +
63273 + while (match && (match->inode != ino || match->device != dev ||
63274 + (match->mode & GR_DELETED))) {
63275 + match = match->next;
63276 + }
63277 +
63278 + if (match && !(match->mode & GR_DELETED))
63279 + return match;
63280 + else
63281 + return NULL;
63282 +}
63283 +
63284 +struct name_entry *
63285 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
63286 +{
63287 + unsigned int len = strlen(name);
63288 + unsigned int key = full_name_hash(name, len);
63289 + unsigned int index = key % state->name_set.n_size;
63290 + struct name_entry *match;
63291 +
63292 + match = state->name_set.n_hash[index];
63293 +
63294 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
63295 + match = match->next;
63296 +
63297 + return match;
63298 +}
63299 +
63300 +static struct name_entry *
63301 +lookup_name_entry(const char *name)
63302 +{
63303 + return __lookup_name_entry(&running_polstate, name);
63304 +}
63305 +
63306 +static struct name_entry *
63307 +lookup_name_entry_create(const char *name)
63308 +{
63309 + unsigned int len = strlen(name);
63310 + unsigned int key = full_name_hash(name, len);
63311 + unsigned int index = key % running_polstate.name_set.n_size;
63312 + struct name_entry *match;
63313 +
63314 + match = running_polstate.name_set.n_hash[index];
63315 +
63316 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63317 + !match->deleted))
63318 + match = match->next;
63319 +
63320 + if (match && match->deleted)
63321 + return match;
63322 +
63323 + match = running_polstate.name_set.n_hash[index];
63324 +
63325 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63326 + match->deleted))
63327 + match = match->next;
63328 +
63329 + if (match && !match->deleted)
63330 + return match;
63331 + else
63332 + return NULL;
63333 +}
63334 +
63335 +static struct inodev_entry *
63336 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
63337 +{
63338 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
63339 + struct inodev_entry *match;
63340 +
63341 + match = running_polstate.inodev_set.i_hash[index];
63342 +
63343 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
63344 + match = match->next;
63345 +
63346 + return match;
63347 +}
63348 +
63349 +void
63350 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
63351 +{
63352 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
63353 + state->inodev_set.i_size);
63354 + struct inodev_entry **curr;
63355 +
63356 + entry->prev = NULL;
63357 +
63358 + curr = &state->inodev_set.i_hash[index];
63359 + if (*curr != NULL)
63360 + (*curr)->prev = entry;
63361 +
63362 + entry->next = *curr;
63363 + *curr = entry;
63364 +
63365 + return;
63366 +}
63367 +
63368 +static void
63369 +insert_inodev_entry(struct inodev_entry *entry)
63370 +{
63371 + __insert_inodev_entry(&running_polstate, entry);
63372 +}
63373 +
63374 +void
63375 +insert_acl_obj_label(struct acl_object_label *obj,
63376 + struct acl_subject_label *subj)
63377 +{
63378 + unsigned int index =
63379 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63380 + struct acl_object_label **curr;
63381 +
63382 + obj->prev = NULL;
63383 +
63384 + curr = &subj->obj_hash[index];
63385 + if (*curr != NULL)
63386 + (*curr)->prev = obj;
63387 +
63388 + obj->next = *curr;
63389 + *curr = obj;
63390 +
63391 + return;
63392 +}
63393 +
63394 +void
63395 +insert_acl_subj_label(struct acl_subject_label *obj,
63396 + struct acl_role_label *role)
63397 +{
63398 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63399 + struct acl_subject_label **curr;
63400 +
63401 + obj->prev = NULL;
63402 +
63403 + curr = &role->subj_hash[index];
63404 + if (*curr != NULL)
63405 + (*curr)->prev = obj;
63406 +
63407 + obj->next = *curr;
63408 + *curr = obj;
63409 +
63410 + return;
63411 +}
63412 +
63413 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63414 +
63415 +static int
63416 +glob_match(const char *p, const char *n)
63417 +{
63418 + char c;
63419 +
63420 + while ((c = *p++) != '\0') {
63421 + switch (c) {
63422 + case '?':
63423 + if (*n == '\0')
63424 + return 1;
63425 + else if (*n == '/')
63426 + return 1;
63427 + break;
63428 + case '\\':
63429 + if (*n != c)
63430 + return 1;
63431 + break;
63432 + case '*':
63433 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63434 + if (*n == '/')
63435 + return 1;
63436 + else if (c == '?') {
63437 + if (*n == '\0')
63438 + return 1;
63439 + else
63440 + ++n;
63441 + }
63442 + }
63443 + if (c == '\0') {
63444 + return 0;
63445 + } else {
63446 + const char *endp;
63447 +
63448 + if ((endp = strchr(n, '/')) == NULL)
63449 + endp = n + strlen(n);
63450 +
63451 + if (c == '[') {
63452 + for (--p; n < endp; ++n)
63453 + if (!glob_match(p, n))
63454 + return 0;
63455 + } else if (c == '/') {
63456 + while (*n != '\0' && *n != '/')
63457 + ++n;
63458 + if (*n == '/' && !glob_match(p, n + 1))
63459 + return 0;
63460 + } else {
63461 + for (--p; n < endp; ++n)
63462 + if (*n == c && !glob_match(p, n))
63463 + return 0;
63464 + }
63465 +
63466 + return 1;
63467 + }
63468 + case '[':
63469 + {
63470 + int not;
63471 + char cold;
63472 +
63473 + if (*n == '\0' || *n == '/')
63474 + return 1;
63475 +
63476 + not = (*p == '!' || *p == '^');
63477 + if (not)
63478 + ++p;
63479 +
63480 + c = *p++;
63481 + for (;;) {
63482 + unsigned char fn = (unsigned char)*n;
63483 +
63484 + if (c == '\0')
63485 + return 1;
63486 + else {
63487 + if (c == fn)
63488 + goto matched;
63489 + cold = c;
63490 + c = *p++;
63491 +
63492 + if (c == '-' && *p != ']') {
63493 + unsigned char cend = *p++;
63494 +
63495 + if (cend == '\0')
63496 + return 1;
63497 +
63498 + if (cold <= fn && fn <= cend)
63499 + goto matched;
63500 +
63501 + c = *p++;
63502 + }
63503 + }
63504 +
63505 + if (c == ']')
63506 + break;
63507 + }
63508 + if (!not)
63509 + return 1;
63510 + break;
63511 + matched:
63512 + while (c != ']') {
63513 + if (c == '\0')
63514 + return 1;
63515 +
63516 + c = *p++;
63517 + }
63518 + if (not)
63519 + return 1;
63520 + }
63521 + break;
63522 + default:
63523 + if (c != *n)
63524 + return 1;
63525 + }
63526 +
63527 + ++n;
63528 + }
63529 +
63530 + if (*n == '\0')
63531 + return 0;
63532 +
63533 + if (*n == '/')
63534 + return 0;
63535 +
63536 + return 1;
63537 +}
63538 +
63539 +static struct acl_object_label *
63540 +chk_glob_label(struct acl_object_label *globbed,
63541 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
63542 +{
63543 + struct acl_object_label *tmp;
63544 +
63545 + if (*path == NULL)
63546 + *path = gr_to_filename_nolock(dentry, mnt);
63547 +
63548 + tmp = globbed;
63549 +
63550 + while (tmp) {
63551 + if (!glob_match(tmp->filename, *path))
63552 + return tmp;
63553 + tmp = tmp->next;
63554 + }
63555 +
63556 + return NULL;
63557 +}
63558 +
63559 +static struct acl_object_label *
63560 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63561 + const ino_t curr_ino, const dev_t curr_dev,
63562 + const struct acl_subject_label *subj, char **path, const int checkglob)
63563 +{
63564 + struct acl_subject_label *tmpsubj;
63565 + struct acl_object_label *retval;
63566 + struct acl_object_label *retval2;
63567 +
63568 + tmpsubj = (struct acl_subject_label *) subj;
63569 + read_lock(&gr_inode_lock);
63570 + do {
63571 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
63572 + if (retval) {
63573 + if (checkglob && retval->globbed) {
63574 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
63575 + if (retval2)
63576 + retval = retval2;
63577 + }
63578 + break;
63579 + }
63580 + } while ((tmpsubj = tmpsubj->parent_subject));
63581 + read_unlock(&gr_inode_lock);
63582 +
63583 + return retval;
63584 +}
63585 +
63586 +static __inline__ struct acl_object_label *
63587 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63588 + struct dentry *curr_dentry,
63589 + const struct acl_subject_label *subj, char **path, const int checkglob)
63590 +{
63591 + int newglob = checkglob;
63592 + ino_t inode;
63593 + dev_t device;
63594 +
63595 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
63596 + as we don't want a / * rule to match instead of the / object
63597 + don't do this for create lookups that call this function though, since they're looking up
63598 + on the parent and thus need globbing checks on all paths
63599 + */
63600 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
63601 + newglob = GR_NO_GLOB;
63602 +
63603 + spin_lock(&curr_dentry->d_lock);
63604 + inode = curr_dentry->d_inode->i_ino;
63605 + device = __get_dev(curr_dentry);
63606 + spin_unlock(&curr_dentry->d_lock);
63607 +
63608 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
63609 +}
63610 +
63611 +#ifdef CONFIG_HUGETLBFS
63612 +static inline bool
63613 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
63614 +{
63615 + int i;
63616 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
63617 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
63618 + return true;
63619 + }
63620 +
63621 + return false;
63622 +}
63623 +#endif
63624 +
63625 +static struct acl_object_label *
63626 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63627 + const struct acl_subject_label *subj, char *path, const int checkglob)
63628 +{
63629 + struct dentry *dentry = (struct dentry *) l_dentry;
63630 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63631 + struct mount *real_mnt = real_mount(mnt);
63632 + struct acl_object_label *retval;
63633 + struct dentry *parent;
63634 +
63635 + br_read_lock(&vfsmount_lock);
63636 + write_seqlock(&rename_lock);
63637 +
63638 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
63639 +#ifdef CONFIG_NET
63640 + mnt == sock_mnt ||
63641 +#endif
63642 +#ifdef CONFIG_HUGETLBFS
63643 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
63644 +#endif
63645 + /* ignore Eric Biederman */
63646 + IS_PRIVATE(l_dentry->d_inode))) {
63647 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
63648 + goto out;
63649 + }
63650 +
63651 + for (;;) {
63652 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63653 + break;
63654 +
63655 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63656 + if (!mnt_has_parent(real_mnt))
63657 + break;
63658 +
63659 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63660 + if (retval != NULL)
63661 + goto out;
63662 +
63663 + dentry = real_mnt->mnt_mountpoint;
63664 + real_mnt = real_mnt->mnt_parent;
63665 + mnt = &real_mnt->mnt;
63666 + continue;
63667 + }
63668 +
63669 + parent = dentry->d_parent;
63670 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63671 + if (retval != NULL)
63672 + goto out;
63673 +
63674 + dentry = parent;
63675 + }
63676 +
63677 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63678 +
63679 + /* gr_real_root is pinned so we don't have to hold a reference */
63680 + if (retval == NULL)
63681 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
63682 +out:
63683 + write_sequnlock(&rename_lock);
63684 + br_read_unlock(&vfsmount_lock);
63685 +
63686 + BUG_ON(retval == NULL);
63687 +
63688 + return retval;
63689 +}
63690 +
63691 +static __inline__ struct acl_object_label *
63692 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63693 + const struct acl_subject_label *subj)
63694 +{
63695 + char *path = NULL;
63696 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
63697 +}
63698 +
63699 +static __inline__ struct acl_object_label *
63700 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63701 + const struct acl_subject_label *subj)
63702 +{
63703 + char *path = NULL;
63704 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
63705 +}
63706 +
63707 +static __inline__ struct acl_object_label *
63708 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63709 + const struct acl_subject_label *subj, char *path)
63710 +{
63711 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
63712 +}
63713 +
63714 +struct acl_subject_label *
63715 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63716 + const struct acl_role_label *role)
63717 +{
63718 + struct dentry *dentry = (struct dentry *) l_dentry;
63719 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63720 + struct mount *real_mnt = real_mount(mnt);
63721 + struct acl_subject_label *retval;
63722 + struct dentry *parent;
63723 +
63724 + br_read_lock(&vfsmount_lock);
63725 + write_seqlock(&rename_lock);
63726 +
63727 + for (;;) {
63728 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63729 + break;
63730 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63731 + if (!mnt_has_parent(real_mnt))
63732 + break;
63733 +
63734 + spin_lock(&dentry->d_lock);
63735 + read_lock(&gr_inode_lock);
63736 + retval =
63737 + lookup_acl_subj_label(dentry->d_inode->i_ino,
63738 + __get_dev(dentry), role);
63739 + read_unlock(&gr_inode_lock);
63740 + spin_unlock(&dentry->d_lock);
63741 + if (retval != NULL)
63742 + goto out;
63743 +
63744 + dentry = real_mnt->mnt_mountpoint;
63745 + real_mnt = real_mnt->mnt_parent;
63746 + mnt = &real_mnt->mnt;
63747 + continue;
63748 + }
63749 +
63750 + spin_lock(&dentry->d_lock);
63751 + read_lock(&gr_inode_lock);
63752 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63753 + __get_dev(dentry), role);
63754 + read_unlock(&gr_inode_lock);
63755 + parent = dentry->d_parent;
63756 + spin_unlock(&dentry->d_lock);
63757 +
63758 + if (retval != NULL)
63759 + goto out;
63760 +
63761 + dentry = parent;
63762 + }
63763 +
63764 + spin_lock(&dentry->d_lock);
63765 + read_lock(&gr_inode_lock);
63766 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63767 + __get_dev(dentry), role);
63768 + read_unlock(&gr_inode_lock);
63769 + spin_unlock(&dentry->d_lock);
63770 +
63771 + if (unlikely(retval == NULL)) {
63772 + /* gr_real_root is pinned, we don't need to hold a reference */
63773 + read_lock(&gr_inode_lock);
63774 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
63775 + __get_dev(gr_real_root.dentry), role);
63776 + read_unlock(&gr_inode_lock);
63777 + }
63778 +out:
63779 + write_sequnlock(&rename_lock);
63780 + br_read_unlock(&vfsmount_lock);
63781 +
63782 + BUG_ON(retval == NULL);
63783 +
63784 + return retval;
63785 +}
63786 +
63787 +void
63788 +assign_special_role(const char *rolename)
63789 +{
63790 + struct acl_object_label *obj;
63791 + struct acl_role_label *r;
63792 + struct acl_role_label *assigned = NULL;
63793 + struct task_struct *tsk;
63794 + struct file *filp;
63795 +
63796 + FOR_EACH_ROLE_START(r)
63797 + if (!strcmp(rolename, r->rolename) &&
63798 + (r->roletype & GR_ROLE_SPECIAL)) {
63799 + assigned = r;
63800 + break;
63801 + }
63802 + FOR_EACH_ROLE_END(r)
63803 +
63804 + if (!assigned)
63805 + return;
63806 +
63807 + read_lock(&tasklist_lock);
63808 + read_lock(&grsec_exec_file_lock);
63809 +
63810 + tsk = current->real_parent;
63811 + if (tsk == NULL)
63812 + goto out_unlock;
63813 +
63814 + filp = tsk->exec_file;
63815 + if (filp == NULL)
63816 + goto out_unlock;
63817 +
63818 + tsk->is_writable = 0;
63819 + tsk->inherited = 0;
63820 +
63821 + tsk->acl_sp_role = 1;
63822 + tsk->acl_role_id = ++acl_sp_role_value;
63823 + tsk->role = assigned;
63824 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
63825 +
63826 + /* ignore additional mmap checks for processes that are writable
63827 + by the default ACL */
63828 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
63829 + if (unlikely(obj->mode & GR_WRITE))
63830 + tsk->is_writable = 1;
63831 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
63832 + if (unlikely(obj->mode & GR_WRITE))
63833 + tsk->is_writable = 1;
63834 +
63835 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63836 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
63837 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
63838 +#endif
63839 +
63840 +out_unlock:
63841 + read_unlock(&grsec_exec_file_lock);
63842 + read_unlock(&tasklist_lock);
63843 + return;
63844 +}
63845 +
63846 +
63847 +static void
63848 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
63849 +{
63850 + struct task_struct *task = current;
63851 + const struct cred *cred = current_cred();
63852 +
63853 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
63854 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63855 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63856 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
63857 +
63858 + return;
63859 +}
63860 +
63861 +static void
63862 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
63863 +{
63864 + struct task_struct *task = current;
63865 + const struct cred *cred = current_cred();
63866 +
63867 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63868 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63869 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63870 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
63871 +
63872 + return;
63873 +}
63874 +
63875 +static void
63876 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
63877 +{
63878 + struct task_struct *task = current;
63879 + const struct cred *cred = current_cred();
63880 +
63881 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63882 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63883 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63884 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
63885 +
63886 + return;
63887 +}
63888 +
63889 +static void
63890 +gr_set_proc_res(struct task_struct *task)
63891 +{
63892 + struct acl_subject_label *proc;
63893 + unsigned short i;
63894 +
63895 + proc = task->acl;
63896 +
63897 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
63898 + return;
63899 +
63900 + for (i = 0; i < RLIM_NLIMITS; i++) {
63901 + if (!(proc->resmask & (1U << i)))
63902 + continue;
63903 +
63904 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
63905 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
63906 +
63907 + if (i == RLIMIT_CPU)
63908 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
63909 + }
63910 +
63911 + return;
63912 +}
63913 +
63914 +/* both of the below must be called with
63915 + rcu_read_lock();
63916 + read_lock(&tasklist_lock);
63917 + read_lock(&grsec_exec_file_lock);
63918 +*/
63919 +
63920 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
63921 +{
63922 + struct acl_object_label *obj;
63923 + struct file *filp;
63924 +
63925 + filp = task->exec_file;
63926 +
63927 + task->acl = subj;
63928 + task->is_writable = 0;
63929 + /* ignore additional mmap checks for processes that are writable
63930 + by the default ACL */
63931 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
63932 + if (unlikely(obj->mode & GR_WRITE))
63933 + task->is_writable = 1;
63934 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
63935 + if (unlikely(obj->mode & GR_WRITE))
63936 + task->is_writable = 1;
63937 +
63938 + gr_set_proc_res(task);
63939 +
63940 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63941 + 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);
63942 +#endif
63943 +}
63944 +
63945 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
63946 +{
63947 + __gr_apply_subject_to_task(&running_polstate, task, subj);
63948 +}
63949 +
63950 +__u32
63951 +gr_search_file(const struct dentry * dentry, const __u32 mode,
63952 + const struct vfsmount * mnt)
63953 +{
63954 + __u32 retval = mode;
63955 + struct acl_subject_label *curracl;
63956 + struct acl_object_label *currobj;
63957 +
63958 + if (unlikely(!(gr_status & GR_READY)))
63959 + return (mode & ~GR_AUDITS);
63960 +
63961 + curracl = current->acl;
63962 +
63963 + currobj = chk_obj_label(dentry, mnt, curracl);
63964 + retval = currobj->mode & mode;
63965 +
63966 + /* if we're opening a specified transfer file for writing
63967 + (e.g. /dev/initctl), then transfer our role to init
63968 + */
63969 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
63970 + current->role->roletype & GR_ROLE_PERSIST)) {
63971 + struct task_struct *task = init_pid_ns.child_reaper;
63972 +
63973 + if (task->role != current->role) {
63974 + task->acl_sp_role = 0;
63975 + task->acl_role_id = current->acl_role_id;
63976 + task->role = current->role;
63977 + rcu_read_lock();
63978 + read_lock(&grsec_exec_file_lock);
63979 + gr_apply_subject_to_task(task, NULL);
63980 + read_unlock(&grsec_exec_file_lock);
63981 + rcu_read_unlock();
63982 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
63983 + }
63984 + }
63985 +
63986 + if (unlikely
63987 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
63988 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
63989 + __u32 new_mode = mode;
63990 +
63991 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
63992 +
63993 + retval = new_mode;
63994 +
63995 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
63996 + new_mode |= GR_INHERIT;
63997 +
63998 + if (!(mode & GR_NOLEARN))
63999 + gr_log_learn(dentry, mnt, new_mode);
64000 + }
64001 +
64002 + return retval;
64003 +}
64004 +
64005 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64006 + const struct dentry *parent,
64007 + const struct vfsmount *mnt)
64008 +{
64009 + struct name_entry *match;
64010 + struct acl_object_label *matchpo;
64011 + struct acl_subject_label *curracl;
64012 + char *path;
64013 +
64014 + if (unlikely(!(gr_status & GR_READY)))
64015 + return NULL;
64016 +
64017 + preempt_disable();
64018 + path = gr_to_filename_rbac(new_dentry, mnt);
64019 + match = lookup_name_entry_create(path);
64020 +
64021 + curracl = current->acl;
64022 +
64023 + if (match) {
64024 + read_lock(&gr_inode_lock);
64025 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64026 + read_unlock(&gr_inode_lock);
64027 +
64028 + if (matchpo) {
64029 + preempt_enable();
64030 + return matchpo;
64031 + }
64032 + }
64033 +
64034 + // lookup parent
64035 +
64036 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64037 +
64038 + preempt_enable();
64039 + return matchpo;
64040 +}
64041 +
64042 +__u32
64043 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64044 + const struct vfsmount * mnt, const __u32 mode)
64045 +{
64046 + struct acl_object_label *matchpo;
64047 + __u32 retval;
64048 +
64049 + if (unlikely(!(gr_status & GR_READY)))
64050 + return (mode & ~GR_AUDITS);
64051 +
64052 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64053 +
64054 + retval = matchpo->mode & mode;
64055 +
64056 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64057 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64058 + __u32 new_mode = mode;
64059 +
64060 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64061 +
64062 + gr_log_learn(new_dentry, mnt, new_mode);
64063 + return new_mode;
64064 + }
64065 +
64066 + return retval;
64067 +}
64068 +
64069 +__u32
64070 +gr_check_link(const struct dentry * new_dentry,
64071 + const struct dentry * parent_dentry,
64072 + const struct vfsmount * parent_mnt,
64073 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64074 +{
64075 + struct acl_object_label *obj;
64076 + __u32 oldmode, newmode;
64077 + __u32 needmode;
64078 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64079 + GR_DELETE | GR_INHERIT;
64080 +
64081 + if (unlikely(!(gr_status & GR_READY)))
64082 + return (GR_CREATE | GR_LINK);
64083 +
64084 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64085 + oldmode = obj->mode;
64086 +
64087 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64088 + newmode = obj->mode;
64089 +
64090 + needmode = newmode & checkmodes;
64091 +
64092 + // old name for hardlink must have at least the permissions of the new name
64093 + if ((oldmode & needmode) != needmode)
64094 + goto bad;
64095 +
64096 + // if old name had restrictions/auditing, make sure the new name does as well
64097 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64098 +
64099 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64100 + if (is_privileged_binary(old_dentry))
64101 + needmode |= GR_SETID;
64102 +
64103 + if ((newmode & needmode) != needmode)
64104 + goto bad;
64105 +
64106 + // enforce minimum permissions
64107 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64108 + return newmode;
64109 +bad:
64110 + needmode = oldmode;
64111 + if (is_privileged_binary(old_dentry))
64112 + needmode |= GR_SETID;
64113 +
64114 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64115 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64116 + return (GR_CREATE | GR_LINK);
64117 + } else if (newmode & GR_SUPPRESS)
64118 + return GR_SUPPRESS;
64119 + else
64120 + return 0;
64121 +}
64122 +
64123 +int
64124 +gr_check_hidden_task(const struct task_struct *task)
64125 +{
64126 + if (unlikely(!(gr_status & GR_READY)))
64127 + return 0;
64128 +
64129 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64130 + return 1;
64131 +
64132 + return 0;
64133 +}
64134 +
64135 +int
64136 +gr_check_protected_task(const struct task_struct *task)
64137 +{
64138 + if (unlikely(!(gr_status & GR_READY) || !task))
64139 + return 0;
64140 +
64141 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64142 + task->acl != current->acl)
64143 + return 1;
64144 +
64145 + return 0;
64146 +}
64147 +
64148 +int
64149 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64150 +{
64151 + struct task_struct *p;
64152 + int ret = 0;
64153 +
64154 + if (unlikely(!(gr_status & GR_READY) || !pid))
64155 + return ret;
64156 +
64157 + read_lock(&tasklist_lock);
64158 + do_each_pid_task(pid, type, p) {
64159 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64160 + p->acl != current->acl) {
64161 + ret = 1;
64162 + goto out;
64163 + }
64164 + } while_each_pid_task(pid, type, p);
64165 +out:
64166 + read_unlock(&tasklist_lock);
64167 +
64168 + return ret;
64169 +}
64170 +
64171 +void
64172 +gr_copy_label(struct task_struct *tsk)
64173 +{
64174 + struct task_struct *p = current;
64175 +
64176 + tsk->inherited = p->inherited;
64177 + tsk->acl_sp_role = 0;
64178 + tsk->acl_role_id = p->acl_role_id;
64179 + tsk->acl = p->acl;
64180 + tsk->role = p->role;
64181 + tsk->signal->used_accept = 0;
64182 + tsk->signal->curr_ip = p->signal->curr_ip;
64183 + tsk->signal->saved_ip = p->signal->saved_ip;
64184 + if (p->exec_file)
64185 + get_file(p->exec_file);
64186 + tsk->exec_file = p->exec_file;
64187 + tsk->is_writable = p->is_writable;
64188 + if (unlikely(p->signal->used_accept)) {
64189 + p->signal->curr_ip = 0;
64190 + p->signal->saved_ip = 0;
64191 + }
64192 +
64193 + return;
64194 +}
64195 +
64196 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64197 +
64198 +int
64199 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64200 +{
64201 + unsigned int i;
64202 + __u16 num;
64203 + uid_t *uidlist;
64204 + uid_t curuid;
64205 + int realok = 0;
64206 + int effectiveok = 0;
64207 + int fsok = 0;
64208 + uid_t globalreal, globaleffective, globalfs;
64209 +
64210 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64211 + struct user_struct *user;
64212 +
64213 + if (!uid_valid(real))
64214 + goto skipit;
64215 +
64216 + /* find user based on global namespace */
64217 +
64218 + globalreal = GR_GLOBAL_UID(real);
64219 +
64220 + user = find_user(make_kuid(&init_user_ns, globalreal));
64221 + if (user == NULL)
64222 + goto skipit;
64223 +
64224 + if (gr_process_kernel_setuid_ban(user)) {
64225 + /* for find_user */
64226 + free_uid(user);
64227 + return 1;
64228 + }
64229 +
64230 + /* for find_user */
64231 + free_uid(user);
64232 +
64233 +skipit:
64234 +#endif
64235 +
64236 + if (unlikely(!(gr_status & GR_READY)))
64237 + return 0;
64238 +
64239 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64240 + gr_log_learn_uid_change(real, effective, fs);
64241 +
64242 + num = current->acl->user_trans_num;
64243 + uidlist = current->acl->user_transitions;
64244 +
64245 + if (uidlist == NULL)
64246 + return 0;
64247 +
64248 + if (!uid_valid(real)) {
64249 + realok = 1;
64250 + globalreal = (uid_t)-1;
64251 + } else {
64252 + globalreal = GR_GLOBAL_UID(real);
64253 + }
64254 + if (!uid_valid(effective)) {
64255 + effectiveok = 1;
64256 + globaleffective = (uid_t)-1;
64257 + } else {
64258 + globaleffective = GR_GLOBAL_UID(effective);
64259 + }
64260 + if (!uid_valid(fs)) {
64261 + fsok = 1;
64262 + globalfs = (uid_t)-1;
64263 + } else {
64264 + globalfs = GR_GLOBAL_UID(fs);
64265 + }
64266 +
64267 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64268 + for (i = 0; i < num; i++) {
64269 + curuid = uidlist[i];
64270 + if (globalreal == curuid)
64271 + realok = 1;
64272 + if (globaleffective == curuid)
64273 + effectiveok = 1;
64274 + if (globalfs == curuid)
64275 + fsok = 1;
64276 + }
64277 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64278 + for (i = 0; i < num; i++) {
64279 + curuid = uidlist[i];
64280 + if (globalreal == curuid)
64281 + break;
64282 + if (globaleffective == curuid)
64283 + break;
64284 + if (globalfs == curuid)
64285 + break;
64286 + }
64287 + /* not in deny list */
64288 + if (i == num) {
64289 + realok = 1;
64290 + effectiveok = 1;
64291 + fsok = 1;
64292 + }
64293 + }
64294 +
64295 + if (realok && effectiveok && fsok)
64296 + return 0;
64297 + else {
64298 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64299 + return 1;
64300 + }
64301 +}
64302 +
64303 +int
64304 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64305 +{
64306 + unsigned int i;
64307 + __u16 num;
64308 + gid_t *gidlist;
64309 + gid_t curgid;
64310 + int realok = 0;
64311 + int effectiveok = 0;
64312 + int fsok = 0;
64313 + gid_t globalreal, globaleffective, globalfs;
64314 +
64315 + if (unlikely(!(gr_status & GR_READY)))
64316 + return 0;
64317 +
64318 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64319 + gr_log_learn_gid_change(real, effective, fs);
64320 +
64321 + num = current->acl->group_trans_num;
64322 + gidlist = current->acl->group_transitions;
64323 +
64324 + if (gidlist == NULL)
64325 + return 0;
64326 +
64327 + if (!gid_valid(real)) {
64328 + realok = 1;
64329 + globalreal = (gid_t)-1;
64330 + } else {
64331 + globalreal = GR_GLOBAL_GID(real);
64332 + }
64333 + if (!gid_valid(effective)) {
64334 + effectiveok = 1;
64335 + globaleffective = (gid_t)-1;
64336 + } else {
64337 + globaleffective = GR_GLOBAL_GID(effective);
64338 + }
64339 + if (!gid_valid(fs)) {
64340 + fsok = 1;
64341 + globalfs = (gid_t)-1;
64342 + } else {
64343 + globalfs = GR_GLOBAL_GID(fs);
64344 + }
64345 +
64346 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64347 + for (i = 0; i < num; i++) {
64348 + curgid = gidlist[i];
64349 + if (globalreal == curgid)
64350 + realok = 1;
64351 + if (globaleffective == curgid)
64352 + effectiveok = 1;
64353 + if (globalfs == curgid)
64354 + fsok = 1;
64355 + }
64356 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64357 + for (i = 0; i < num; i++) {
64358 + curgid = gidlist[i];
64359 + if (globalreal == curgid)
64360 + break;
64361 + if (globaleffective == curgid)
64362 + break;
64363 + if (globalfs == curgid)
64364 + break;
64365 + }
64366 + /* not in deny list */
64367 + if (i == num) {
64368 + realok = 1;
64369 + effectiveok = 1;
64370 + fsok = 1;
64371 + }
64372 + }
64373 +
64374 + if (realok && effectiveok && fsok)
64375 + return 0;
64376 + else {
64377 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64378 + return 1;
64379 + }
64380 +}
64381 +
64382 +extern int gr_acl_is_capable(const int cap);
64383 +
64384 +void
64385 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64386 +{
64387 + struct acl_role_label *role = task->role;
64388 + struct acl_subject_label *subj = NULL;
64389 + struct acl_object_label *obj;
64390 + struct file *filp;
64391 + uid_t uid;
64392 + gid_t gid;
64393 +
64394 + if (unlikely(!(gr_status & GR_READY)))
64395 + return;
64396 +
64397 + uid = GR_GLOBAL_UID(kuid);
64398 + gid = GR_GLOBAL_GID(kgid);
64399 +
64400 + filp = task->exec_file;
64401 +
64402 + /* kernel process, we'll give them the kernel role */
64403 + if (unlikely(!filp)) {
64404 + task->role = running_polstate.kernel_role;
64405 + task->acl = running_polstate.kernel_role->root_label;
64406 + return;
64407 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
64408 + /* save the current ip at time of role lookup so that the proper
64409 + IP will be learned for role_allowed_ip */
64410 + task->signal->saved_ip = task->signal->curr_ip;
64411 + role = lookup_acl_role_label(task, uid, gid);
64412 + }
64413 +
64414 + /* don't change the role if we're not a privileged process */
64415 + if (role && task->role != role &&
64416 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64417 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64418 + return;
64419 +
64420 + /* perform subject lookup in possibly new role
64421 + we can use this result below in the case where role == task->role
64422 + */
64423 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64424 +
64425 + /* if we changed uid/gid, but result in the same role
64426 + and are using inheritance, don't lose the inherited subject
64427 + if current subject is other than what normal lookup
64428 + would result in, we arrived via inheritance, don't
64429 + lose subject
64430 + */
64431 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64432 + (subj == task->acl)))
64433 + task->acl = subj;
64434 +
64435 + /* leave task->inherited unaffected */
64436 +
64437 + task->role = role;
64438 +
64439 + task->is_writable = 0;
64440 +
64441 + /* ignore additional mmap checks for processes that are writable
64442 + by the default ACL */
64443 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64444 + if (unlikely(obj->mode & GR_WRITE))
64445 + task->is_writable = 1;
64446 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64447 + if (unlikely(obj->mode & GR_WRITE))
64448 + task->is_writable = 1;
64449 +
64450 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64451 + 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);
64452 +#endif
64453 +
64454 + gr_set_proc_res(task);
64455 +
64456 + return;
64457 +}
64458 +
64459 +int
64460 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64461 + const int unsafe_flags)
64462 +{
64463 + struct task_struct *task = current;
64464 + struct acl_subject_label *newacl;
64465 + struct acl_object_label *obj;
64466 + __u32 retmode;
64467 +
64468 + if (unlikely(!(gr_status & GR_READY)))
64469 + return 0;
64470 +
64471 + newacl = chk_subj_label(dentry, mnt, task->role);
64472 +
64473 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64474 + did an exec
64475 + */
64476 + rcu_read_lock();
64477 + read_lock(&tasklist_lock);
64478 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64479 + (task->parent->acl->mode & GR_POVERRIDE))) {
64480 + read_unlock(&tasklist_lock);
64481 + rcu_read_unlock();
64482 + goto skip_check;
64483 + }
64484 + read_unlock(&tasklist_lock);
64485 + rcu_read_unlock();
64486 +
64487 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64488 + !(task->role->roletype & GR_ROLE_GOD) &&
64489 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64490 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64491 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64492 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64493 + else
64494 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64495 + return -EACCES;
64496 + }
64497 +
64498 +skip_check:
64499 +
64500 + obj = chk_obj_label(dentry, mnt, task->acl);
64501 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64502 +
64503 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64504 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64505 + if (obj->nested)
64506 + task->acl = obj->nested;
64507 + else
64508 + task->acl = newacl;
64509 + task->inherited = 0;
64510 + } else {
64511 + task->inherited = 1;
64512 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64513 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64514 + }
64515 +
64516 + task->is_writable = 0;
64517 +
64518 + /* ignore additional mmap checks for processes that are writable
64519 + by the default ACL */
64520 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
64521 + if (unlikely(obj->mode & GR_WRITE))
64522 + task->is_writable = 1;
64523 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64524 + if (unlikely(obj->mode & GR_WRITE))
64525 + task->is_writable = 1;
64526 +
64527 + gr_set_proc_res(task);
64528 +
64529 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64530 + 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);
64531 +#endif
64532 + return 0;
64533 +}
64534 +
64535 +/* always called with valid inodev ptr */
64536 +static void
64537 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64538 +{
64539 + struct acl_object_label *matchpo;
64540 + struct acl_subject_label *matchps;
64541 + struct acl_subject_label *subj;
64542 + struct acl_role_label *role;
64543 + unsigned int x;
64544 +
64545 + FOR_EACH_ROLE_START(role)
64546 + FOR_EACH_SUBJECT_START(role, subj, x)
64547 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64548 + matchpo->mode |= GR_DELETED;
64549 + FOR_EACH_SUBJECT_END(subj,x)
64550 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64551 + /* nested subjects aren't in the role's subj_hash table */
64552 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64553 + matchpo->mode |= GR_DELETED;
64554 + FOR_EACH_NESTED_SUBJECT_END(subj)
64555 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64556 + matchps->mode |= GR_DELETED;
64557 + FOR_EACH_ROLE_END(role)
64558 +
64559 + inodev->nentry->deleted = 1;
64560 +
64561 + return;
64562 +}
64563 +
64564 +void
64565 +gr_handle_delete(const ino_t ino, const dev_t dev)
64566 +{
64567 + struct inodev_entry *inodev;
64568 +
64569 + if (unlikely(!(gr_status & GR_READY)))
64570 + return;
64571 +
64572 + write_lock(&gr_inode_lock);
64573 + inodev = lookup_inodev_entry(ino, dev);
64574 + if (inodev != NULL)
64575 + do_handle_delete(inodev, ino, dev);
64576 + write_unlock(&gr_inode_lock);
64577 +
64578 + return;
64579 +}
64580 +
64581 +static void
64582 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64583 + const ino_t newinode, const dev_t newdevice,
64584 + struct acl_subject_label *subj)
64585 +{
64586 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64587 + struct acl_object_label *match;
64588 +
64589 + match = subj->obj_hash[index];
64590 +
64591 + while (match && (match->inode != oldinode ||
64592 + match->device != olddevice ||
64593 + !(match->mode & GR_DELETED)))
64594 + match = match->next;
64595 +
64596 + if (match && (match->inode == oldinode)
64597 + && (match->device == olddevice)
64598 + && (match->mode & GR_DELETED)) {
64599 + if (match->prev == NULL) {
64600 + subj->obj_hash[index] = match->next;
64601 + if (match->next != NULL)
64602 + match->next->prev = NULL;
64603 + } else {
64604 + match->prev->next = match->next;
64605 + if (match->next != NULL)
64606 + match->next->prev = match->prev;
64607 + }
64608 + match->prev = NULL;
64609 + match->next = NULL;
64610 + match->inode = newinode;
64611 + match->device = newdevice;
64612 + match->mode &= ~GR_DELETED;
64613 +
64614 + insert_acl_obj_label(match, subj);
64615 + }
64616 +
64617 + return;
64618 +}
64619 +
64620 +static void
64621 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
64622 + const ino_t newinode, const dev_t newdevice,
64623 + struct acl_role_label *role)
64624 +{
64625 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
64626 + struct acl_subject_label *match;
64627 +
64628 + match = role->subj_hash[index];
64629 +
64630 + while (match && (match->inode != oldinode ||
64631 + match->device != olddevice ||
64632 + !(match->mode & GR_DELETED)))
64633 + match = match->next;
64634 +
64635 + if (match && (match->inode == oldinode)
64636 + && (match->device == olddevice)
64637 + && (match->mode & GR_DELETED)) {
64638 + if (match->prev == NULL) {
64639 + role->subj_hash[index] = match->next;
64640 + if (match->next != NULL)
64641 + match->next->prev = NULL;
64642 + } else {
64643 + match->prev->next = match->next;
64644 + if (match->next != NULL)
64645 + match->next->prev = match->prev;
64646 + }
64647 + match->prev = NULL;
64648 + match->next = NULL;
64649 + match->inode = newinode;
64650 + match->device = newdevice;
64651 + match->mode &= ~GR_DELETED;
64652 +
64653 + insert_acl_subj_label(match, role);
64654 + }
64655 +
64656 + return;
64657 +}
64658 +
64659 +static void
64660 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
64661 + const ino_t newinode, const dev_t newdevice)
64662 +{
64663 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
64664 + struct inodev_entry *match;
64665 +
64666 + match = running_polstate.inodev_set.i_hash[index];
64667 +
64668 + while (match && (match->nentry->inode != oldinode ||
64669 + match->nentry->device != olddevice || !match->nentry->deleted))
64670 + match = match->next;
64671 +
64672 + if (match && (match->nentry->inode == oldinode)
64673 + && (match->nentry->device == olddevice) &&
64674 + match->nentry->deleted) {
64675 + if (match->prev == NULL) {
64676 + running_polstate.inodev_set.i_hash[index] = match->next;
64677 + if (match->next != NULL)
64678 + match->next->prev = NULL;
64679 + } else {
64680 + match->prev->next = match->next;
64681 + if (match->next != NULL)
64682 + match->next->prev = match->prev;
64683 + }
64684 + match->prev = NULL;
64685 + match->next = NULL;
64686 + match->nentry->inode = newinode;
64687 + match->nentry->device = newdevice;
64688 + match->nentry->deleted = 0;
64689 +
64690 + insert_inodev_entry(match);
64691 + }
64692 +
64693 + return;
64694 +}
64695 +
64696 +static void
64697 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
64698 +{
64699 + struct acl_subject_label *subj;
64700 + struct acl_role_label *role;
64701 + unsigned int x;
64702 +
64703 + FOR_EACH_ROLE_START(role)
64704 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
64705 +
64706 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64707 + if ((subj->inode == ino) && (subj->device == dev)) {
64708 + subj->inode = ino;
64709 + subj->device = dev;
64710 + }
64711 + /* nested subjects aren't in the role's subj_hash table */
64712 + update_acl_obj_label(matchn->inode, matchn->device,
64713 + ino, dev, subj);
64714 + FOR_EACH_NESTED_SUBJECT_END(subj)
64715 + FOR_EACH_SUBJECT_START(role, subj, x)
64716 + update_acl_obj_label(matchn->inode, matchn->device,
64717 + ino, dev, subj);
64718 + FOR_EACH_SUBJECT_END(subj,x)
64719 + FOR_EACH_ROLE_END(role)
64720 +
64721 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
64722 +
64723 + return;
64724 +}
64725 +
64726 +static void
64727 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
64728 + const struct vfsmount *mnt)
64729 +{
64730 + ino_t ino = dentry->d_inode->i_ino;
64731 + dev_t dev = __get_dev(dentry);
64732 +
64733 + __do_handle_create(matchn, ino, dev);
64734 +
64735 + return;
64736 +}
64737 +
64738 +void
64739 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64740 +{
64741 + struct name_entry *matchn;
64742 +
64743 + if (unlikely(!(gr_status & GR_READY)))
64744 + return;
64745 +
64746 + preempt_disable();
64747 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
64748 +
64749 + if (unlikely((unsigned long)matchn)) {
64750 + write_lock(&gr_inode_lock);
64751 + do_handle_create(matchn, dentry, mnt);
64752 + write_unlock(&gr_inode_lock);
64753 + }
64754 + preempt_enable();
64755 +
64756 + return;
64757 +}
64758 +
64759 +void
64760 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64761 +{
64762 + struct name_entry *matchn;
64763 +
64764 + if (unlikely(!(gr_status & GR_READY)))
64765 + return;
64766 +
64767 + preempt_disable();
64768 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
64769 +
64770 + if (unlikely((unsigned long)matchn)) {
64771 + write_lock(&gr_inode_lock);
64772 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
64773 + write_unlock(&gr_inode_lock);
64774 + }
64775 + preempt_enable();
64776 +
64777 + return;
64778 +}
64779 +
64780 +void
64781 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64782 + struct dentry *old_dentry,
64783 + struct dentry *new_dentry,
64784 + struct vfsmount *mnt, const __u8 replace)
64785 +{
64786 + struct name_entry *matchn;
64787 + struct inodev_entry *inodev;
64788 + struct inode *inode = new_dentry->d_inode;
64789 + ino_t old_ino = old_dentry->d_inode->i_ino;
64790 + dev_t old_dev = __get_dev(old_dentry);
64791 +
64792 + /* vfs_rename swaps the name and parent link for old_dentry and
64793 + new_dentry
64794 + at this point, old_dentry has the new name, parent link, and inode
64795 + for the renamed file
64796 + if a file is being replaced by a rename, new_dentry has the inode
64797 + and name for the replaced file
64798 + */
64799 +
64800 + if (unlikely(!(gr_status & GR_READY)))
64801 + return;
64802 +
64803 + preempt_disable();
64804 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
64805 +
64806 + /* we wouldn't have to check d_inode if it weren't for
64807 + NFS silly-renaming
64808 + */
64809 +
64810 + write_lock(&gr_inode_lock);
64811 + if (unlikely(replace && inode)) {
64812 + ino_t new_ino = inode->i_ino;
64813 + dev_t new_dev = __get_dev(new_dentry);
64814 +
64815 + inodev = lookup_inodev_entry(new_ino, new_dev);
64816 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
64817 + do_handle_delete(inodev, new_ino, new_dev);
64818 + }
64819 +
64820 + inodev = lookup_inodev_entry(old_ino, old_dev);
64821 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
64822 + do_handle_delete(inodev, old_ino, old_dev);
64823 +
64824 + if (unlikely((unsigned long)matchn))
64825 + do_handle_create(matchn, old_dentry, mnt);
64826 +
64827 + write_unlock(&gr_inode_lock);
64828 + preempt_enable();
64829 +
64830 + return;
64831 +}
64832 +
64833 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
64834 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
64835 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
64836 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
64837 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
64838 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
64839 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
64840 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
64841 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
64842 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
64843 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
64844 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
64845 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
64846 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
64847 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
64848 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
64849 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
64850 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
64851 +};
64852 +
64853 +void
64854 +gr_learn_resource(const struct task_struct *task,
64855 + const int res, const unsigned long wanted, const int gt)
64856 +{
64857 + struct acl_subject_label *acl;
64858 + const struct cred *cred;
64859 +
64860 + if (unlikely((gr_status & GR_READY) &&
64861 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
64862 + goto skip_reslog;
64863 +
64864 + gr_log_resource(task, res, wanted, gt);
64865 +skip_reslog:
64866 +
64867 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
64868 + return;
64869 +
64870 + acl = task->acl;
64871 +
64872 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
64873 + !(acl->resmask & (1U << (unsigned short) res))))
64874 + return;
64875 +
64876 + if (wanted >= acl->res[res].rlim_cur) {
64877 + unsigned long res_add;
64878 +
64879 + res_add = wanted + res_learn_bumps[res];
64880 +
64881 + acl->res[res].rlim_cur = res_add;
64882 +
64883 + if (wanted > acl->res[res].rlim_max)
64884 + acl->res[res].rlim_max = res_add;
64885 +
64886 + /* only log the subject filename, since resource logging is supported for
64887 + single-subject learning only */
64888 + rcu_read_lock();
64889 + cred = __task_cred(task);
64890 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
64891 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
64892 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
64893 + "", (unsigned long) res, &task->signal->saved_ip);
64894 + rcu_read_unlock();
64895 + }
64896 +
64897 + return;
64898 +}
64899 +EXPORT_SYMBOL(gr_learn_resource);
64900 +#endif
64901 +
64902 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
64903 +void
64904 +pax_set_initial_flags(struct linux_binprm *bprm)
64905 +{
64906 + struct task_struct *task = current;
64907 + struct acl_subject_label *proc;
64908 + unsigned long flags;
64909 +
64910 + if (unlikely(!(gr_status & GR_READY)))
64911 + return;
64912 +
64913 + flags = pax_get_flags(task);
64914 +
64915 + proc = task->acl;
64916 +
64917 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
64918 + flags &= ~MF_PAX_PAGEEXEC;
64919 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
64920 + flags &= ~MF_PAX_SEGMEXEC;
64921 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
64922 + flags &= ~MF_PAX_RANDMMAP;
64923 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
64924 + flags &= ~MF_PAX_EMUTRAMP;
64925 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
64926 + flags &= ~MF_PAX_MPROTECT;
64927 +
64928 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
64929 + flags |= MF_PAX_PAGEEXEC;
64930 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
64931 + flags |= MF_PAX_SEGMEXEC;
64932 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
64933 + flags |= MF_PAX_RANDMMAP;
64934 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
64935 + flags |= MF_PAX_EMUTRAMP;
64936 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
64937 + flags |= MF_PAX_MPROTECT;
64938 +
64939 + pax_set_flags(task, flags);
64940 +
64941 + return;
64942 +}
64943 +#endif
64944 +
64945 +int
64946 +gr_handle_proc_ptrace(struct task_struct *task)
64947 +{
64948 + struct file *filp;
64949 + struct task_struct *tmp = task;
64950 + struct task_struct *curtemp = current;
64951 + __u32 retmode;
64952 +
64953 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64954 + if (unlikely(!(gr_status & GR_READY)))
64955 + return 0;
64956 +#endif
64957 +
64958 + read_lock(&tasklist_lock);
64959 + read_lock(&grsec_exec_file_lock);
64960 + filp = task->exec_file;
64961 +
64962 + while (task_pid_nr(tmp) > 0) {
64963 + if (tmp == curtemp)
64964 + break;
64965 + tmp = tmp->real_parent;
64966 + }
64967 +
64968 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64969 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
64970 + read_unlock(&grsec_exec_file_lock);
64971 + read_unlock(&tasklist_lock);
64972 + return 1;
64973 + }
64974 +
64975 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64976 + if (!(gr_status & GR_READY)) {
64977 + read_unlock(&grsec_exec_file_lock);
64978 + read_unlock(&tasklist_lock);
64979 + return 0;
64980 + }
64981 +#endif
64982 +
64983 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
64984 + read_unlock(&grsec_exec_file_lock);
64985 + read_unlock(&tasklist_lock);
64986 +
64987 + if (retmode & GR_NOPTRACE)
64988 + return 1;
64989 +
64990 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
64991 + && (current->acl != task->acl || (current->acl != current->role->root_label
64992 + && task_pid_nr(current) != task_pid_nr(task))))
64993 + return 1;
64994 +
64995 + return 0;
64996 +}
64997 +
64998 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
64999 +{
65000 + if (unlikely(!(gr_status & GR_READY)))
65001 + return;
65002 +
65003 + if (!(current->role->roletype & GR_ROLE_GOD))
65004 + return;
65005 +
65006 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65007 + p->role->rolename, gr_task_roletype_to_char(p),
65008 + p->acl->filename);
65009 +}
65010 +
65011 +int
65012 +gr_handle_ptrace(struct task_struct *task, const long request)
65013 +{
65014 + struct task_struct *tmp = task;
65015 + struct task_struct *curtemp = current;
65016 + __u32 retmode;
65017 +
65018 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65019 + if (unlikely(!(gr_status & GR_READY)))
65020 + return 0;
65021 +#endif
65022 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
65023 + read_lock(&tasklist_lock);
65024 + while (task_pid_nr(tmp) > 0) {
65025 + if (tmp == curtemp)
65026 + break;
65027 + tmp = tmp->real_parent;
65028 + }
65029 +
65030 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65031 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
65032 + read_unlock(&tasklist_lock);
65033 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65034 + return 1;
65035 + }
65036 + read_unlock(&tasklist_lock);
65037 + }
65038 +
65039 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65040 + if (!(gr_status & GR_READY))
65041 + return 0;
65042 +#endif
65043 +
65044 + read_lock(&grsec_exec_file_lock);
65045 + if (unlikely(!task->exec_file)) {
65046 + read_unlock(&grsec_exec_file_lock);
65047 + return 0;
65048 + }
65049 +
65050 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
65051 + read_unlock(&grsec_exec_file_lock);
65052 +
65053 + if (retmode & GR_NOPTRACE) {
65054 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65055 + return 1;
65056 + }
65057 +
65058 + if (retmode & GR_PTRACERD) {
65059 + switch (request) {
65060 + case PTRACE_SEIZE:
65061 + case PTRACE_POKETEXT:
65062 + case PTRACE_POKEDATA:
65063 + case PTRACE_POKEUSR:
65064 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
65065 + case PTRACE_SETREGS:
65066 + case PTRACE_SETFPREGS:
65067 +#endif
65068 +#ifdef CONFIG_X86
65069 + case PTRACE_SETFPXREGS:
65070 +#endif
65071 +#ifdef CONFIG_ALTIVEC
65072 + case PTRACE_SETVRREGS:
65073 +#endif
65074 + return 1;
65075 + default:
65076 + return 0;
65077 + }
65078 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
65079 + !(current->role->roletype & GR_ROLE_GOD) &&
65080 + (current->acl != task->acl)) {
65081 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65082 + return 1;
65083 + }
65084 +
65085 + return 0;
65086 +}
65087 +
65088 +static int is_writable_mmap(const struct file *filp)
65089 +{
65090 + struct task_struct *task = current;
65091 + struct acl_object_label *obj, *obj2;
65092 +
65093 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
65094 + !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))) {
65095 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65096 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
65097 + task->role->root_label);
65098 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
65099 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
65100 + return 1;
65101 + }
65102 + }
65103 + return 0;
65104 +}
65105 +
65106 +int
65107 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
65108 +{
65109 + __u32 mode;
65110 +
65111 + if (unlikely(!file || !(prot & PROT_EXEC)))
65112 + return 1;
65113 +
65114 + if (is_writable_mmap(file))
65115 + return 0;
65116 +
65117 + mode =
65118 + gr_search_file(file->f_path.dentry,
65119 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65120 + file->f_path.mnt);
65121 +
65122 + if (!gr_tpe_allow(file))
65123 + return 0;
65124 +
65125 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65126 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65127 + return 0;
65128 + } else if (unlikely(!(mode & GR_EXEC))) {
65129 + return 0;
65130 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65131 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65132 + return 1;
65133 + }
65134 +
65135 + return 1;
65136 +}
65137 +
65138 +int
65139 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65140 +{
65141 + __u32 mode;
65142 +
65143 + if (unlikely(!file || !(prot & PROT_EXEC)))
65144 + return 1;
65145 +
65146 + if (is_writable_mmap(file))
65147 + return 0;
65148 +
65149 + mode =
65150 + gr_search_file(file->f_path.dentry,
65151 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65152 + file->f_path.mnt);
65153 +
65154 + if (!gr_tpe_allow(file))
65155 + return 0;
65156 +
65157 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65158 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65159 + return 0;
65160 + } else if (unlikely(!(mode & GR_EXEC))) {
65161 + return 0;
65162 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65163 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65164 + return 1;
65165 + }
65166 +
65167 + return 1;
65168 +}
65169 +
65170 +void
65171 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65172 +{
65173 + unsigned long runtime;
65174 + unsigned long cputime;
65175 + unsigned int wday, cday;
65176 + __u8 whr, chr;
65177 + __u8 wmin, cmin;
65178 + __u8 wsec, csec;
65179 + struct timespec timeval;
65180 +
65181 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
65182 + !(task->acl->mode & GR_PROCACCT)))
65183 + return;
65184 +
65185 + do_posix_clock_monotonic_gettime(&timeval);
65186 + runtime = timeval.tv_sec - task->start_time.tv_sec;
65187 + wday = runtime / (3600 * 24);
65188 + runtime -= wday * (3600 * 24);
65189 + whr = runtime / 3600;
65190 + runtime -= whr * 3600;
65191 + wmin = runtime / 60;
65192 + runtime -= wmin * 60;
65193 + wsec = runtime;
65194 +
65195 + cputime = (task->utime + task->stime) / HZ;
65196 + cday = cputime / (3600 * 24);
65197 + cputime -= cday * (3600 * 24);
65198 + chr = cputime / 3600;
65199 + cputime -= chr * 3600;
65200 + cmin = cputime / 60;
65201 + cputime -= cmin * 60;
65202 + csec = cputime;
65203 +
65204 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
65205 +
65206 + return;
65207 +}
65208 +
65209 +#ifdef CONFIG_TASKSTATS
65210 +int gr_is_taskstats_denied(int pid)
65211 +{
65212 + struct task_struct *task;
65213 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65214 + const struct cred *cred;
65215 +#endif
65216 + int ret = 0;
65217 +
65218 + /* restrict taskstats viewing to un-chrooted root users
65219 + who have the 'view' subject flag if the RBAC system is enabled
65220 + */
65221 +
65222 + rcu_read_lock();
65223 + read_lock(&tasklist_lock);
65224 + task = find_task_by_vpid(pid);
65225 + if (task) {
65226 +#ifdef CONFIG_GRKERNSEC_CHROOT
65227 + if (proc_is_chrooted(task))
65228 + ret = -EACCES;
65229 +#endif
65230 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65231 + cred = __task_cred(task);
65232 +#ifdef CONFIG_GRKERNSEC_PROC_USER
65233 + if (gr_is_global_nonroot(cred->uid))
65234 + ret = -EACCES;
65235 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65236 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
65237 + ret = -EACCES;
65238 +#endif
65239 +#endif
65240 + if (gr_status & GR_READY) {
65241 + if (!(task->acl->mode & GR_VIEW))
65242 + ret = -EACCES;
65243 + }
65244 + } else
65245 + ret = -ENOENT;
65246 +
65247 + read_unlock(&tasklist_lock);
65248 + rcu_read_unlock();
65249 +
65250 + return ret;
65251 +}
65252 +#endif
65253 +
65254 +/* AUXV entries are filled via a descendant of search_binary_handler
65255 + after we've already applied the subject for the target
65256 +*/
65257 +int gr_acl_enable_at_secure(void)
65258 +{
65259 + if (unlikely(!(gr_status & GR_READY)))
65260 + return 0;
65261 +
65262 + if (current->acl->mode & GR_ATSECURE)
65263 + return 1;
65264 +
65265 + return 0;
65266 +}
65267 +
65268 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
65269 +{
65270 + struct task_struct *task = current;
65271 + struct dentry *dentry = file->f_path.dentry;
65272 + struct vfsmount *mnt = file->f_path.mnt;
65273 + struct acl_object_label *obj, *tmp;
65274 + struct acl_subject_label *subj;
65275 + unsigned int bufsize;
65276 + int is_not_root;
65277 + char *path;
65278 + dev_t dev = __get_dev(dentry);
65279 +
65280 + if (unlikely(!(gr_status & GR_READY)))
65281 + return 1;
65282 +
65283 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65284 + return 1;
65285 +
65286 + /* ignore Eric Biederman */
65287 + if (IS_PRIVATE(dentry->d_inode))
65288 + return 1;
65289 +
65290 + subj = task->acl;
65291 + read_lock(&gr_inode_lock);
65292 + do {
65293 + obj = lookup_acl_obj_label(ino, dev, subj);
65294 + if (obj != NULL) {
65295 + read_unlock(&gr_inode_lock);
65296 + return (obj->mode & GR_FIND) ? 1 : 0;
65297 + }
65298 + } while ((subj = subj->parent_subject));
65299 + read_unlock(&gr_inode_lock);
65300 +
65301 + /* this is purely an optimization since we're looking for an object
65302 + for the directory we're doing a readdir on
65303 + if it's possible for any globbed object to match the entry we're
65304 + filling into the directory, then the object we find here will be
65305 + an anchor point with attached globbed objects
65306 + */
65307 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
65308 + if (obj->globbed == NULL)
65309 + return (obj->mode & GR_FIND) ? 1 : 0;
65310 +
65311 + is_not_root = ((obj->filename[0] == '/') &&
65312 + (obj->filename[1] == '\0')) ? 0 : 1;
65313 + bufsize = PAGE_SIZE - namelen - is_not_root;
65314 +
65315 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
65316 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
65317 + return 1;
65318 +
65319 + preempt_disable();
65320 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
65321 + bufsize);
65322 +
65323 + bufsize = strlen(path);
65324 +
65325 + /* if base is "/", don't append an additional slash */
65326 + if (is_not_root)
65327 + *(path + bufsize) = '/';
65328 + memcpy(path + bufsize + is_not_root, name, namelen);
65329 + *(path + bufsize + namelen + is_not_root) = '\0';
65330 +
65331 + tmp = obj->globbed;
65332 + while (tmp) {
65333 + if (!glob_match(tmp->filename, path)) {
65334 + preempt_enable();
65335 + return (tmp->mode & GR_FIND) ? 1 : 0;
65336 + }
65337 + tmp = tmp->next;
65338 + }
65339 + preempt_enable();
65340 + return (obj->mode & GR_FIND) ? 1 : 0;
65341 +}
65342 +
65343 +void gr_put_exec_file(struct task_struct *task)
65344 +{
65345 + struct file *filp;
65346 +
65347 + write_lock(&grsec_exec_file_lock);
65348 + filp = task->exec_file;
65349 + task->exec_file = NULL;
65350 + write_unlock(&grsec_exec_file_lock);
65351 +
65352 + if (filp)
65353 + fput(filp);
65354 +
65355 + return;
65356 +}
65357 +
65358 +
65359 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
65360 +EXPORT_SYMBOL(gr_acl_is_enabled);
65361 +#endif
65362 +#ifdef CONFIG_SECURITY
65363 +EXPORT_SYMBOL(gr_check_user_change);
65364 +EXPORT_SYMBOL(gr_check_group_change);
65365 +#endif
65366 +
65367 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
65368 new file mode 100644
65369 index 0000000..18ffbbd
65370 --- /dev/null
65371 +++ b/grsecurity/gracl_alloc.c
65372 @@ -0,0 +1,105 @@
65373 +#include <linux/kernel.h>
65374 +#include <linux/mm.h>
65375 +#include <linux/slab.h>
65376 +#include <linux/vmalloc.h>
65377 +#include <linux/gracl.h>
65378 +#include <linux/grsecurity.h>
65379 +
65380 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
65381 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
65382 +
65383 +static __inline__ int
65384 +alloc_pop(void)
65385 +{
65386 + if (current_alloc_state->alloc_stack_next == 1)
65387 + return 0;
65388 +
65389 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
65390 +
65391 + current_alloc_state->alloc_stack_next--;
65392 +
65393 + return 1;
65394 +}
65395 +
65396 +static __inline__ int
65397 +alloc_push(void *buf)
65398 +{
65399 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
65400 + return 1;
65401 +
65402 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
65403 +
65404 + current_alloc_state->alloc_stack_next++;
65405 +
65406 + return 0;
65407 +}
65408 +
65409 +void *
65410 +acl_alloc(unsigned long len)
65411 +{
65412 + void *ret = NULL;
65413 +
65414 + if (!len || len > PAGE_SIZE)
65415 + goto out;
65416 +
65417 + ret = kmalloc(len, GFP_KERNEL);
65418 +
65419 + if (ret) {
65420 + if (alloc_push(ret)) {
65421 + kfree(ret);
65422 + ret = NULL;
65423 + }
65424 + }
65425 +
65426 +out:
65427 + return ret;
65428 +}
65429 +
65430 +void *
65431 +acl_alloc_num(unsigned long num, unsigned long len)
65432 +{
65433 + if (!len || (num > (PAGE_SIZE / len)))
65434 + return NULL;
65435 +
65436 + return acl_alloc(num * len);
65437 +}
65438 +
65439 +void
65440 +acl_free_all(void)
65441 +{
65442 + if (!current_alloc_state->alloc_stack)
65443 + return;
65444 +
65445 + while (alloc_pop()) ;
65446 +
65447 + if (current_alloc_state->alloc_stack) {
65448 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
65449 + kfree(current_alloc_state->alloc_stack);
65450 + else
65451 + vfree(current_alloc_state->alloc_stack);
65452 + }
65453 +
65454 + current_alloc_state->alloc_stack = NULL;
65455 + current_alloc_state->alloc_stack_size = 1;
65456 + current_alloc_state->alloc_stack_next = 1;
65457 +
65458 + return;
65459 +}
65460 +
65461 +int
65462 +acl_alloc_stack_init(unsigned long size)
65463 +{
65464 + if ((size * sizeof (void *)) <= PAGE_SIZE)
65465 + current_alloc_state->alloc_stack =
65466 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
65467 + else
65468 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
65469 +
65470 + current_alloc_state->alloc_stack_size = size;
65471 + current_alloc_state->alloc_stack_next = 1;
65472 +
65473 + if (!current_alloc_state->alloc_stack)
65474 + return 0;
65475 + else
65476 + return 1;
65477 +}
65478 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
65479 new file mode 100644
65480 index 0000000..bdd51ea
65481 --- /dev/null
65482 +++ b/grsecurity/gracl_cap.c
65483 @@ -0,0 +1,110 @@
65484 +#include <linux/kernel.h>
65485 +#include <linux/module.h>
65486 +#include <linux/sched.h>
65487 +#include <linux/gracl.h>
65488 +#include <linux/grsecurity.h>
65489 +#include <linux/grinternal.h>
65490 +
65491 +extern const char *captab_log[];
65492 +extern int captab_log_entries;
65493 +
65494 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65495 +{
65496 + struct acl_subject_label *curracl;
65497 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65498 + kernel_cap_t cap_audit = __cap_empty_set;
65499 +
65500 + if (!gr_acl_is_enabled())
65501 + return 1;
65502 +
65503 + curracl = task->acl;
65504 +
65505 + cap_drop = curracl->cap_lower;
65506 + cap_mask = curracl->cap_mask;
65507 + cap_audit = curracl->cap_invert_audit;
65508 +
65509 + while ((curracl = curracl->parent_subject)) {
65510 + /* if the cap isn't specified in the current computed mask but is specified in the
65511 + current level subject, and is lowered in the current level subject, then add
65512 + it to the set of dropped capabilities
65513 + otherwise, add the current level subject's mask to the current computed mask
65514 + */
65515 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65516 + cap_raise(cap_mask, cap);
65517 + if (cap_raised(curracl->cap_lower, cap))
65518 + cap_raise(cap_drop, cap);
65519 + if (cap_raised(curracl->cap_invert_audit, cap))
65520 + cap_raise(cap_audit, cap);
65521 + }
65522 + }
65523 +
65524 + if (!cap_raised(cap_drop, cap)) {
65525 + if (cap_raised(cap_audit, cap))
65526 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
65527 + return 1;
65528 + }
65529 +
65530 + curracl = task->acl;
65531 +
65532 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
65533 + && cap_raised(cred->cap_effective, cap)) {
65534 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65535 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
65536 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
65537 + gr_to_filename(task->exec_file->f_path.dentry,
65538 + task->exec_file->f_path.mnt) : curracl->filename,
65539 + curracl->filename, 0UL,
65540 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
65541 + return 1;
65542 + }
65543 +
65544 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
65545 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
65546 +
65547 + return 0;
65548 +}
65549 +
65550 +int
65551 +gr_acl_is_capable(const int cap)
65552 +{
65553 + return gr_task_acl_is_capable(current, current_cred(), cap);
65554 +}
65555 +
65556 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
65557 +{
65558 + struct acl_subject_label *curracl;
65559 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65560 +
65561 + if (!gr_acl_is_enabled())
65562 + return 1;
65563 +
65564 + curracl = task->acl;
65565 +
65566 + cap_drop = curracl->cap_lower;
65567 + cap_mask = curracl->cap_mask;
65568 +
65569 + while ((curracl = curracl->parent_subject)) {
65570 + /* if the cap isn't specified in the current computed mask but is specified in the
65571 + current level subject, and is lowered in the current level subject, then add
65572 + it to the set of dropped capabilities
65573 + otherwise, add the current level subject's mask to the current computed mask
65574 + */
65575 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65576 + cap_raise(cap_mask, cap);
65577 + if (cap_raised(curracl->cap_lower, cap))
65578 + cap_raise(cap_drop, cap);
65579 + }
65580 + }
65581 +
65582 + if (!cap_raised(cap_drop, cap))
65583 + return 1;
65584 +
65585 + return 0;
65586 +}
65587 +
65588 +int
65589 +gr_acl_is_capable_nolog(const int cap)
65590 +{
65591 + return gr_task_acl_is_capable_nolog(current, cap);
65592 +}
65593 +
65594 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
65595 new file mode 100644
65596 index 0000000..ca25605
65597 --- /dev/null
65598 +++ b/grsecurity/gracl_compat.c
65599 @@ -0,0 +1,270 @@
65600 +#include <linux/kernel.h>
65601 +#include <linux/gracl.h>
65602 +#include <linux/compat.h>
65603 +#include <linux/gracl_compat.h>
65604 +
65605 +#include <asm/uaccess.h>
65606 +
65607 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
65608 +{
65609 + struct gr_arg_wrapper_compat uwrapcompat;
65610 +
65611 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
65612 + return -EFAULT;
65613 +
65614 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
65615 + (uwrapcompat.version != 0x2901)) ||
65616 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
65617 + return -EINVAL;
65618 +
65619 + uwrap->arg = compat_ptr(uwrapcompat.arg);
65620 + uwrap->version = uwrapcompat.version;
65621 + uwrap->size = sizeof(struct gr_arg);
65622 +
65623 + return 0;
65624 +}
65625 +
65626 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
65627 +{
65628 + struct gr_arg_compat argcompat;
65629 +
65630 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
65631 + return -EFAULT;
65632 +
65633 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
65634 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
65635 + arg->role_db.num_roles = argcompat.role_db.num_roles;
65636 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
65637 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
65638 + arg->role_db.num_objects = argcompat.role_db.num_objects;
65639 +
65640 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
65641 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
65642 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
65643 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
65644 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
65645 + arg->segv_device = argcompat.segv_device;
65646 + arg->segv_inode = argcompat.segv_inode;
65647 + arg->segv_uid = argcompat.segv_uid;
65648 + arg->num_sprole_pws = argcompat.num_sprole_pws;
65649 + arg->mode = argcompat.mode;
65650 +
65651 + return 0;
65652 +}
65653 +
65654 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
65655 +{
65656 + struct acl_object_label_compat objcompat;
65657 +
65658 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
65659 + return -EFAULT;
65660 +
65661 + obj->filename = compat_ptr(objcompat.filename);
65662 + obj->inode = objcompat.inode;
65663 + obj->device = objcompat.device;
65664 + obj->mode = objcompat.mode;
65665 +
65666 + obj->nested = compat_ptr(objcompat.nested);
65667 + obj->globbed = compat_ptr(objcompat.globbed);
65668 +
65669 + obj->prev = compat_ptr(objcompat.prev);
65670 + obj->next = compat_ptr(objcompat.next);
65671 +
65672 + return 0;
65673 +}
65674 +
65675 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
65676 +{
65677 + unsigned int i;
65678 + struct acl_subject_label_compat subjcompat;
65679 +
65680 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
65681 + return -EFAULT;
65682 +
65683 + subj->filename = compat_ptr(subjcompat.filename);
65684 + subj->inode = subjcompat.inode;
65685 + subj->device = subjcompat.device;
65686 + subj->mode = subjcompat.mode;
65687 + subj->cap_mask = subjcompat.cap_mask;
65688 + subj->cap_lower = subjcompat.cap_lower;
65689 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
65690 +
65691 + for (i = 0; i < GR_NLIMITS; i++) {
65692 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
65693 + subj->res[i].rlim_cur = RLIM_INFINITY;
65694 + else
65695 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
65696 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
65697 + subj->res[i].rlim_max = RLIM_INFINITY;
65698 + else
65699 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
65700 + }
65701 + subj->resmask = subjcompat.resmask;
65702 +
65703 + subj->user_trans_type = subjcompat.user_trans_type;
65704 + subj->group_trans_type = subjcompat.group_trans_type;
65705 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
65706 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
65707 + subj->user_trans_num = subjcompat.user_trans_num;
65708 + subj->group_trans_num = subjcompat.group_trans_num;
65709 +
65710 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
65711 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
65712 + subj->ip_type = subjcompat.ip_type;
65713 + subj->ips = compat_ptr(subjcompat.ips);
65714 + subj->ip_num = subjcompat.ip_num;
65715 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
65716 +
65717 + subj->crashes = subjcompat.crashes;
65718 + subj->expires = subjcompat.expires;
65719 +
65720 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
65721 + subj->hash = compat_ptr(subjcompat.hash);
65722 + subj->prev = compat_ptr(subjcompat.prev);
65723 + subj->next = compat_ptr(subjcompat.next);
65724 +
65725 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
65726 + subj->obj_hash_size = subjcompat.obj_hash_size;
65727 + subj->pax_flags = subjcompat.pax_flags;
65728 +
65729 + return 0;
65730 +}
65731 +
65732 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
65733 +{
65734 + struct acl_role_label_compat rolecompat;
65735 +
65736 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
65737 + return -EFAULT;
65738 +
65739 + role->rolename = compat_ptr(rolecompat.rolename);
65740 + role->uidgid = rolecompat.uidgid;
65741 + role->roletype = rolecompat.roletype;
65742 +
65743 + role->auth_attempts = rolecompat.auth_attempts;
65744 + role->expires = rolecompat.expires;
65745 +
65746 + role->root_label = compat_ptr(rolecompat.root_label);
65747 + role->hash = compat_ptr(rolecompat.hash);
65748 +
65749 + role->prev = compat_ptr(rolecompat.prev);
65750 + role->next = compat_ptr(rolecompat.next);
65751 +
65752 + role->transitions = compat_ptr(rolecompat.transitions);
65753 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
65754 + role->domain_children = compat_ptr(rolecompat.domain_children);
65755 + role->domain_child_num = rolecompat.domain_child_num;
65756 +
65757 + role->umask = rolecompat.umask;
65758 +
65759 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
65760 + role->subj_hash_size = rolecompat.subj_hash_size;
65761 +
65762 + return 0;
65763 +}
65764 +
65765 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
65766 +{
65767 + struct role_allowed_ip_compat roleip_compat;
65768 +
65769 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
65770 + return -EFAULT;
65771 +
65772 + roleip->addr = roleip_compat.addr;
65773 + roleip->netmask = roleip_compat.netmask;
65774 +
65775 + roleip->prev = compat_ptr(roleip_compat.prev);
65776 + roleip->next = compat_ptr(roleip_compat.next);
65777 +
65778 + return 0;
65779 +}
65780 +
65781 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
65782 +{
65783 + struct role_transition_compat trans_compat;
65784 +
65785 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
65786 + return -EFAULT;
65787 +
65788 + trans->rolename = compat_ptr(trans_compat.rolename);
65789 +
65790 + trans->prev = compat_ptr(trans_compat.prev);
65791 + trans->next = compat_ptr(trans_compat.next);
65792 +
65793 + return 0;
65794 +
65795 +}
65796 +
65797 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
65798 +{
65799 + struct gr_hash_struct_compat hash_compat;
65800 +
65801 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
65802 + return -EFAULT;
65803 +
65804 + hash->table = compat_ptr(hash_compat.table);
65805 + hash->nametable = compat_ptr(hash_compat.nametable);
65806 + hash->first = compat_ptr(hash_compat.first);
65807 +
65808 + hash->table_size = hash_compat.table_size;
65809 + hash->used_size = hash_compat.used_size;
65810 +
65811 + hash->type = hash_compat.type;
65812 +
65813 + return 0;
65814 +}
65815 +
65816 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
65817 +{
65818 + compat_uptr_t ptrcompat;
65819 +
65820 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
65821 + return -EFAULT;
65822 +
65823 + *(void **)ptr = compat_ptr(ptrcompat);
65824 +
65825 + return 0;
65826 +}
65827 +
65828 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
65829 +{
65830 + struct acl_ip_label_compat ip_compat;
65831 +
65832 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
65833 + return -EFAULT;
65834 +
65835 + ip->iface = compat_ptr(ip_compat.iface);
65836 + ip->addr = ip_compat.addr;
65837 + ip->netmask = ip_compat.netmask;
65838 + ip->low = ip_compat.low;
65839 + ip->high = ip_compat.high;
65840 + ip->mode = ip_compat.mode;
65841 + ip->type = ip_compat.type;
65842 +
65843 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
65844 +
65845 + ip->prev = compat_ptr(ip_compat.prev);
65846 + ip->next = compat_ptr(ip_compat.next);
65847 +
65848 + return 0;
65849 +}
65850 +
65851 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
65852 +{
65853 + struct sprole_pw_compat pw_compat;
65854 +
65855 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
65856 + return -EFAULT;
65857 +
65858 + pw->rolename = compat_ptr(pw_compat.rolename);
65859 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
65860 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
65861 +
65862 + return 0;
65863 +}
65864 +
65865 +size_t get_gr_arg_wrapper_size_compat(void)
65866 +{
65867 + return sizeof(struct gr_arg_wrapper_compat);
65868 +}
65869 +
65870 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
65871 new file mode 100644
65872 index 0000000..a340c17
65873 --- /dev/null
65874 +++ b/grsecurity/gracl_fs.c
65875 @@ -0,0 +1,431 @@
65876 +#include <linux/kernel.h>
65877 +#include <linux/sched.h>
65878 +#include <linux/types.h>
65879 +#include <linux/fs.h>
65880 +#include <linux/file.h>
65881 +#include <linux/stat.h>
65882 +#include <linux/grsecurity.h>
65883 +#include <linux/grinternal.h>
65884 +#include <linux/gracl.h>
65885 +
65886 +umode_t
65887 +gr_acl_umask(void)
65888 +{
65889 + if (unlikely(!gr_acl_is_enabled()))
65890 + return 0;
65891 +
65892 + return current->role->umask;
65893 +}
65894 +
65895 +__u32
65896 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65897 + const struct vfsmount * mnt)
65898 +{
65899 + __u32 mode;
65900 +
65901 + if (unlikely(!dentry->d_inode))
65902 + return GR_FIND;
65903 +
65904 + mode =
65905 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
65906 +
65907 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
65908 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65909 + return mode;
65910 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
65911 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65912 + return 0;
65913 + } else if (unlikely(!(mode & GR_FIND)))
65914 + return 0;
65915 +
65916 + return GR_FIND;
65917 +}
65918 +
65919 +__u32
65920 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65921 + int acc_mode)
65922 +{
65923 + __u32 reqmode = GR_FIND;
65924 + __u32 mode;
65925 +
65926 + if (unlikely(!dentry->d_inode))
65927 + return reqmode;
65928 +
65929 + if (acc_mode & MAY_APPEND)
65930 + reqmode |= GR_APPEND;
65931 + else if (acc_mode & MAY_WRITE)
65932 + reqmode |= GR_WRITE;
65933 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
65934 + reqmode |= GR_READ;
65935 +
65936 + mode =
65937 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65938 + mnt);
65939 +
65940 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65941 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65942 + reqmode & GR_READ ? " reading" : "",
65943 + reqmode & GR_WRITE ? " writing" : reqmode &
65944 + GR_APPEND ? " appending" : "");
65945 + return reqmode;
65946 + } else
65947 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65948 + {
65949 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65950 + reqmode & GR_READ ? " reading" : "",
65951 + reqmode & GR_WRITE ? " writing" : reqmode &
65952 + GR_APPEND ? " appending" : "");
65953 + return 0;
65954 + } else if (unlikely((mode & reqmode) != reqmode))
65955 + return 0;
65956 +
65957 + return reqmode;
65958 +}
65959 +
65960 +__u32
65961 +gr_acl_handle_creat(const struct dentry * dentry,
65962 + const struct dentry * p_dentry,
65963 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65964 + const int imode)
65965 +{
65966 + __u32 reqmode = GR_WRITE | GR_CREATE;
65967 + __u32 mode;
65968 +
65969 + if (acc_mode & MAY_APPEND)
65970 + reqmode |= GR_APPEND;
65971 + // if a directory was required or the directory already exists, then
65972 + // don't count this open as a read
65973 + if ((acc_mode & MAY_READ) &&
65974 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
65975 + reqmode |= GR_READ;
65976 + if ((open_flags & O_CREAT) &&
65977 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
65978 + reqmode |= GR_SETID;
65979 +
65980 + mode =
65981 + gr_check_create(dentry, p_dentry, p_mnt,
65982 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
65983 +
65984 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65985 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65986 + reqmode & GR_READ ? " reading" : "",
65987 + reqmode & GR_WRITE ? " writing" : reqmode &
65988 + GR_APPEND ? " appending" : "");
65989 + return reqmode;
65990 + } else
65991 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65992 + {
65993 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65994 + reqmode & GR_READ ? " reading" : "",
65995 + reqmode & GR_WRITE ? " writing" : reqmode &
65996 + GR_APPEND ? " appending" : "");
65997 + return 0;
65998 + } else if (unlikely((mode & reqmode) != reqmode))
65999 + return 0;
66000 +
66001 + return reqmode;
66002 +}
66003 +
66004 +__u32
66005 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66006 + const int fmode)
66007 +{
66008 + __u32 mode, reqmode = GR_FIND;
66009 +
66010 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
66011 + reqmode |= GR_EXEC;
66012 + if (fmode & S_IWOTH)
66013 + reqmode |= GR_WRITE;
66014 + if (fmode & S_IROTH)
66015 + reqmode |= GR_READ;
66016 +
66017 + mode =
66018 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66019 + mnt);
66020 +
66021 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66022 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66023 + reqmode & GR_READ ? " reading" : "",
66024 + reqmode & GR_WRITE ? " writing" : "",
66025 + reqmode & GR_EXEC ? " executing" : "");
66026 + return reqmode;
66027 + } else
66028 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66029 + {
66030 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66031 + reqmode & GR_READ ? " reading" : "",
66032 + reqmode & GR_WRITE ? " writing" : "",
66033 + reqmode & GR_EXEC ? " executing" : "");
66034 + return 0;
66035 + } else if (unlikely((mode & reqmode) != reqmode))
66036 + return 0;
66037 +
66038 + return reqmode;
66039 +}
66040 +
66041 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
66042 +{
66043 + __u32 mode;
66044 +
66045 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
66046 +
66047 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66048 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
66049 + return mode;
66050 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66051 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
66052 + return 0;
66053 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66054 + return 0;
66055 +
66056 + return (reqmode);
66057 +}
66058 +
66059 +__u32
66060 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
66061 +{
66062 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
66063 +}
66064 +
66065 +__u32
66066 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
66067 +{
66068 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
66069 +}
66070 +
66071 +__u32
66072 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
66073 +{
66074 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
66075 +}
66076 +
66077 +__u32
66078 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
66079 +{
66080 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
66081 +}
66082 +
66083 +__u32
66084 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
66085 + umode_t *modeptr)
66086 +{
66087 + umode_t mode;
66088 +
66089 + *modeptr &= ~gr_acl_umask();
66090 + mode = *modeptr;
66091 +
66092 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
66093 + return 1;
66094 +
66095 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
66096 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
66097 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
66098 + GR_CHMOD_ACL_MSG);
66099 + } else {
66100 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
66101 + }
66102 +}
66103 +
66104 +__u32
66105 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
66106 +{
66107 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
66108 +}
66109 +
66110 +__u32
66111 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
66112 +{
66113 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
66114 +}
66115 +
66116 +__u32
66117 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
66118 +{
66119 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
66120 +}
66121 +
66122 +__u32
66123 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
66124 +{
66125 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
66126 + GR_UNIXCONNECT_ACL_MSG);
66127 +}
66128 +
66129 +/* hardlinks require at minimum create and link permission,
66130 + any additional privilege required is based on the
66131 + privilege of the file being linked to
66132 +*/
66133 +__u32
66134 +gr_acl_handle_link(const struct dentry * new_dentry,
66135 + const struct dentry * parent_dentry,
66136 + const struct vfsmount * parent_mnt,
66137 + const struct dentry * old_dentry,
66138 + const struct vfsmount * old_mnt, const struct filename *to)
66139 +{
66140 + __u32 mode;
66141 + __u32 needmode = GR_CREATE | GR_LINK;
66142 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
66143 +
66144 + mode =
66145 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
66146 + old_mnt);
66147 +
66148 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
66149 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66150 + return mode;
66151 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66152 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66153 + return 0;
66154 + } else if (unlikely((mode & needmode) != needmode))
66155 + return 0;
66156 +
66157 + return 1;
66158 +}
66159 +
66160 +__u32
66161 +gr_acl_handle_symlink(const struct dentry * new_dentry,
66162 + const struct dentry * parent_dentry,
66163 + const struct vfsmount * parent_mnt, const struct filename *from)
66164 +{
66165 + __u32 needmode = GR_WRITE | GR_CREATE;
66166 + __u32 mode;
66167 +
66168 + mode =
66169 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
66170 + GR_CREATE | GR_AUDIT_CREATE |
66171 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
66172 +
66173 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
66174 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66175 + return mode;
66176 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66177 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66178 + return 0;
66179 + } else if (unlikely((mode & needmode) != needmode))
66180 + return 0;
66181 +
66182 + return (GR_WRITE | GR_CREATE);
66183 +}
66184 +
66185 +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)
66186 +{
66187 + __u32 mode;
66188 +
66189 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66190 +
66191 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66192 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
66193 + return mode;
66194 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66195 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
66196 + return 0;
66197 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66198 + return 0;
66199 +
66200 + return (reqmode);
66201 +}
66202 +
66203 +__u32
66204 +gr_acl_handle_mknod(const struct dentry * new_dentry,
66205 + const struct dentry * parent_dentry,
66206 + const struct vfsmount * parent_mnt,
66207 + const int mode)
66208 +{
66209 + __u32 reqmode = GR_WRITE | GR_CREATE;
66210 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66211 + reqmode |= GR_SETID;
66212 +
66213 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66214 + reqmode, GR_MKNOD_ACL_MSG);
66215 +}
66216 +
66217 +__u32
66218 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
66219 + const struct dentry *parent_dentry,
66220 + const struct vfsmount *parent_mnt)
66221 +{
66222 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66223 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
66224 +}
66225 +
66226 +#define RENAME_CHECK_SUCCESS(old, new) \
66227 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
66228 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
66229 +
66230 +int
66231 +gr_acl_handle_rename(struct dentry *new_dentry,
66232 + struct dentry *parent_dentry,
66233 + const struct vfsmount *parent_mnt,
66234 + struct dentry *old_dentry,
66235 + struct inode *old_parent_inode,
66236 + struct vfsmount *old_mnt, const struct filename *newname)
66237 +{
66238 + __u32 comp1, comp2;
66239 + int error = 0;
66240 +
66241 + if (unlikely(!gr_acl_is_enabled()))
66242 + return 0;
66243 +
66244 + if (!new_dentry->d_inode) {
66245 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
66246 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
66247 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
66248 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
66249 + GR_DELETE | GR_AUDIT_DELETE |
66250 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66251 + GR_SUPPRESS, old_mnt);
66252 + } else {
66253 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
66254 + GR_CREATE | GR_DELETE |
66255 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
66256 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66257 + GR_SUPPRESS, parent_mnt);
66258 + comp2 =
66259 + gr_search_file(old_dentry,
66260 + GR_READ | GR_WRITE | GR_AUDIT_READ |
66261 + GR_DELETE | GR_AUDIT_DELETE |
66262 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
66263 + }
66264 +
66265 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
66266 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
66267 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66268 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
66269 + && !(comp2 & GR_SUPPRESS)) {
66270 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66271 + error = -EACCES;
66272 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
66273 + error = -EACCES;
66274 +
66275 + return error;
66276 +}
66277 +
66278 +void
66279 +gr_acl_handle_exit(void)
66280 +{
66281 + u16 id;
66282 + char *rolename;
66283 +
66284 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
66285 + !(current->role->roletype & GR_ROLE_PERSIST))) {
66286 + id = current->acl_role_id;
66287 + rolename = current->role->rolename;
66288 + gr_set_acls(1);
66289 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
66290 + }
66291 +
66292 + gr_put_exec_file(current);
66293 + return;
66294 +}
66295 +
66296 +int
66297 +gr_acl_handle_procpidmem(const struct task_struct *task)
66298 +{
66299 + if (unlikely(!gr_acl_is_enabled()))
66300 + return 0;
66301 +
66302 + if (task != current && task->acl->mode & GR_PROTPROCFD)
66303 + return -EACCES;
66304 +
66305 + return 0;
66306 +}
66307 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
66308 new file mode 100644
66309 index 0000000..f056b81
66310 --- /dev/null
66311 +++ b/grsecurity/gracl_ip.c
66312 @@ -0,0 +1,386 @@
66313 +#include <linux/kernel.h>
66314 +#include <asm/uaccess.h>
66315 +#include <asm/errno.h>
66316 +#include <net/sock.h>
66317 +#include <linux/file.h>
66318 +#include <linux/fs.h>
66319 +#include <linux/net.h>
66320 +#include <linux/in.h>
66321 +#include <linux/skbuff.h>
66322 +#include <linux/ip.h>
66323 +#include <linux/udp.h>
66324 +#include <linux/types.h>
66325 +#include <linux/sched.h>
66326 +#include <linux/netdevice.h>
66327 +#include <linux/inetdevice.h>
66328 +#include <linux/gracl.h>
66329 +#include <linux/grsecurity.h>
66330 +#include <linux/grinternal.h>
66331 +
66332 +#define GR_BIND 0x01
66333 +#define GR_CONNECT 0x02
66334 +#define GR_INVERT 0x04
66335 +#define GR_BINDOVERRIDE 0x08
66336 +#define GR_CONNECTOVERRIDE 0x10
66337 +#define GR_SOCK_FAMILY 0x20
66338 +
66339 +static const char * gr_protocols[IPPROTO_MAX] = {
66340 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
66341 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
66342 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
66343 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
66344 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
66345 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
66346 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
66347 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
66348 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
66349 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
66350 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
66351 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
66352 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
66353 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
66354 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
66355 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
66356 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
66357 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
66358 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
66359 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
66360 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
66361 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
66362 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
66363 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
66364 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
66365 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
66366 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
66367 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
66368 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
66369 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
66370 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
66371 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
66372 + };
66373 +
66374 +static const char * gr_socktypes[SOCK_MAX] = {
66375 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
66376 + "unknown:7", "unknown:8", "unknown:9", "packet"
66377 + };
66378 +
66379 +static const char * gr_sockfamilies[AF_MAX+1] = {
66380 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
66381 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
66382 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
66383 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
66384 + };
66385 +
66386 +const char *
66387 +gr_proto_to_name(unsigned char proto)
66388 +{
66389 + return gr_protocols[proto];
66390 +}
66391 +
66392 +const char *
66393 +gr_socktype_to_name(unsigned char type)
66394 +{
66395 + return gr_socktypes[type];
66396 +}
66397 +
66398 +const char *
66399 +gr_sockfamily_to_name(unsigned char family)
66400 +{
66401 + return gr_sockfamilies[family];
66402 +}
66403 +
66404 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
66405 +
66406 +int
66407 +gr_search_socket(const int domain, const int type, const int protocol)
66408 +{
66409 + struct acl_subject_label *curr;
66410 + const struct cred *cred = current_cred();
66411 +
66412 + if (unlikely(!gr_acl_is_enabled()))
66413 + goto exit;
66414 +
66415 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
66416 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
66417 + goto exit; // let the kernel handle it
66418 +
66419 + curr = current->acl;
66420 +
66421 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
66422 + /* the family is allowed, if this is PF_INET allow it only if
66423 + the extra sock type/protocol checks pass */
66424 + if (domain == PF_INET)
66425 + goto inet_check;
66426 + goto exit;
66427 + } else {
66428 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66429 + __u32 fakeip = 0;
66430 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66431 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66432 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66433 + gr_to_filename(current->exec_file->f_path.dentry,
66434 + current->exec_file->f_path.mnt) :
66435 + curr->filename, curr->filename,
66436 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
66437 + &current->signal->saved_ip);
66438 + goto exit;
66439 + }
66440 + goto exit_fail;
66441 + }
66442 +
66443 +inet_check:
66444 + /* the rest of this checking is for IPv4 only */
66445 + if (!curr->ips)
66446 + goto exit;
66447 +
66448 + if ((curr->ip_type & (1U << type)) &&
66449 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
66450 + goto exit;
66451 +
66452 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66453 + /* we don't place acls on raw sockets , and sometimes
66454 + dgram/ip sockets are opened for ioctl and not
66455 + bind/connect, so we'll fake a bind learn log */
66456 + if (type == SOCK_RAW || type == SOCK_PACKET) {
66457 + __u32 fakeip = 0;
66458 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66459 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66460 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66461 + gr_to_filename(current->exec_file->f_path.dentry,
66462 + current->exec_file->f_path.mnt) :
66463 + curr->filename, curr->filename,
66464 + &fakeip, 0, type,
66465 + protocol, GR_CONNECT, &current->signal->saved_ip);
66466 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
66467 + __u32 fakeip = 0;
66468 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66469 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66470 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66471 + gr_to_filename(current->exec_file->f_path.dentry,
66472 + current->exec_file->f_path.mnt) :
66473 + curr->filename, curr->filename,
66474 + &fakeip, 0, type,
66475 + protocol, GR_BIND, &current->signal->saved_ip);
66476 + }
66477 + /* we'll log when they use connect or bind */
66478 + goto exit;
66479 + }
66480 +
66481 +exit_fail:
66482 + if (domain == PF_INET)
66483 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
66484 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
66485 + else if (rcu_access_pointer(net_families[domain]) != NULL)
66486 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
66487 + gr_socktype_to_name(type), protocol);
66488 +
66489 + return 0;
66490 +exit:
66491 + return 1;
66492 +}
66493 +
66494 +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)
66495 +{
66496 + if ((ip->mode & mode) &&
66497 + (ip_port >= ip->low) &&
66498 + (ip_port <= ip->high) &&
66499 + ((ntohl(ip_addr) & our_netmask) ==
66500 + (ntohl(our_addr) & our_netmask))
66501 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
66502 + && (ip->type & (1U << type))) {
66503 + if (ip->mode & GR_INVERT)
66504 + return 2; // specifically denied
66505 + else
66506 + return 1; // allowed
66507 + }
66508 +
66509 + return 0; // not specifically allowed, may continue parsing
66510 +}
66511 +
66512 +static int
66513 +gr_search_connectbind(const int full_mode, struct sock *sk,
66514 + struct sockaddr_in *addr, const int type)
66515 +{
66516 + char iface[IFNAMSIZ] = {0};
66517 + struct acl_subject_label *curr;
66518 + struct acl_ip_label *ip;
66519 + struct inet_sock *isk;
66520 + struct net_device *dev;
66521 + struct in_device *idev;
66522 + unsigned long i;
66523 + int ret;
66524 + int mode = full_mode & (GR_BIND | GR_CONNECT);
66525 + __u32 ip_addr = 0;
66526 + __u32 our_addr;
66527 + __u32 our_netmask;
66528 + char *p;
66529 + __u16 ip_port = 0;
66530 + const struct cred *cred = current_cred();
66531 +
66532 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
66533 + return 0;
66534 +
66535 + curr = current->acl;
66536 + isk = inet_sk(sk);
66537 +
66538 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
66539 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
66540 + addr->sin_addr.s_addr = curr->inaddr_any_override;
66541 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
66542 + struct sockaddr_in saddr;
66543 + int err;
66544 +
66545 + saddr.sin_family = AF_INET;
66546 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
66547 + saddr.sin_port = isk->inet_sport;
66548 +
66549 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66550 + if (err)
66551 + return err;
66552 +
66553 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66554 + if (err)
66555 + return err;
66556 + }
66557 +
66558 + if (!curr->ips)
66559 + return 0;
66560 +
66561 + ip_addr = addr->sin_addr.s_addr;
66562 + ip_port = ntohs(addr->sin_port);
66563 +
66564 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66565 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66566 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66567 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66568 + gr_to_filename(current->exec_file->f_path.dentry,
66569 + current->exec_file->f_path.mnt) :
66570 + curr->filename, curr->filename,
66571 + &ip_addr, ip_port, type,
66572 + sk->sk_protocol, mode, &current->signal->saved_ip);
66573 + return 0;
66574 + }
66575 +
66576 + for (i = 0; i < curr->ip_num; i++) {
66577 + ip = *(curr->ips + i);
66578 + if (ip->iface != NULL) {
66579 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
66580 + p = strchr(iface, ':');
66581 + if (p != NULL)
66582 + *p = '\0';
66583 + dev = dev_get_by_name(sock_net(sk), iface);
66584 + if (dev == NULL)
66585 + continue;
66586 + idev = in_dev_get(dev);
66587 + if (idev == NULL) {
66588 + dev_put(dev);
66589 + continue;
66590 + }
66591 + rcu_read_lock();
66592 + for_ifa(idev) {
66593 + if (!strcmp(ip->iface, ifa->ifa_label)) {
66594 + our_addr = ifa->ifa_address;
66595 + our_netmask = 0xffffffff;
66596 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66597 + if (ret == 1) {
66598 + rcu_read_unlock();
66599 + in_dev_put(idev);
66600 + dev_put(dev);
66601 + return 0;
66602 + } else if (ret == 2) {
66603 + rcu_read_unlock();
66604 + in_dev_put(idev);
66605 + dev_put(dev);
66606 + goto denied;
66607 + }
66608 + }
66609 + } endfor_ifa(idev);
66610 + rcu_read_unlock();
66611 + in_dev_put(idev);
66612 + dev_put(dev);
66613 + } else {
66614 + our_addr = ip->addr;
66615 + our_netmask = ip->netmask;
66616 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66617 + if (ret == 1)
66618 + return 0;
66619 + else if (ret == 2)
66620 + goto denied;
66621 + }
66622 + }
66623 +
66624 +denied:
66625 + if (mode == GR_BIND)
66626 + 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));
66627 + else if (mode == GR_CONNECT)
66628 + 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));
66629 +
66630 + return -EACCES;
66631 +}
66632 +
66633 +int
66634 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
66635 +{
66636 + /* always allow disconnection of dgram sockets with connect */
66637 + if (addr->sin_family == AF_UNSPEC)
66638 + return 0;
66639 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
66640 +}
66641 +
66642 +int
66643 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
66644 +{
66645 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
66646 +}
66647 +
66648 +int gr_search_listen(struct socket *sock)
66649 +{
66650 + struct sock *sk = sock->sk;
66651 + struct sockaddr_in addr;
66652 +
66653 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66654 + addr.sin_port = inet_sk(sk)->inet_sport;
66655 +
66656 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66657 +}
66658 +
66659 +int gr_search_accept(struct socket *sock)
66660 +{
66661 + struct sock *sk = sock->sk;
66662 + struct sockaddr_in addr;
66663 +
66664 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66665 + addr.sin_port = inet_sk(sk)->inet_sport;
66666 +
66667 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66668 +}
66669 +
66670 +int
66671 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
66672 +{
66673 + if (addr)
66674 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
66675 + else {
66676 + struct sockaddr_in sin;
66677 + const struct inet_sock *inet = inet_sk(sk);
66678 +
66679 + sin.sin_addr.s_addr = inet->inet_daddr;
66680 + sin.sin_port = inet->inet_dport;
66681 +
66682 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66683 + }
66684 +}
66685 +
66686 +int
66687 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
66688 +{
66689 + struct sockaddr_in sin;
66690 +
66691 + if (unlikely(skb->len < sizeof (struct udphdr)))
66692 + return 0; // skip this packet
66693 +
66694 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
66695 + sin.sin_port = udp_hdr(skb)->source;
66696 +
66697 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66698 +}
66699 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
66700 new file mode 100644
66701 index 0000000..25f54ef
66702 --- /dev/null
66703 +++ b/grsecurity/gracl_learn.c
66704 @@ -0,0 +1,207 @@
66705 +#include <linux/kernel.h>
66706 +#include <linux/mm.h>
66707 +#include <linux/sched.h>
66708 +#include <linux/poll.h>
66709 +#include <linux/string.h>
66710 +#include <linux/file.h>
66711 +#include <linux/types.h>
66712 +#include <linux/vmalloc.h>
66713 +#include <linux/grinternal.h>
66714 +
66715 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
66716 + size_t count, loff_t *ppos);
66717 +extern int gr_acl_is_enabled(void);
66718 +
66719 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
66720 +static int gr_learn_attached;
66721 +
66722 +/* use a 512k buffer */
66723 +#define LEARN_BUFFER_SIZE (512 * 1024)
66724 +
66725 +static DEFINE_SPINLOCK(gr_learn_lock);
66726 +static DEFINE_MUTEX(gr_learn_user_mutex);
66727 +
66728 +/* we need to maintain two buffers, so that the kernel context of grlearn
66729 + uses a semaphore around the userspace copying, and the other kernel contexts
66730 + use a spinlock when copying into the buffer, since they cannot sleep
66731 +*/
66732 +static char *learn_buffer;
66733 +static char *learn_buffer_user;
66734 +static int learn_buffer_len;
66735 +static int learn_buffer_user_len;
66736 +
66737 +static ssize_t
66738 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
66739 +{
66740 + DECLARE_WAITQUEUE(wait, current);
66741 + ssize_t retval = 0;
66742 +
66743 + add_wait_queue(&learn_wait, &wait);
66744 + set_current_state(TASK_INTERRUPTIBLE);
66745 + do {
66746 + mutex_lock(&gr_learn_user_mutex);
66747 + spin_lock(&gr_learn_lock);
66748 + if (learn_buffer_len)
66749 + break;
66750 + spin_unlock(&gr_learn_lock);
66751 + mutex_unlock(&gr_learn_user_mutex);
66752 + if (file->f_flags & O_NONBLOCK) {
66753 + retval = -EAGAIN;
66754 + goto out;
66755 + }
66756 + if (signal_pending(current)) {
66757 + retval = -ERESTARTSYS;
66758 + goto out;
66759 + }
66760 +
66761 + schedule();
66762 + } while (1);
66763 +
66764 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
66765 + learn_buffer_user_len = learn_buffer_len;
66766 + retval = learn_buffer_len;
66767 + learn_buffer_len = 0;
66768 +
66769 + spin_unlock(&gr_learn_lock);
66770 +
66771 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
66772 + retval = -EFAULT;
66773 +
66774 + mutex_unlock(&gr_learn_user_mutex);
66775 +out:
66776 + set_current_state(TASK_RUNNING);
66777 + remove_wait_queue(&learn_wait, &wait);
66778 + return retval;
66779 +}
66780 +
66781 +static unsigned int
66782 +poll_learn(struct file * file, poll_table * wait)
66783 +{
66784 + poll_wait(file, &learn_wait, wait);
66785 +
66786 + if (learn_buffer_len)
66787 + return (POLLIN | POLLRDNORM);
66788 +
66789 + return 0;
66790 +}
66791 +
66792 +void
66793 +gr_clear_learn_entries(void)
66794 +{
66795 + char *tmp;
66796 +
66797 + mutex_lock(&gr_learn_user_mutex);
66798 + spin_lock(&gr_learn_lock);
66799 + tmp = learn_buffer;
66800 + learn_buffer = NULL;
66801 + spin_unlock(&gr_learn_lock);
66802 + if (tmp)
66803 + vfree(tmp);
66804 + if (learn_buffer_user != NULL) {
66805 + vfree(learn_buffer_user);
66806 + learn_buffer_user = NULL;
66807 + }
66808 + learn_buffer_len = 0;
66809 + mutex_unlock(&gr_learn_user_mutex);
66810 +
66811 + return;
66812 +}
66813 +
66814 +void
66815 +gr_add_learn_entry(const char *fmt, ...)
66816 +{
66817 + va_list args;
66818 + unsigned int len;
66819 +
66820 + if (!gr_learn_attached)
66821 + return;
66822 +
66823 + spin_lock(&gr_learn_lock);
66824 +
66825 + /* leave a gap at the end so we know when it's "full" but don't have to
66826 + compute the exact length of the string we're trying to append
66827 + */
66828 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
66829 + spin_unlock(&gr_learn_lock);
66830 + wake_up_interruptible(&learn_wait);
66831 + return;
66832 + }
66833 + if (learn_buffer == NULL) {
66834 + spin_unlock(&gr_learn_lock);
66835 + return;
66836 + }
66837 +
66838 + va_start(args, fmt);
66839 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
66840 + va_end(args);
66841 +
66842 + learn_buffer_len += len + 1;
66843 +
66844 + spin_unlock(&gr_learn_lock);
66845 + wake_up_interruptible(&learn_wait);
66846 +
66847 + return;
66848 +}
66849 +
66850 +static int
66851 +open_learn(struct inode *inode, struct file *file)
66852 +{
66853 + if (file->f_mode & FMODE_READ && gr_learn_attached)
66854 + return -EBUSY;
66855 + if (file->f_mode & FMODE_READ) {
66856 + int retval = 0;
66857 + mutex_lock(&gr_learn_user_mutex);
66858 + if (learn_buffer == NULL)
66859 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
66860 + if (learn_buffer_user == NULL)
66861 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
66862 + if (learn_buffer == NULL) {
66863 + retval = -ENOMEM;
66864 + goto out_error;
66865 + }
66866 + if (learn_buffer_user == NULL) {
66867 + retval = -ENOMEM;
66868 + goto out_error;
66869 + }
66870 + learn_buffer_len = 0;
66871 + learn_buffer_user_len = 0;
66872 + gr_learn_attached = 1;
66873 +out_error:
66874 + mutex_unlock(&gr_learn_user_mutex);
66875 + return retval;
66876 + }
66877 + return 0;
66878 +}
66879 +
66880 +static int
66881 +close_learn(struct inode *inode, struct file *file)
66882 +{
66883 + if (file->f_mode & FMODE_READ) {
66884 + char *tmp = NULL;
66885 + mutex_lock(&gr_learn_user_mutex);
66886 + spin_lock(&gr_learn_lock);
66887 + tmp = learn_buffer;
66888 + learn_buffer = NULL;
66889 + spin_unlock(&gr_learn_lock);
66890 + if (tmp)
66891 + vfree(tmp);
66892 + if (learn_buffer_user != NULL) {
66893 + vfree(learn_buffer_user);
66894 + learn_buffer_user = NULL;
66895 + }
66896 + learn_buffer_len = 0;
66897 + learn_buffer_user_len = 0;
66898 + gr_learn_attached = 0;
66899 + mutex_unlock(&gr_learn_user_mutex);
66900 + }
66901 +
66902 + return 0;
66903 +}
66904 +
66905 +const struct file_operations grsec_fops = {
66906 + .read = read_learn,
66907 + .write = write_grsec_handler,
66908 + .open = open_learn,
66909 + .release = close_learn,
66910 + .poll = poll_learn,
66911 +};
66912 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
66913 new file mode 100644
66914 index 0000000..d409f33
66915 --- /dev/null
66916 +++ b/grsecurity/gracl_policy.c
66917 @@ -0,0 +1,1825 @@
66918 +#include <linux/kernel.h>
66919 +#include <linux/module.h>
66920 +#include <linux/sched.h>
66921 +#include <linux/mm.h>
66922 +#include <linux/file.h>
66923 +#include <linux/fs.h>
66924 +#include <linux/namei.h>
66925 +#include <linux/mount.h>
66926 +#include <linux/tty.h>
66927 +#include <linux/proc_fs.h>
66928 +#include <linux/lglock.h>
66929 +#include <linux/slab.h>
66930 +#include <linux/vmalloc.h>
66931 +#include <linux/types.h>
66932 +#include <linux/sysctl.h>
66933 +#include <linux/netdevice.h>
66934 +#include <linux/ptrace.h>
66935 +#include <linux/gracl.h>
66936 +#include <linux/gralloc.h>
66937 +#include <linux/security.h>
66938 +#include <linux/grinternal.h>
66939 +#include <linux/pid_namespace.h>
66940 +#include <linux/stop_machine.h>
66941 +#include <linux/fdtable.h>
66942 +#include <linux/percpu.h>
66943 +#include <linux/lglock.h>
66944 +#include <linux/hugetlb.h>
66945 +#include <linux/posix-timers.h>
66946 +#include "../fs/mount.h"
66947 +
66948 +#include <asm/uaccess.h>
66949 +#include <asm/errno.h>
66950 +#include <asm/mman.h>
66951 +
66952 +extern struct gr_policy_state *polstate;
66953 +
66954 +#define FOR_EACH_ROLE_START(role) \
66955 + role = polstate->role_list; \
66956 + while (role) {
66957 +
66958 +#define FOR_EACH_ROLE_END(role) \
66959 + role = role->prev; \
66960 + }
66961 +
66962 +struct path gr_real_root;
66963 +
66964 +extern struct gr_alloc_state *current_alloc_state;
66965 +
66966 +u16 acl_sp_role_value;
66967 +
66968 +static DEFINE_MUTEX(gr_dev_mutex);
66969 +
66970 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
66971 +extern void gr_clear_learn_entries(void);
66972 +
66973 +static struct gr_arg gr_usermode;
66974 +static unsigned char gr_system_salt[GR_SALT_LEN];
66975 +static unsigned char gr_system_sum[GR_SHA_LEN];
66976 +
66977 +static unsigned int gr_auth_attempts = 0;
66978 +static unsigned long gr_auth_expires = 0UL;
66979 +
66980 +struct acl_object_label *fakefs_obj_rw;
66981 +struct acl_object_label *fakefs_obj_rwx;
66982 +
66983 +extern int gr_init_uidset(void);
66984 +extern void gr_free_uidset(void);
66985 +extern void gr_remove_uid(uid_t uid);
66986 +extern int gr_find_uid(uid_t uid);
66987 +
66988 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
66989 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
66990 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
66991 +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);
66992 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
66993 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
66994 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
66995 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
66996 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
66997 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
66998 +extern void assign_special_role(const char *rolename);
66999 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
67000 +extern int gr_rbac_disable(void *unused);
67001 +extern void gr_enable_rbac_system(void);
67002 +
67003 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
67004 +{
67005 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
67006 + return -EFAULT;
67007 +
67008 + return 0;
67009 +}
67010 +
67011 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
67012 +{
67013 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
67014 + return -EFAULT;
67015 +
67016 + return 0;
67017 +}
67018 +
67019 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
67020 +{
67021 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
67022 + return -EFAULT;
67023 +
67024 + return 0;
67025 +}
67026 +
67027 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
67028 +{
67029 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
67030 + return -EFAULT;
67031 +
67032 + return 0;
67033 +}
67034 +
67035 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
67036 +{
67037 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
67038 + return -EFAULT;
67039 +
67040 + return 0;
67041 +}
67042 +
67043 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
67044 +{
67045 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
67046 + return -EFAULT;
67047 +
67048 + return 0;
67049 +}
67050 +
67051 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
67052 +{
67053 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
67054 + return -EFAULT;
67055 +
67056 + return 0;
67057 +}
67058 +
67059 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
67060 +{
67061 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
67062 + return -EFAULT;
67063 +
67064 + return 0;
67065 +}
67066 +
67067 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
67068 +{
67069 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
67070 + return -EFAULT;
67071 +
67072 + return 0;
67073 +}
67074 +
67075 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
67076 +{
67077 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
67078 + return -EFAULT;
67079 +
67080 + if (((uwrap->version != GRSECURITY_VERSION) &&
67081 + (uwrap->version != 0x2901)) ||
67082 + (uwrap->size != sizeof(struct gr_arg)))
67083 + return -EINVAL;
67084 +
67085 + return 0;
67086 +}
67087 +
67088 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
67089 +{
67090 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
67091 + return -EFAULT;
67092 +
67093 + return 0;
67094 +}
67095 +
67096 +static size_t get_gr_arg_wrapper_size_normal(void)
67097 +{
67098 + return sizeof(struct gr_arg_wrapper);
67099 +}
67100 +
67101 +#ifdef CONFIG_COMPAT
67102 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
67103 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
67104 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
67105 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
67106 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
67107 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
67108 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
67109 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
67110 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
67111 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
67112 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
67113 +extern size_t get_gr_arg_wrapper_size_compat(void);
67114 +
67115 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
67116 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
67117 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
67118 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
67119 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
67120 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
67121 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
67122 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
67123 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
67124 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
67125 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
67126 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
67127 +
67128 +#else
67129 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
67130 +#define copy_gr_arg copy_gr_arg_normal
67131 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
67132 +#define copy_acl_object_label copy_acl_object_label_normal
67133 +#define copy_acl_subject_label copy_acl_subject_label_normal
67134 +#define copy_acl_role_label copy_acl_role_label_normal
67135 +#define copy_acl_ip_label copy_acl_ip_label_normal
67136 +#define copy_pointer_from_array copy_pointer_from_array_normal
67137 +#define copy_sprole_pw copy_sprole_pw_normal
67138 +#define copy_role_transition copy_role_transition_normal
67139 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
67140 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
67141 +#endif
67142 +
67143 +static struct acl_subject_label *
67144 +lookup_subject_map(const struct acl_subject_label *userp)
67145 +{
67146 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
67147 + struct subject_map *match;
67148 +
67149 + match = polstate->subj_map_set.s_hash[index];
67150 +
67151 + while (match && match->user != userp)
67152 + match = match->next;
67153 +
67154 + if (match != NULL)
67155 + return match->kernel;
67156 + else
67157 + return NULL;
67158 +}
67159 +
67160 +static void
67161 +insert_subj_map_entry(struct subject_map *subjmap)
67162 +{
67163 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
67164 + struct subject_map **curr;
67165 +
67166 + subjmap->prev = NULL;
67167 +
67168 + curr = &polstate->subj_map_set.s_hash[index];
67169 + if (*curr != NULL)
67170 + (*curr)->prev = subjmap;
67171 +
67172 + subjmap->next = *curr;
67173 + *curr = subjmap;
67174 +
67175 + return;
67176 +}
67177 +
67178 +static void
67179 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
67180 +{
67181 + unsigned int index =
67182 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
67183 + struct acl_role_label **curr;
67184 + struct acl_role_label *tmp, *tmp2;
67185 +
67186 + curr = &polstate->acl_role_set.r_hash[index];
67187 +
67188 + /* simple case, slot is empty, just set it to our role */
67189 + if (*curr == NULL) {
67190 + *curr = role;
67191 + } else {
67192 + /* example:
67193 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
67194 + 2 -> 3
67195 + */
67196 + /* first check to see if we can already be reached via this slot */
67197 + tmp = *curr;
67198 + while (tmp && tmp != role)
67199 + tmp = tmp->next;
67200 + if (tmp == role) {
67201 + /* we don't need to add ourselves to this slot's chain */
67202 + return;
67203 + }
67204 + /* we need to add ourselves to this chain, two cases */
67205 + if (role->next == NULL) {
67206 + /* simple case, append the current chain to our role */
67207 + role->next = *curr;
67208 + *curr = role;
67209 + } else {
67210 + /* 1 -> 2 -> 3 -> 4
67211 + 2 -> 3 -> 4
67212 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
67213 + */
67214 + /* trickier case: walk our role's chain until we find
67215 + the role for the start of the current slot's chain */
67216 + tmp = role;
67217 + tmp2 = *curr;
67218 + while (tmp->next && tmp->next != tmp2)
67219 + tmp = tmp->next;
67220 + if (tmp->next == tmp2) {
67221 + /* from example above, we found 3, so just
67222 + replace this slot's chain with ours */
67223 + *curr = role;
67224 + } else {
67225 + /* we didn't find a subset of our role's chain
67226 + in the current slot's chain, so append their
67227 + chain to ours, and set us as the first role in
67228 + the slot's chain
67229 +
67230 + we could fold this case with the case above,
67231 + but making it explicit for clarity
67232 + */
67233 + tmp->next = tmp2;
67234 + *curr = role;
67235 + }
67236 + }
67237 + }
67238 +
67239 + return;
67240 +}
67241 +
67242 +static void
67243 +insert_acl_role_label(struct acl_role_label *role)
67244 +{
67245 + int i;
67246 +
67247 + if (polstate->role_list == NULL) {
67248 + polstate->role_list = role;
67249 + role->prev = NULL;
67250 + } else {
67251 + role->prev = polstate->role_list;
67252 + polstate->role_list = role;
67253 + }
67254 +
67255 + /* used for hash chains */
67256 + role->next = NULL;
67257 +
67258 + if (role->roletype & GR_ROLE_DOMAIN) {
67259 + for (i = 0; i < role->domain_child_num; i++)
67260 + __insert_acl_role_label(role, role->domain_children[i]);
67261 + } else
67262 + __insert_acl_role_label(role, role->uidgid);
67263 +}
67264 +
67265 +static int
67266 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
67267 +{
67268 + struct name_entry **curr, *nentry;
67269 + struct inodev_entry *ientry;
67270 + unsigned int len = strlen(name);
67271 + unsigned int key = full_name_hash(name, len);
67272 + unsigned int index = key % polstate->name_set.n_size;
67273 +
67274 + curr = &polstate->name_set.n_hash[index];
67275 +
67276 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
67277 + curr = &((*curr)->next);
67278 +
67279 + if (*curr != NULL)
67280 + return 1;
67281 +
67282 + nentry = acl_alloc(sizeof (struct name_entry));
67283 + if (nentry == NULL)
67284 + return 0;
67285 + ientry = acl_alloc(sizeof (struct inodev_entry));
67286 + if (ientry == NULL)
67287 + return 0;
67288 + ientry->nentry = nentry;
67289 +
67290 + nentry->key = key;
67291 + nentry->name = name;
67292 + nentry->inode = inode;
67293 + nentry->device = device;
67294 + nentry->len = len;
67295 + nentry->deleted = deleted;
67296 +
67297 + nentry->prev = NULL;
67298 + curr = &polstate->name_set.n_hash[index];
67299 + if (*curr != NULL)
67300 + (*curr)->prev = nentry;
67301 + nentry->next = *curr;
67302 + *curr = nentry;
67303 +
67304 + /* insert us into the table searchable by inode/dev */
67305 + __insert_inodev_entry(polstate, ientry);
67306 +
67307 + return 1;
67308 +}
67309 +
67310 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
67311 +
67312 +static void *
67313 +create_table(__u32 * len, int elementsize)
67314 +{
67315 + unsigned int table_sizes[] = {
67316 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
67317 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
67318 + 4194301, 8388593, 16777213, 33554393, 67108859
67319 + };
67320 + void *newtable = NULL;
67321 + unsigned int pwr = 0;
67322 +
67323 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
67324 + table_sizes[pwr] <= *len)
67325 + pwr++;
67326 +
67327 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
67328 + return newtable;
67329 +
67330 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
67331 + newtable =
67332 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
67333 + else
67334 + newtable = vmalloc(table_sizes[pwr] * elementsize);
67335 +
67336 + *len = table_sizes[pwr];
67337 +
67338 + return newtable;
67339 +}
67340 +
67341 +static int
67342 +init_variables(const struct gr_arg *arg, bool reload)
67343 +{
67344 + struct task_struct *reaper = init_pid_ns.child_reaper;
67345 + unsigned int stacksize;
67346 +
67347 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
67348 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
67349 + polstate->name_set.n_size = arg->role_db.num_objects;
67350 + polstate->inodev_set.i_size = arg->role_db.num_objects;
67351 +
67352 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
67353 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
67354 + return 1;
67355 +
67356 + if (!reload) {
67357 + if (!gr_init_uidset())
67358 + return 1;
67359 + }
67360 +
67361 + /* set up the stack that holds allocation info */
67362 +
67363 + stacksize = arg->role_db.num_pointers + 5;
67364 +
67365 + if (!acl_alloc_stack_init(stacksize))
67366 + return 1;
67367 +
67368 + if (!reload) {
67369 + /* grab reference for the real root dentry and vfsmount */
67370 + get_fs_root(reaper->fs, &gr_real_root);
67371 +
67372 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67373 + 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);
67374 +#endif
67375 +
67376 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
67377 + if (fakefs_obj_rw == NULL)
67378 + return 1;
67379 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
67380 +
67381 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
67382 + if (fakefs_obj_rwx == NULL)
67383 + return 1;
67384 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
67385 + }
67386 +
67387 + polstate->subj_map_set.s_hash =
67388 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
67389 + polstate->acl_role_set.r_hash =
67390 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
67391 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
67392 + polstate->inodev_set.i_hash =
67393 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
67394 +
67395 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
67396 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
67397 + return 1;
67398 +
67399 + memset(polstate->subj_map_set.s_hash, 0,
67400 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
67401 + memset(polstate->acl_role_set.r_hash, 0,
67402 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
67403 + memset(polstate->name_set.n_hash, 0,
67404 + sizeof (struct name_entry *) * polstate->name_set.n_size);
67405 + memset(polstate->inodev_set.i_hash, 0,
67406 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
67407 +
67408 + return 0;
67409 +}
67410 +
67411 +/* free information not needed after startup
67412 + currently contains user->kernel pointer mappings for subjects
67413 +*/
67414 +
67415 +static void
67416 +free_init_variables(void)
67417 +{
67418 + __u32 i;
67419 +
67420 + if (polstate->subj_map_set.s_hash) {
67421 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
67422 + if (polstate->subj_map_set.s_hash[i]) {
67423 + kfree(polstate->subj_map_set.s_hash[i]);
67424 + polstate->subj_map_set.s_hash[i] = NULL;
67425 + }
67426 + }
67427 +
67428 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
67429 + PAGE_SIZE)
67430 + kfree(polstate->subj_map_set.s_hash);
67431 + else
67432 + vfree(polstate->subj_map_set.s_hash);
67433 + }
67434 +
67435 + return;
67436 +}
67437 +
67438 +static void
67439 +free_variables(bool reload)
67440 +{
67441 + struct acl_subject_label *s;
67442 + struct acl_role_label *r;
67443 + struct task_struct *task, *task2;
67444 + unsigned int x;
67445 +
67446 + if (!reload) {
67447 + gr_clear_learn_entries();
67448 +
67449 + read_lock(&tasklist_lock);
67450 + do_each_thread(task2, task) {
67451 + task->acl_sp_role = 0;
67452 + task->acl_role_id = 0;
67453 + task->inherited = 0;
67454 + task->acl = NULL;
67455 + task->role = NULL;
67456 + } while_each_thread(task2, task);
67457 + read_unlock(&tasklist_lock);
67458 +
67459 + /* release the reference to the real root dentry and vfsmount */
67460 + path_put(&gr_real_root);
67461 + memset(&gr_real_root, 0, sizeof(gr_real_root));
67462 + }
67463 +
67464 + /* free all object hash tables */
67465 +
67466 + FOR_EACH_ROLE_START(r)
67467 + if (r->subj_hash == NULL)
67468 + goto next_role;
67469 + FOR_EACH_SUBJECT_START(r, s, x)
67470 + if (s->obj_hash == NULL)
67471 + break;
67472 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67473 + kfree(s->obj_hash);
67474 + else
67475 + vfree(s->obj_hash);
67476 + FOR_EACH_SUBJECT_END(s, x)
67477 + FOR_EACH_NESTED_SUBJECT_START(r, s)
67478 + if (s->obj_hash == NULL)
67479 + break;
67480 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67481 + kfree(s->obj_hash);
67482 + else
67483 + vfree(s->obj_hash);
67484 + FOR_EACH_NESTED_SUBJECT_END(s)
67485 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
67486 + kfree(r->subj_hash);
67487 + else
67488 + vfree(r->subj_hash);
67489 + r->subj_hash = NULL;
67490 +next_role:
67491 + FOR_EACH_ROLE_END(r)
67492 +
67493 + acl_free_all();
67494 +
67495 + if (polstate->acl_role_set.r_hash) {
67496 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
67497 + PAGE_SIZE)
67498 + kfree(polstate->acl_role_set.r_hash);
67499 + else
67500 + vfree(polstate->acl_role_set.r_hash);
67501 + }
67502 + if (polstate->name_set.n_hash) {
67503 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
67504 + PAGE_SIZE)
67505 + kfree(polstate->name_set.n_hash);
67506 + else
67507 + vfree(polstate->name_set.n_hash);
67508 + }
67509 +
67510 + if (polstate->inodev_set.i_hash) {
67511 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
67512 + PAGE_SIZE)
67513 + kfree(polstate->inodev_set.i_hash);
67514 + else
67515 + vfree(polstate->inodev_set.i_hash);
67516 + }
67517 +
67518 + if (!reload)
67519 + gr_free_uidset();
67520 +
67521 + memset(&polstate->name_set, 0, sizeof (struct name_db));
67522 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
67523 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
67524 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
67525 +
67526 + polstate->default_role = NULL;
67527 + polstate->kernel_role = NULL;
67528 + polstate->role_list = NULL;
67529 +
67530 + return;
67531 +}
67532 +
67533 +static struct acl_subject_label *
67534 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
67535 +
67536 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
67537 +{
67538 + unsigned int len = strnlen_user(*name, maxlen);
67539 + char *tmp;
67540 +
67541 + if (!len || len >= maxlen)
67542 + return -EINVAL;
67543 +
67544 + if ((tmp = (char *) acl_alloc(len)) == NULL)
67545 + return -ENOMEM;
67546 +
67547 + if (copy_from_user(tmp, *name, len))
67548 + return -EFAULT;
67549 +
67550 + tmp[len-1] = '\0';
67551 + *name = tmp;
67552 +
67553 + return 0;
67554 +}
67555 +
67556 +static int
67557 +copy_user_glob(struct acl_object_label *obj)
67558 +{
67559 + struct acl_object_label *g_tmp, **guser;
67560 + int error;
67561 +
67562 + if (obj->globbed == NULL)
67563 + return 0;
67564 +
67565 + guser = &obj->globbed;
67566 + while (*guser) {
67567 + g_tmp = (struct acl_object_label *)
67568 + acl_alloc(sizeof (struct acl_object_label));
67569 + if (g_tmp == NULL)
67570 + return -ENOMEM;
67571 +
67572 + if (copy_acl_object_label(g_tmp, *guser))
67573 + return -EFAULT;
67574 +
67575 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
67576 + if (error)
67577 + return error;
67578 +
67579 + *guser = g_tmp;
67580 + guser = &(g_tmp->next);
67581 + }
67582 +
67583 + return 0;
67584 +}
67585 +
67586 +static int
67587 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
67588 + struct acl_role_label *role)
67589 +{
67590 + struct acl_object_label *o_tmp;
67591 + int ret;
67592 +
67593 + while (userp) {
67594 + if ((o_tmp = (struct acl_object_label *)
67595 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
67596 + return -ENOMEM;
67597 +
67598 + if (copy_acl_object_label(o_tmp, userp))
67599 + return -EFAULT;
67600 +
67601 + userp = o_tmp->prev;
67602 +
67603 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
67604 + if (ret)
67605 + return ret;
67606 +
67607 + insert_acl_obj_label(o_tmp, subj);
67608 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
67609 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
67610 + return -ENOMEM;
67611 +
67612 + ret = copy_user_glob(o_tmp);
67613 + if (ret)
67614 + return ret;
67615 +
67616 + if (o_tmp->nested) {
67617 + int already_copied;
67618 +
67619 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
67620 + if (IS_ERR(o_tmp->nested))
67621 + return PTR_ERR(o_tmp->nested);
67622 +
67623 + /* insert into nested subject list if we haven't copied this one yet
67624 + to prevent duplicate entries */
67625 + if (!already_copied) {
67626 + o_tmp->nested->next = role->hash->first;
67627 + role->hash->first = o_tmp->nested;
67628 + }
67629 + }
67630 + }
67631 +
67632 + return 0;
67633 +}
67634 +
67635 +static __u32
67636 +count_user_subjs(struct acl_subject_label *userp)
67637 +{
67638 + struct acl_subject_label s_tmp;
67639 + __u32 num = 0;
67640 +
67641 + while (userp) {
67642 + if (copy_acl_subject_label(&s_tmp, userp))
67643 + break;
67644 +
67645 + userp = s_tmp.prev;
67646 + }
67647 +
67648 + return num;
67649 +}
67650 +
67651 +static int
67652 +copy_user_allowedips(struct acl_role_label *rolep)
67653 +{
67654 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
67655 +
67656 + ruserip = rolep->allowed_ips;
67657 +
67658 + while (ruserip) {
67659 + rlast = rtmp;
67660 +
67661 + if ((rtmp = (struct role_allowed_ip *)
67662 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
67663 + return -ENOMEM;
67664 +
67665 + if (copy_role_allowed_ip(rtmp, ruserip))
67666 + return -EFAULT;
67667 +
67668 + ruserip = rtmp->prev;
67669 +
67670 + if (!rlast) {
67671 + rtmp->prev = NULL;
67672 + rolep->allowed_ips = rtmp;
67673 + } else {
67674 + rlast->next = rtmp;
67675 + rtmp->prev = rlast;
67676 + }
67677 +
67678 + if (!ruserip)
67679 + rtmp->next = NULL;
67680 + }
67681 +
67682 + return 0;
67683 +}
67684 +
67685 +static int
67686 +copy_user_transitions(struct acl_role_label *rolep)
67687 +{
67688 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
67689 + int error;
67690 +
67691 + rusertp = rolep->transitions;
67692 +
67693 + while (rusertp) {
67694 + rlast = rtmp;
67695 +
67696 + if ((rtmp = (struct role_transition *)
67697 + acl_alloc(sizeof (struct role_transition))) == NULL)
67698 + return -ENOMEM;
67699 +
67700 + if (copy_role_transition(rtmp, rusertp))
67701 + return -EFAULT;
67702 +
67703 + rusertp = rtmp->prev;
67704 +
67705 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
67706 + if (error)
67707 + return error;
67708 +
67709 + if (!rlast) {
67710 + rtmp->prev = NULL;
67711 + rolep->transitions = rtmp;
67712 + } else {
67713 + rlast->next = rtmp;
67714 + rtmp->prev = rlast;
67715 + }
67716 +
67717 + if (!rusertp)
67718 + rtmp->next = NULL;
67719 + }
67720 +
67721 + return 0;
67722 +}
67723 +
67724 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
67725 +{
67726 + struct acl_object_label o_tmp;
67727 + __u32 num = 0;
67728 +
67729 + while (userp) {
67730 + if (copy_acl_object_label(&o_tmp, userp))
67731 + break;
67732 +
67733 + userp = o_tmp.prev;
67734 + num++;
67735 + }
67736 +
67737 + return num;
67738 +}
67739 +
67740 +static struct acl_subject_label *
67741 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
67742 +{
67743 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
67744 + __u32 num_objs;
67745 + struct acl_ip_label **i_tmp, *i_utmp2;
67746 + struct gr_hash_struct ghash;
67747 + struct subject_map *subjmap;
67748 + unsigned int i_num;
67749 + int err;
67750 +
67751 + if (already_copied != NULL)
67752 + *already_copied = 0;
67753 +
67754 + s_tmp = lookup_subject_map(userp);
67755 +
67756 + /* we've already copied this subject into the kernel, just return
67757 + the reference to it, and don't copy it over again
67758 + */
67759 + if (s_tmp) {
67760 + if (already_copied != NULL)
67761 + *already_copied = 1;
67762 + return(s_tmp);
67763 + }
67764 +
67765 + if ((s_tmp = (struct acl_subject_label *)
67766 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
67767 + return ERR_PTR(-ENOMEM);
67768 +
67769 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
67770 + if (subjmap == NULL)
67771 + return ERR_PTR(-ENOMEM);
67772 +
67773 + subjmap->user = userp;
67774 + subjmap->kernel = s_tmp;
67775 + insert_subj_map_entry(subjmap);
67776 +
67777 + if (copy_acl_subject_label(s_tmp, userp))
67778 + return ERR_PTR(-EFAULT);
67779 +
67780 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
67781 + if (err)
67782 + return ERR_PTR(err);
67783 +
67784 + if (!strcmp(s_tmp->filename, "/"))
67785 + role->root_label = s_tmp;
67786 +
67787 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
67788 + return ERR_PTR(-EFAULT);
67789 +
67790 + /* copy user and group transition tables */
67791 +
67792 + if (s_tmp->user_trans_num) {
67793 + uid_t *uidlist;
67794 +
67795 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
67796 + if (uidlist == NULL)
67797 + return ERR_PTR(-ENOMEM);
67798 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
67799 + return ERR_PTR(-EFAULT);
67800 +
67801 + s_tmp->user_transitions = uidlist;
67802 + }
67803 +
67804 + if (s_tmp->group_trans_num) {
67805 + gid_t *gidlist;
67806 +
67807 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
67808 + if (gidlist == NULL)
67809 + return ERR_PTR(-ENOMEM);
67810 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
67811 + return ERR_PTR(-EFAULT);
67812 +
67813 + s_tmp->group_transitions = gidlist;
67814 + }
67815 +
67816 + /* set up object hash table */
67817 + num_objs = count_user_objs(ghash.first);
67818 +
67819 + s_tmp->obj_hash_size = num_objs;
67820 + s_tmp->obj_hash =
67821 + (struct acl_object_label **)
67822 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
67823 +
67824 + if (!s_tmp->obj_hash)
67825 + return ERR_PTR(-ENOMEM);
67826 +
67827 + memset(s_tmp->obj_hash, 0,
67828 + s_tmp->obj_hash_size *
67829 + sizeof (struct acl_object_label *));
67830 +
67831 + /* add in objects */
67832 + err = copy_user_objs(ghash.first, s_tmp, role);
67833 +
67834 + if (err)
67835 + return ERR_PTR(err);
67836 +
67837 + /* set pointer for parent subject */
67838 + if (s_tmp->parent_subject) {
67839 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
67840 +
67841 + if (IS_ERR(s_tmp2))
67842 + return s_tmp2;
67843 +
67844 + s_tmp->parent_subject = s_tmp2;
67845 + }
67846 +
67847 + /* add in ip acls */
67848 +
67849 + if (!s_tmp->ip_num) {
67850 + s_tmp->ips = NULL;
67851 + goto insert;
67852 + }
67853 +
67854 + i_tmp =
67855 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
67856 + sizeof (struct acl_ip_label *));
67857 +
67858 + if (!i_tmp)
67859 + return ERR_PTR(-ENOMEM);
67860 +
67861 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
67862 + *(i_tmp + i_num) =
67863 + (struct acl_ip_label *)
67864 + acl_alloc(sizeof (struct acl_ip_label));
67865 + if (!*(i_tmp + i_num))
67866 + return ERR_PTR(-ENOMEM);
67867 +
67868 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
67869 + return ERR_PTR(-EFAULT);
67870 +
67871 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
67872 + return ERR_PTR(-EFAULT);
67873 +
67874 + if ((*(i_tmp + i_num))->iface == NULL)
67875 + continue;
67876 +
67877 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
67878 + if (err)
67879 + return ERR_PTR(err);
67880 + }
67881 +
67882 + s_tmp->ips = i_tmp;
67883 +
67884 +insert:
67885 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
67886 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
67887 + return ERR_PTR(-ENOMEM);
67888 +
67889 + return s_tmp;
67890 +}
67891 +
67892 +static int
67893 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
67894 +{
67895 + struct acl_subject_label s_pre;
67896 + struct acl_subject_label * ret;
67897 + int err;
67898 +
67899 + while (userp) {
67900 + if (copy_acl_subject_label(&s_pre, userp))
67901 + return -EFAULT;
67902 +
67903 + ret = do_copy_user_subj(userp, role, NULL);
67904 +
67905 + err = PTR_ERR(ret);
67906 + if (IS_ERR(ret))
67907 + return err;
67908 +
67909 + insert_acl_subj_label(ret, role);
67910 +
67911 + userp = s_pre.prev;
67912 + }
67913 +
67914 + return 0;
67915 +}
67916 +
67917 +static int
67918 +copy_user_acl(struct gr_arg *arg)
67919 +{
67920 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
67921 + struct acl_subject_label *subj_list;
67922 + struct sprole_pw *sptmp;
67923 + struct gr_hash_struct *ghash;
67924 + uid_t *domainlist;
67925 + unsigned int r_num;
67926 + int err = 0;
67927 + __u16 i;
67928 + __u32 num_subjs;
67929 +
67930 + /* we need a default and kernel role */
67931 + if (arg->role_db.num_roles < 2)
67932 + return -EINVAL;
67933 +
67934 + /* copy special role authentication info from userspace */
67935 +
67936 + polstate->num_sprole_pws = arg->num_sprole_pws;
67937 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
67938 +
67939 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
67940 + return -ENOMEM;
67941 +
67942 + for (i = 0; i < polstate->num_sprole_pws; i++) {
67943 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
67944 + if (!sptmp)
67945 + return -ENOMEM;
67946 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
67947 + return -EFAULT;
67948 +
67949 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
67950 + if (err)
67951 + return err;
67952 +
67953 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67954 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
67955 +#endif
67956 +
67957 + polstate->acl_special_roles[i] = sptmp;
67958 + }
67959 +
67960 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
67961 +
67962 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
67963 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
67964 +
67965 + if (!r_tmp)
67966 + return -ENOMEM;
67967 +
67968 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
67969 + return -EFAULT;
67970 +
67971 + if (copy_acl_role_label(r_tmp, r_utmp2))
67972 + return -EFAULT;
67973 +
67974 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
67975 + if (err)
67976 + return err;
67977 +
67978 + if (!strcmp(r_tmp->rolename, "default")
67979 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
67980 + polstate->default_role = r_tmp;
67981 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
67982 + polstate->kernel_role = r_tmp;
67983 + }
67984 +
67985 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
67986 + return -ENOMEM;
67987 +
67988 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
67989 + return -EFAULT;
67990 +
67991 + r_tmp->hash = ghash;
67992 +
67993 + num_subjs = count_user_subjs(r_tmp->hash->first);
67994 +
67995 + r_tmp->subj_hash_size = num_subjs;
67996 + r_tmp->subj_hash =
67997 + (struct acl_subject_label **)
67998 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
67999 +
68000 + if (!r_tmp->subj_hash)
68001 + return -ENOMEM;
68002 +
68003 + err = copy_user_allowedips(r_tmp);
68004 + if (err)
68005 + return err;
68006 +
68007 + /* copy domain info */
68008 + if (r_tmp->domain_children != NULL) {
68009 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
68010 + if (domainlist == NULL)
68011 + return -ENOMEM;
68012 +
68013 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
68014 + return -EFAULT;
68015 +
68016 + r_tmp->domain_children = domainlist;
68017 + }
68018 +
68019 + err = copy_user_transitions(r_tmp);
68020 + if (err)
68021 + return err;
68022 +
68023 + memset(r_tmp->subj_hash, 0,
68024 + r_tmp->subj_hash_size *
68025 + sizeof (struct acl_subject_label *));
68026 +
68027 + /* acquire the list of subjects, then NULL out
68028 + the list prior to parsing the subjects for this role,
68029 + as during this parsing the list is replaced with a list
68030 + of *nested* subjects for the role
68031 + */
68032 + subj_list = r_tmp->hash->first;
68033 +
68034 + /* set nested subject list to null */
68035 + r_tmp->hash->first = NULL;
68036 +
68037 + err = copy_user_subjs(subj_list, r_tmp);
68038 +
68039 + if (err)
68040 + return err;
68041 +
68042 + insert_acl_role_label(r_tmp);
68043 + }
68044 +
68045 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
68046 + return -EINVAL;
68047 +
68048 + return err;
68049 +}
68050 +
68051 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
68052 +{
68053 + char *tmpname;
68054 + struct acl_subject_label *tmpsubj;
68055 + struct file *filp;
68056 + struct name_entry *nmatch;
68057 +
68058 + filp = task->exec_file;
68059 + if (filp == NULL)
68060 + return NULL;
68061 +
68062 + /* the following is to apply the correct subject
68063 + on binaries running when the RBAC system
68064 + is enabled, when the binaries have been
68065 + replaced or deleted since their execution
68066 + -----
68067 + when the RBAC system starts, the inode/dev
68068 + from exec_file will be one the RBAC system
68069 + is unaware of. It only knows the inode/dev
68070 + of the present file on disk, or the absence
68071 + of it.
68072 + */
68073 +
68074 + if (filename)
68075 + nmatch = __lookup_name_entry(polstate, filename);
68076 + else {
68077 + preempt_disable();
68078 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
68079 +
68080 + nmatch = __lookup_name_entry(polstate, tmpname);
68081 + preempt_enable();
68082 + }
68083 + tmpsubj = NULL;
68084 + if (nmatch) {
68085 + if (nmatch->deleted)
68086 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
68087 + else
68088 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
68089 + }
68090 + /* this also works for the reload case -- if we don't match a potentially inherited subject
68091 + then we fall back to a normal lookup based on the binary's ino/dev
68092 + */
68093 + if (tmpsubj == NULL)
68094 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
68095 + task->role);
68096 +
68097 + return tmpsubj;
68098 +}
68099 +
68100 +static int gracl_reload_apply_policies(void *reload)
68101 +{
68102 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
68103 + struct task_struct *task, *task2;
68104 + struct acl_role_label *role, *rtmp;
68105 + struct acl_subject_label *subj;
68106 + const struct cred *cred;
68107 + int role_applied;
68108 + int ret = 0;
68109 +
68110 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_reload_state));
68111 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
68112 +
68113 + /* first make sure we'll be able to apply the new policy cleanly */
68114 + do_each_thread(task2, task) {
68115 + if (task->exec_file == NULL)
68116 + continue;
68117 + role_applied = 0;
68118 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68119 + /* preserve special roles */
68120 + FOR_EACH_ROLE_START(role)
68121 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68122 + rtmp = task->role;
68123 + task->role = role;
68124 + role_applied = 1;
68125 + break;
68126 + }
68127 + FOR_EACH_ROLE_END(role)
68128 + }
68129 + if (!role_applied) {
68130 + cred = __task_cred(task);
68131 + rtmp = task->role;
68132 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68133 + }
68134 + /* this handles non-nested inherited subjects, nested subjects will still
68135 + be dropped currently */
68136 + subj = gr_get_subject_for_task(task, task->acl->filename);
68137 + task->tmpacl = gr_get_subject_for_task(task, NULL);
68138 + /* change the role back so that we've made no modifications to the policy */
68139 + task->role = rtmp;
68140 +
68141 + if (subj == NULL || task->tmpacl == NULL) {
68142 + ret = -EINVAL;
68143 + goto out;
68144 + }
68145 + } while_each_thread(task2, task);
68146 +
68147 + /* now actually apply the policy */
68148 +
68149 + do_each_thread(task2, task) {
68150 + if (task->exec_file) {
68151 + role_applied = 0;
68152 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68153 + /* preserve special roles */
68154 + FOR_EACH_ROLE_START(role)
68155 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68156 + task->role = role;
68157 + role_applied = 1;
68158 + break;
68159 + }
68160 + FOR_EACH_ROLE_END(role)
68161 + }
68162 + if (!role_applied) {
68163 + cred = __task_cred(task);
68164 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68165 + }
68166 + /* this handles non-nested inherited subjects, nested subjects will still
68167 + be dropped currently */
68168 + if (!reload_state->oldmode && task->inherited)
68169 + subj = gr_get_subject_for_task(task, task->acl->filename);
68170 + else {
68171 + /* looked up and tagged to the task previously */
68172 + subj = task->tmpacl;
68173 + }
68174 + /* subj will be non-null */
68175 + __gr_apply_subject_to_task(polstate, task, subj);
68176 + if (reload_state->oldmode) {
68177 + task->acl_role_id = 0;
68178 + task->acl_sp_role = 0;
68179 + task->inherited = 0;
68180 + }
68181 + } else {
68182 + // it's a kernel process
68183 + task->role = polstate->kernel_role;
68184 + task->acl = polstate->kernel_role->root_label;
68185 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68186 + task->acl->mode &= ~GR_PROCFIND;
68187 +#endif
68188 + }
68189 + } while_each_thread(task2, task);
68190 +
68191 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
68192 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
68193 +
68194 +out:
68195 +
68196 + return ret;
68197 +}
68198 +
68199 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
68200 +{
68201 + struct gr_reload_state new_reload_state = { };
68202 + int err;
68203 +
68204 + new_reload_state.oldpolicy_ptr = polstate;
68205 + new_reload_state.oldalloc_ptr = current_alloc_state;
68206 + new_reload_state.oldmode = oldmode;
68207 +
68208 + current_alloc_state = &new_reload_state.newalloc;
68209 + polstate = &new_reload_state.newpolicy;
68210 +
68211 + /* everything relevant is now saved off, copy in the new policy */
68212 + if (init_variables(args, true)) {
68213 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68214 + err = -ENOMEM;
68215 + goto error;
68216 + }
68217 +
68218 + err = copy_user_acl(args);
68219 + free_init_variables();
68220 + if (err)
68221 + goto error;
68222 + /* the new policy is copied in, with the old policy available via saved_state
68223 + first go through applying roles, making sure to preserve special roles
68224 + then apply new subjects, making sure to preserve inherited and nested subjects,
68225 + though currently only inherited subjects will be preserved
68226 + */
68227 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
68228 + if (err)
68229 + goto error;
68230 +
68231 + /* we've now applied the new policy, so restore the old policy state to free it */
68232 + polstate = &new_reload_state.oldpolicy;
68233 + current_alloc_state = &new_reload_state.oldalloc;
68234 + free_variables(true);
68235 +
68236 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
68237 + to running_polstate/current_alloc_state inside stop_machine
68238 + */
68239 + err = 0;
68240 + goto out;
68241 +error:
68242 + /* on error of loading the new policy, we'll just keep the previous
68243 + policy set around
68244 + */
68245 + free_variables(true);
68246 +
68247 + /* doesn't affect runtime, but maintains consistent state */
68248 +out:
68249 + polstate = new_reload_state.oldpolicy_ptr;
68250 + current_alloc_state = new_reload_state.oldalloc_ptr;
68251 +
68252 + return err;
68253 +}
68254 +
68255 +static int
68256 +gracl_init(struct gr_arg *args)
68257 +{
68258 + int error = 0;
68259 +
68260 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
68261 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
68262 +
68263 + if (init_variables(args, false)) {
68264 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68265 + error = -ENOMEM;
68266 + goto out;
68267 + }
68268 +
68269 + error = copy_user_acl(args);
68270 + free_init_variables();
68271 + if (error)
68272 + goto out;
68273 +
68274 + error = gr_set_acls(0);
68275 + if (error)
68276 + goto out;
68277 +
68278 + gr_enable_rbac_system();
68279 +
68280 + return 0;
68281 +
68282 +out:
68283 + free_variables(false);
68284 + return error;
68285 +}
68286 +
68287 +static int
68288 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
68289 + unsigned char **sum)
68290 +{
68291 + struct acl_role_label *r;
68292 + struct role_allowed_ip *ipp;
68293 + struct role_transition *trans;
68294 + unsigned int i;
68295 + int found = 0;
68296 + u32 curr_ip = current->signal->curr_ip;
68297 +
68298 + current->signal->saved_ip = curr_ip;
68299 +
68300 + /* check transition table */
68301 +
68302 + for (trans = current->role->transitions; trans; trans = trans->next) {
68303 + if (!strcmp(rolename, trans->rolename)) {
68304 + found = 1;
68305 + break;
68306 + }
68307 + }
68308 +
68309 + if (!found)
68310 + return 0;
68311 +
68312 + /* handle special roles that do not require authentication
68313 + and check ip */
68314 +
68315 + FOR_EACH_ROLE_START(r)
68316 + if (!strcmp(rolename, r->rolename) &&
68317 + (r->roletype & GR_ROLE_SPECIAL)) {
68318 + found = 0;
68319 + if (r->allowed_ips != NULL) {
68320 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
68321 + if ((ntohl(curr_ip) & ipp->netmask) ==
68322 + (ntohl(ipp->addr) & ipp->netmask))
68323 + found = 1;
68324 + }
68325 + } else
68326 + found = 2;
68327 + if (!found)
68328 + return 0;
68329 +
68330 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
68331 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
68332 + *salt = NULL;
68333 + *sum = NULL;
68334 + return 1;
68335 + }
68336 + }
68337 + FOR_EACH_ROLE_END(r)
68338 +
68339 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68340 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
68341 + *salt = polstate->acl_special_roles[i]->salt;
68342 + *sum = polstate->acl_special_roles[i]->sum;
68343 + return 1;
68344 + }
68345 + }
68346 +
68347 + return 0;
68348 +}
68349 +
68350 +int gr_check_secure_terminal(struct task_struct *task)
68351 +{
68352 + struct task_struct *p, *p2, *p3;
68353 + struct files_struct *files;
68354 + struct fdtable *fdt;
68355 + struct file *our_file = NULL, *file;
68356 + int i;
68357 +
68358 + if (task->signal->tty == NULL)
68359 + return 1;
68360 +
68361 + files = get_files_struct(task);
68362 + if (files != NULL) {
68363 + rcu_read_lock();
68364 + fdt = files_fdtable(files);
68365 + for (i=0; i < fdt->max_fds; i++) {
68366 + file = fcheck_files(files, i);
68367 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
68368 + get_file(file);
68369 + our_file = file;
68370 + }
68371 + }
68372 + rcu_read_unlock();
68373 + put_files_struct(files);
68374 + }
68375 +
68376 + if (our_file == NULL)
68377 + return 1;
68378 +
68379 + read_lock(&tasklist_lock);
68380 + do_each_thread(p2, p) {
68381 + files = get_files_struct(p);
68382 + if (files == NULL ||
68383 + (p->signal && p->signal->tty == task->signal->tty)) {
68384 + if (files != NULL)
68385 + put_files_struct(files);
68386 + continue;
68387 + }
68388 + rcu_read_lock();
68389 + fdt = files_fdtable(files);
68390 + for (i=0; i < fdt->max_fds; i++) {
68391 + file = fcheck_files(files, i);
68392 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
68393 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
68394 + p3 = task;
68395 + while (task_pid_nr(p3) > 0) {
68396 + if (p3 == p)
68397 + break;
68398 + p3 = p3->real_parent;
68399 + }
68400 + if (p3 == p)
68401 + break;
68402 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
68403 + gr_handle_alertkill(p);
68404 + rcu_read_unlock();
68405 + put_files_struct(files);
68406 + read_unlock(&tasklist_lock);
68407 + fput(our_file);
68408 + return 0;
68409 + }
68410 + }
68411 + rcu_read_unlock();
68412 + put_files_struct(files);
68413 + } while_each_thread(p2, p);
68414 + read_unlock(&tasklist_lock);
68415 +
68416 + fput(our_file);
68417 + return 1;
68418 +}
68419 +
68420 +ssize_t
68421 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
68422 +{
68423 + struct gr_arg_wrapper uwrap;
68424 + unsigned char *sprole_salt = NULL;
68425 + unsigned char *sprole_sum = NULL;
68426 + int error = 0;
68427 + int error2 = 0;
68428 + size_t req_count = 0;
68429 + unsigned char oldmode = 0;
68430 +
68431 + mutex_lock(&gr_dev_mutex);
68432 +
68433 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
68434 + error = -EPERM;
68435 + goto out;
68436 + }
68437 +
68438 +#ifdef CONFIG_COMPAT
68439 + pax_open_kernel();
68440 + if (is_compat_task()) {
68441 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
68442 + copy_gr_arg = &copy_gr_arg_compat;
68443 + copy_acl_object_label = &copy_acl_object_label_compat;
68444 + copy_acl_subject_label = &copy_acl_subject_label_compat;
68445 + copy_acl_role_label = &copy_acl_role_label_compat;
68446 + copy_acl_ip_label = &copy_acl_ip_label_compat;
68447 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
68448 + copy_role_transition = &copy_role_transition_compat;
68449 + copy_sprole_pw = &copy_sprole_pw_compat;
68450 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
68451 + copy_pointer_from_array = &copy_pointer_from_array_compat;
68452 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
68453 + } else {
68454 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
68455 + copy_gr_arg = &copy_gr_arg_normal;
68456 + copy_acl_object_label = &copy_acl_object_label_normal;
68457 + copy_acl_subject_label = &copy_acl_subject_label_normal;
68458 + copy_acl_role_label = &copy_acl_role_label_normal;
68459 + copy_acl_ip_label = &copy_acl_ip_label_normal;
68460 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
68461 + copy_role_transition = &copy_role_transition_normal;
68462 + copy_sprole_pw = &copy_sprole_pw_normal;
68463 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
68464 + copy_pointer_from_array = &copy_pointer_from_array_normal;
68465 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
68466 + }
68467 + pax_close_kernel();
68468 +#endif
68469 +
68470 + req_count = get_gr_arg_wrapper_size();
68471 +
68472 + if (count != req_count) {
68473 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
68474 + error = -EINVAL;
68475 + goto out;
68476 + }
68477 +
68478 +
68479 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
68480 + gr_auth_expires = 0;
68481 + gr_auth_attempts = 0;
68482 + }
68483 +
68484 + error = copy_gr_arg_wrapper(buf, &uwrap);
68485 + if (error)
68486 + goto out;
68487 +
68488 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
68489 + if (error)
68490 + goto out;
68491 +
68492 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68493 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68494 + time_after(gr_auth_expires, get_seconds())) {
68495 + error = -EBUSY;
68496 + goto out;
68497 + }
68498 +
68499 + /* if non-root trying to do anything other than use a special role,
68500 + do not attempt authentication, do not count towards authentication
68501 + locking
68502 + */
68503 +
68504 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
68505 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68506 + gr_is_global_nonroot(current_uid())) {
68507 + error = -EPERM;
68508 + goto out;
68509 + }
68510 +
68511 + /* ensure pw and special role name are null terminated */
68512 +
68513 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
68514 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
68515 +
68516 + /* Okay.
68517 + * We have our enough of the argument structure..(we have yet
68518 + * to copy_from_user the tables themselves) . Copy the tables
68519 + * only if we need them, i.e. for loading operations. */
68520 +
68521 + switch (gr_usermode.mode) {
68522 + case GR_STATUS:
68523 + if (gr_acl_is_enabled()) {
68524 + error = 1;
68525 + if (!gr_check_secure_terminal(current))
68526 + error = 3;
68527 + } else
68528 + error = 2;
68529 + goto out;
68530 + case GR_SHUTDOWN:
68531 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68532 + stop_machine(gr_rbac_disable, NULL, NULL);
68533 + free_variables(false);
68534 + memset(&gr_usermode, 0, sizeof(gr_usermode));
68535 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
68536 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
68537 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
68538 + } else if (gr_acl_is_enabled()) {
68539 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
68540 + error = -EPERM;
68541 + } else {
68542 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
68543 + error = -EAGAIN;
68544 + }
68545 + break;
68546 + case GR_ENABLE:
68547 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
68548 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
68549 + else {
68550 + if (gr_acl_is_enabled())
68551 + error = -EAGAIN;
68552 + else
68553 + error = error2;
68554 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
68555 + }
68556 + break;
68557 + case GR_OLDRELOAD:
68558 + oldmode = 1;
68559 + case GR_RELOAD:
68560 + if (!gr_acl_is_enabled()) {
68561 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
68562 + error = -EAGAIN;
68563 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68564 + error2 = gracl_reload(&gr_usermode, oldmode);
68565 + if (!error2)
68566 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
68567 + else {
68568 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68569 + error = error2;
68570 + }
68571 + } else {
68572 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68573 + error = -EPERM;
68574 + }
68575 + break;
68576 + case GR_SEGVMOD:
68577 + if (unlikely(!gr_acl_is_enabled())) {
68578 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
68579 + error = -EAGAIN;
68580 + break;
68581 + }
68582 +
68583 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68584 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
68585 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
68586 + struct acl_subject_label *segvacl;
68587 + segvacl =
68588 + lookup_acl_subj_label(gr_usermode.segv_inode,
68589 + gr_usermode.segv_device,
68590 + current->role);
68591 + if (segvacl) {
68592 + segvacl->crashes = 0;
68593 + segvacl->expires = 0;
68594 + }
68595 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
68596 + gr_remove_uid(gr_usermode.segv_uid);
68597 + }
68598 + } else {
68599 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
68600 + error = -EPERM;
68601 + }
68602 + break;
68603 + case GR_SPROLE:
68604 + case GR_SPROLEPAM:
68605 + if (unlikely(!gr_acl_is_enabled())) {
68606 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
68607 + error = -EAGAIN;
68608 + break;
68609 + }
68610 +
68611 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
68612 + current->role->expires = 0;
68613 + current->role->auth_attempts = 0;
68614 + }
68615 +
68616 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68617 + time_after(current->role->expires, get_seconds())) {
68618 + error = -EBUSY;
68619 + goto out;
68620 + }
68621 +
68622 + if (lookup_special_role_auth
68623 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
68624 + && ((!sprole_salt && !sprole_sum)
68625 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
68626 + char *p = "";
68627 + assign_special_role(gr_usermode.sp_role);
68628 + read_lock(&tasklist_lock);
68629 + if (current->real_parent)
68630 + p = current->real_parent->role->rolename;
68631 + read_unlock(&tasklist_lock);
68632 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
68633 + p, acl_sp_role_value);
68634 + } else {
68635 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
68636 + error = -EPERM;
68637 + if(!(current->role->auth_attempts++))
68638 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68639 +
68640 + goto out;
68641 + }
68642 + break;
68643 + case GR_UNSPROLE:
68644 + if (unlikely(!gr_acl_is_enabled())) {
68645 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
68646 + error = -EAGAIN;
68647 + break;
68648 + }
68649 +
68650 + if (current->role->roletype & GR_ROLE_SPECIAL) {
68651 + char *p = "";
68652 + int i = 0;
68653 +
68654 + read_lock(&tasklist_lock);
68655 + if (current->real_parent) {
68656 + p = current->real_parent->role->rolename;
68657 + i = current->real_parent->acl_role_id;
68658 + }
68659 + read_unlock(&tasklist_lock);
68660 +
68661 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
68662 + gr_set_acls(1);
68663 + } else {
68664 + error = -EPERM;
68665 + goto out;
68666 + }
68667 + break;
68668 + default:
68669 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
68670 + error = -EINVAL;
68671 + break;
68672 + }
68673 +
68674 + if (error != -EPERM)
68675 + goto out;
68676 +
68677 + if(!(gr_auth_attempts++))
68678 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68679 +
68680 + out:
68681 + mutex_unlock(&gr_dev_mutex);
68682 +
68683 + if (!error)
68684 + error = req_count;
68685 +
68686 + return error;
68687 +}
68688 +
68689 +int
68690 +gr_set_acls(const int type)
68691 +{
68692 + struct task_struct *task, *task2;
68693 + struct acl_role_label *role = current->role;
68694 + struct acl_subject_label *subj;
68695 + __u16 acl_role_id = current->acl_role_id;
68696 + const struct cred *cred;
68697 + int ret;
68698 +
68699 + rcu_read_lock();
68700 + read_lock(&tasklist_lock);
68701 + read_lock(&grsec_exec_file_lock);
68702 + do_each_thread(task2, task) {
68703 + /* check to see if we're called from the exit handler,
68704 + if so, only replace ACLs that have inherited the admin
68705 + ACL */
68706 +
68707 + if (type && (task->role != role ||
68708 + task->acl_role_id != acl_role_id))
68709 + continue;
68710 +
68711 + task->acl_role_id = 0;
68712 + task->acl_sp_role = 0;
68713 + task->inherited = 0;
68714 +
68715 + if (task->exec_file) {
68716 + cred = __task_cred(task);
68717 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68718 + subj = gr_get_subject_for_task(task, NULL);
68719 + if (subj == NULL) {
68720 + ret = -EINVAL;
68721 + read_unlock(&grsec_exec_file_lock);
68722 + read_unlock(&tasklist_lock);
68723 + rcu_read_unlock();
68724 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
68725 + return ret;
68726 + }
68727 + __gr_apply_subject_to_task(polstate, task, subj);
68728 + } else {
68729 + // it's a kernel process
68730 + task->role = polstate->kernel_role;
68731 + task->acl = polstate->kernel_role->root_label;
68732 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68733 + task->acl->mode &= ~GR_PROCFIND;
68734 +#endif
68735 + }
68736 + } while_each_thread(task2, task);
68737 + read_unlock(&grsec_exec_file_lock);
68738 + read_unlock(&tasklist_lock);
68739 + rcu_read_unlock();
68740 +
68741 + return 0;
68742 +}
68743 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
68744 new file mode 100644
68745 index 0000000..39645c9
68746 --- /dev/null
68747 +++ b/grsecurity/gracl_res.c
68748 @@ -0,0 +1,68 @@
68749 +#include <linux/kernel.h>
68750 +#include <linux/sched.h>
68751 +#include <linux/gracl.h>
68752 +#include <linux/grinternal.h>
68753 +
68754 +static const char *restab_log[] = {
68755 + [RLIMIT_CPU] = "RLIMIT_CPU",
68756 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
68757 + [RLIMIT_DATA] = "RLIMIT_DATA",
68758 + [RLIMIT_STACK] = "RLIMIT_STACK",
68759 + [RLIMIT_CORE] = "RLIMIT_CORE",
68760 + [RLIMIT_RSS] = "RLIMIT_RSS",
68761 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
68762 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
68763 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
68764 + [RLIMIT_AS] = "RLIMIT_AS",
68765 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
68766 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
68767 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
68768 + [RLIMIT_NICE] = "RLIMIT_NICE",
68769 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
68770 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
68771 + [GR_CRASH_RES] = "RLIMIT_CRASH"
68772 +};
68773 +
68774 +void
68775 +gr_log_resource(const struct task_struct *task,
68776 + const int res, const unsigned long wanted, const int gt)
68777 +{
68778 + const struct cred *cred;
68779 + unsigned long rlim;
68780 +
68781 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
68782 + return;
68783 +
68784 + // not yet supported resource
68785 + if (unlikely(!restab_log[res]))
68786 + return;
68787 +
68788 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
68789 + rlim = task_rlimit_max(task, res);
68790 + else
68791 + rlim = task_rlimit(task, res);
68792 +
68793 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68794 + return;
68795 +
68796 + rcu_read_lock();
68797 + cred = __task_cred(task);
68798 +
68799 + if (res == RLIMIT_NPROC &&
68800 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68801 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68802 + goto out_rcu_unlock;
68803 + else if (res == RLIMIT_MEMLOCK &&
68804 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68805 + goto out_rcu_unlock;
68806 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68807 + goto out_rcu_unlock;
68808 + rcu_read_unlock();
68809 +
68810 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68811 +
68812 + return;
68813 +out_rcu_unlock:
68814 + rcu_read_unlock();
68815 + return;
68816 +}
68817 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68818 new file mode 100644
68819 index 0000000..2040e61
68820 --- /dev/null
68821 +++ b/grsecurity/gracl_segv.c
68822 @@ -0,0 +1,313 @@
68823 +#include <linux/kernel.h>
68824 +#include <linux/mm.h>
68825 +#include <asm/uaccess.h>
68826 +#include <asm/errno.h>
68827 +#include <asm/mman.h>
68828 +#include <net/sock.h>
68829 +#include <linux/file.h>
68830 +#include <linux/fs.h>
68831 +#include <linux/net.h>
68832 +#include <linux/in.h>
68833 +#include <linux/slab.h>
68834 +#include <linux/types.h>
68835 +#include <linux/sched.h>
68836 +#include <linux/timer.h>
68837 +#include <linux/gracl.h>
68838 +#include <linux/grsecurity.h>
68839 +#include <linux/grinternal.h>
68840 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68841 +#include <linux/magic.h>
68842 +#include <linux/pagemap.h>
68843 +#include "../fs/btrfs/async-thread.h"
68844 +#include "../fs/btrfs/ctree.h"
68845 +#include "../fs/btrfs/btrfs_inode.h"
68846 +#endif
68847 +
68848 +static struct crash_uid *uid_set;
68849 +static unsigned short uid_used;
68850 +static DEFINE_SPINLOCK(gr_uid_lock);
68851 +extern rwlock_t gr_inode_lock;
68852 +extern struct acl_subject_label *
68853 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68854 + struct acl_role_label *role);
68855 +
68856 +static inline dev_t __get_dev(const struct dentry *dentry)
68857 +{
68858 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68859 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68860 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68861 + else
68862 +#endif
68863 + return dentry->d_sb->s_dev;
68864 +}
68865 +
68866 +int
68867 +gr_init_uidset(void)
68868 +{
68869 + uid_set =
68870 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68871 + uid_used = 0;
68872 +
68873 + return uid_set ? 1 : 0;
68874 +}
68875 +
68876 +void
68877 +gr_free_uidset(void)
68878 +{
68879 + if (uid_set) {
68880 + struct crash_uid *tmpset;
68881 + spin_lock(&gr_uid_lock);
68882 + tmpset = uid_set;
68883 + uid_set = NULL;
68884 + uid_used = 0;
68885 + spin_unlock(&gr_uid_lock);
68886 + if (tmpset)
68887 + kfree(tmpset);
68888 + }
68889 +
68890 + return;
68891 +}
68892 +
68893 +int
68894 +gr_find_uid(const uid_t uid)
68895 +{
68896 + struct crash_uid *tmp = uid_set;
68897 + uid_t buid;
68898 + int low = 0, high = uid_used - 1, mid;
68899 +
68900 + while (high >= low) {
68901 + mid = (low + high) >> 1;
68902 + buid = tmp[mid].uid;
68903 + if (buid == uid)
68904 + return mid;
68905 + if (buid > uid)
68906 + high = mid - 1;
68907 + if (buid < uid)
68908 + low = mid + 1;
68909 + }
68910 +
68911 + return -1;
68912 +}
68913 +
68914 +static __inline__ void
68915 +gr_insertsort(void)
68916 +{
68917 + unsigned short i, j;
68918 + struct crash_uid index;
68919 +
68920 + for (i = 1; i < uid_used; i++) {
68921 + index = uid_set[i];
68922 + j = i;
68923 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68924 + uid_set[j] = uid_set[j - 1];
68925 + j--;
68926 + }
68927 + uid_set[j] = index;
68928 + }
68929 +
68930 + return;
68931 +}
68932 +
68933 +static __inline__ void
68934 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68935 +{
68936 + int loc;
68937 + uid_t uid = GR_GLOBAL_UID(kuid);
68938 +
68939 + if (uid_used == GR_UIDTABLE_MAX)
68940 + return;
68941 +
68942 + loc = gr_find_uid(uid);
68943 +
68944 + if (loc >= 0) {
68945 + uid_set[loc].expires = expires;
68946 + return;
68947 + }
68948 +
68949 + uid_set[uid_used].uid = uid;
68950 + uid_set[uid_used].expires = expires;
68951 + uid_used++;
68952 +
68953 + gr_insertsort();
68954 +
68955 + return;
68956 +}
68957 +
68958 +void
68959 +gr_remove_uid(const unsigned short loc)
68960 +{
68961 + unsigned short i;
68962 +
68963 + for (i = loc + 1; i < uid_used; i++)
68964 + uid_set[i - 1] = uid_set[i];
68965 +
68966 + uid_used--;
68967 +
68968 + return;
68969 +}
68970 +
68971 +int
68972 +gr_check_crash_uid(const kuid_t kuid)
68973 +{
68974 + int loc;
68975 + int ret = 0;
68976 + uid_t uid;
68977 +
68978 + if (unlikely(!gr_acl_is_enabled()))
68979 + return 0;
68980 +
68981 + uid = GR_GLOBAL_UID(kuid);
68982 +
68983 + spin_lock(&gr_uid_lock);
68984 + loc = gr_find_uid(uid);
68985 +
68986 + if (loc < 0)
68987 + goto out_unlock;
68988 +
68989 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68990 + gr_remove_uid(loc);
68991 + else
68992 + ret = 1;
68993 +
68994 +out_unlock:
68995 + spin_unlock(&gr_uid_lock);
68996 + return ret;
68997 +}
68998 +
68999 +static __inline__ int
69000 +proc_is_setxid(const struct cred *cred)
69001 +{
69002 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69003 + !uid_eq(cred->uid, cred->fsuid))
69004 + return 1;
69005 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69006 + !gid_eq(cred->gid, cred->fsgid))
69007 + return 1;
69008 +
69009 + return 0;
69010 +}
69011 +
69012 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69013 +
69014 +void
69015 +gr_handle_crash(struct task_struct *task, const int sig)
69016 +{
69017 + struct acl_subject_label *curr;
69018 + struct task_struct *tsk, *tsk2;
69019 + const struct cred *cred;
69020 + const struct cred *cred2;
69021 +
69022 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69023 + return;
69024 +
69025 + if (unlikely(!gr_acl_is_enabled()))
69026 + return;
69027 +
69028 + curr = task->acl;
69029 +
69030 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
69031 + return;
69032 +
69033 + if (time_before_eq(curr->expires, get_seconds())) {
69034 + curr->expires = 0;
69035 + curr->crashes = 0;
69036 + }
69037 +
69038 + curr->crashes++;
69039 +
69040 + if (!curr->expires)
69041 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
69042 +
69043 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69044 + time_after(curr->expires, get_seconds())) {
69045 + rcu_read_lock();
69046 + cred = __task_cred(task);
69047 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
69048 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69049 + spin_lock(&gr_uid_lock);
69050 + gr_insert_uid(cred->uid, curr->expires);
69051 + spin_unlock(&gr_uid_lock);
69052 + curr->expires = 0;
69053 + curr->crashes = 0;
69054 + read_lock(&tasklist_lock);
69055 + do_each_thread(tsk2, tsk) {
69056 + cred2 = __task_cred(tsk);
69057 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
69058 + gr_fake_force_sig(SIGKILL, tsk);
69059 + } while_each_thread(tsk2, tsk);
69060 + read_unlock(&tasklist_lock);
69061 + } else {
69062 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69063 + read_lock(&tasklist_lock);
69064 + read_lock(&grsec_exec_file_lock);
69065 + do_each_thread(tsk2, tsk) {
69066 + if (likely(tsk != task)) {
69067 + // if this thread has the same subject as the one that triggered
69068 + // RES_CRASH and it's the same binary, kill it
69069 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
69070 + gr_fake_force_sig(SIGKILL, tsk);
69071 + }
69072 + } while_each_thread(tsk2, tsk);
69073 + read_unlock(&grsec_exec_file_lock);
69074 + read_unlock(&tasklist_lock);
69075 + }
69076 + rcu_read_unlock();
69077 + }
69078 +
69079 + return;
69080 +}
69081 +
69082 +int
69083 +gr_check_crash_exec(const struct file *filp)
69084 +{
69085 + struct acl_subject_label *curr;
69086 +
69087 + if (unlikely(!gr_acl_is_enabled()))
69088 + return 0;
69089 +
69090 + read_lock(&gr_inode_lock);
69091 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
69092 + __get_dev(filp->f_path.dentry),
69093 + current->role);
69094 + read_unlock(&gr_inode_lock);
69095 +
69096 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
69097 + (!curr->crashes && !curr->expires))
69098 + return 0;
69099 +
69100 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69101 + time_after(curr->expires, get_seconds()))
69102 + return 1;
69103 + else if (time_before_eq(curr->expires, get_seconds())) {
69104 + curr->crashes = 0;
69105 + curr->expires = 0;
69106 + }
69107 +
69108 + return 0;
69109 +}
69110 +
69111 +void
69112 +gr_handle_alertkill(struct task_struct *task)
69113 +{
69114 + struct acl_subject_label *curracl;
69115 + __u32 curr_ip;
69116 + struct task_struct *p, *p2;
69117 +
69118 + if (unlikely(!gr_acl_is_enabled()))
69119 + return;
69120 +
69121 + curracl = task->acl;
69122 + curr_ip = task->signal->curr_ip;
69123 +
69124 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
69125 + read_lock(&tasklist_lock);
69126 + do_each_thread(p2, p) {
69127 + if (p->signal->curr_ip == curr_ip)
69128 + gr_fake_force_sig(SIGKILL, p);
69129 + } while_each_thread(p2, p);
69130 + read_unlock(&tasklist_lock);
69131 + } else if (curracl->mode & GR_KILLPROC)
69132 + gr_fake_force_sig(SIGKILL, task);
69133 +
69134 + return;
69135 +}
69136 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
69137 new file mode 100644
69138 index 0000000..98011b0
69139 --- /dev/null
69140 +++ b/grsecurity/gracl_shm.c
69141 @@ -0,0 +1,40 @@
69142 +#include <linux/kernel.h>
69143 +#include <linux/mm.h>
69144 +#include <linux/sched.h>
69145 +#include <linux/file.h>
69146 +#include <linux/ipc.h>
69147 +#include <linux/gracl.h>
69148 +#include <linux/grsecurity.h>
69149 +#include <linux/grinternal.h>
69150 +
69151 +int
69152 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69153 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69154 +{
69155 + struct task_struct *task;
69156 +
69157 + if (!gr_acl_is_enabled())
69158 + return 1;
69159 +
69160 + rcu_read_lock();
69161 + read_lock(&tasklist_lock);
69162 +
69163 + task = find_task_by_vpid(shm_cprid);
69164 +
69165 + if (unlikely(!task))
69166 + task = find_task_by_vpid(shm_lapid);
69167 +
69168 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
69169 + (task_pid_nr(task) == shm_lapid)) &&
69170 + (task->acl->mode & GR_PROTSHM) &&
69171 + (task->acl != current->acl))) {
69172 + read_unlock(&tasklist_lock);
69173 + rcu_read_unlock();
69174 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
69175 + return 0;
69176 + }
69177 + read_unlock(&tasklist_lock);
69178 + rcu_read_unlock();
69179 +
69180 + return 1;
69181 +}
69182 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
69183 new file mode 100644
69184 index 0000000..bc0be01
69185 --- /dev/null
69186 +++ b/grsecurity/grsec_chdir.c
69187 @@ -0,0 +1,19 @@
69188 +#include <linux/kernel.h>
69189 +#include <linux/sched.h>
69190 +#include <linux/fs.h>
69191 +#include <linux/file.h>
69192 +#include <linux/grsecurity.h>
69193 +#include <linux/grinternal.h>
69194 +
69195 +void
69196 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
69197 +{
69198 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69199 + if ((grsec_enable_chdir && grsec_enable_group &&
69200 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
69201 + !grsec_enable_group)) {
69202 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
69203 + }
69204 +#endif
69205 + return;
69206 +}
69207 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
69208 new file mode 100644
69209 index 0000000..e10b319
69210 --- /dev/null
69211 +++ b/grsecurity/grsec_chroot.c
69212 @@ -0,0 +1,370 @@
69213 +#include <linux/kernel.h>
69214 +#include <linux/module.h>
69215 +#include <linux/sched.h>
69216 +#include <linux/file.h>
69217 +#include <linux/fs.h>
69218 +#include <linux/mount.h>
69219 +#include <linux/types.h>
69220 +#include "../fs/mount.h"
69221 +#include <linux/grsecurity.h>
69222 +#include <linux/grinternal.h>
69223 +
69224 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69225 +int gr_init_ran;
69226 +#endif
69227 +
69228 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
69229 +{
69230 +#ifdef CONFIG_GRKERNSEC
69231 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
69232 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
69233 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69234 + && gr_init_ran
69235 +#endif
69236 + )
69237 + task->gr_is_chrooted = 1;
69238 + else {
69239 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69240 + if (task_pid_nr(task) == 1 && !gr_init_ran)
69241 + gr_init_ran = 1;
69242 +#endif
69243 + task->gr_is_chrooted = 0;
69244 + }
69245 +
69246 + task->gr_chroot_dentry = path->dentry;
69247 +#endif
69248 + return;
69249 +}
69250 +
69251 +void gr_clear_chroot_entries(struct task_struct *task)
69252 +{
69253 +#ifdef CONFIG_GRKERNSEC
69254 + task->gr_is_chrooted = 0;
69255 + task->gr_chroot_dentry = NULL;
69256 +#endif
69257 + return;
69258 +}
69259 +
69260 +int
69261 +gr_handle_chroot_unix(const pid_t pid)
69262 +{
69263 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69264 + struct task_struct *p;
69265 +
69266 + if (unlikely(!grsec_enable_chroot_unix))
69267 + return 1;
69268 +
69269 + if (likely(!proc_is_chrooted(current)))
69270 + return 1;
69271 +
69272 + rcu_read_lock();
69273 + read_lock(&tasklist_lock);
69274 + p = find_task_by_vpid_unrestricted(pid);
69275 + if (unlikely(p && !have_same_root(current, p))) {
69276 + read_unlock(&tasklist_lock);
69277 + rcu_read_unlock();
69278 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
69279 + return 0;
69280 + }
69281 + read_unlock(&tasklist_lock);
69282 + rcu_read_unlock();
69283 +#endif
69284 + return 1;
69285 +}
69286 +
69287 +int
69288 +gr_handle_chroot_nice(void)
69289 +{
69290 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69291 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
69292 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
69293 + return -EPERM;
69294 + }
69295 +#endif
69296 + return 0;
69297 +}
69298 +
69299 +int
69300 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
69301 +{
69302 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69303 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
69304 + && proc_is_chrooted(current)) {
69305 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
69306 + return -EACCES;
69307 + }
69308 +#endif
69309 + return 0;
69310 +}
69311 +
69312 +int
69313 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
69314 +{
69315 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69316 + struct task_struct *p;
69317 + int ret = 0;
69318 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
69319 + return ret;
69320 +
69321 + read_lock(&tasklist_lock);
69322 + do_each_pid_task(pid, type, p) {
69323 + if (!have_same_root(current, p)) {
69324 + ret = 1;
69325 + goto out;
69326 + }
69327 + } while_each_pid_task(pid, type, p);
69328 +out:
69329 + read_unlock(&tasklist_lock);
69330 + return ret;
69331 +#endif
69332 + return 0;
69333 +}
69334 +
69335 +int
69336 +gr_pid_is_chrooted(struct task_struct *p)
69337 +{
69338 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69339 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
69340 + return 0;
69341 +
69342 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
69343 + !have_same_root(current, p)) {
69344 + return 1;
69345 + }
69346 +#endif
69347 + return 0;
69348 +}
69349 +
69350 +EXPORT_SYMBOL(gr_pid_is_chrooted);
69351 +
69352 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
69353 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
69354 +{
69355 + struct path path, currentroot;
69356 + int ret = 0;
69357 +
69358 + path.dentry = (struct dentry *)u_dentry;
69359 + path.mnt = (struct vfsmount *)u_mnt;
69360 + get_fs_root(current->fs, &currentroot);
69361 + if (path_is_under(&path, &currentroot))
69362 + ret = 1;
69363 + path_put(&currentroot);
69364 +
69365 + return ret;
69366 +}
69367 +#endif
69368 +
69369 +int
69370 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
69371 +{
69372 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69373 + if (!grsec_enable_chroot_fchdir)
69374 + return 1;
69375 +
69376 + if (!proc_is_chrooted(current))
69377 + return 1;
69378 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
69379 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
69380 + return 0;
69381 + }
69382 +#endif
69383 + return 1;
69384 +}
69385 +
69386 +int
69387 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69388 + const time_t shm_createtime)
69389 +{
69390 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69391 + struct task_struct *p;
69392 + time_t starttime;
69393 +
69394 + if (unlikely(!grsec_enable_chroot_shmat))
69395 + return 1;
69396 +
69397 + if (likely(!proc_is_chrooted(current)))
69398 + return 1;
69399 +
69400 + rcu_read_lock();
69401 + read_lock(&tasklist_lock);
69402 +
69403 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
69404 + starttime = p->start_time.tv_sec;
69405 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
69406 + if (have_same_root(current, p)) {
69407 + goto allow;
69408 + } else {
69409 + read_unlock(&tasklist_lock);
69410 + rcu_read_unlock();
69411 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69412 + return 0;
69413 + }
69414 + }
69415 + /* creator exited, pid reuse, fall through to next check */
69416 + }
69417 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
69418 + if (unlikely(!have_same_root(current, p))) {
69419 + read_unlock(&tasklist_lock);
69420 + rcu_read_unlock();
69421 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69422 + return 0;
69423 + }
69424 + }
69425 +
69426 +allow:
69427 + read_unlock(&tasklist_lock);
69428 + rcu_read_unlock();
69429 +#endif
69430 + return 1;
69431 +}
69432 +
69433 +void
69434 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
69435 +{
69436 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69437 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
69438 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
69439 +#endif
69440 + return;
69441 +}
69442 +
69443 +int
69444 +gr_handle_chroot_mknod(const struct dentry *dentry,
69445 + const struct vfsmount *mnt, const int mode)
69446 +{
69447 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69448 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
69449 + proc_is_chrooted(current)) {
69450 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
69451 + return -EPERM;
69452 + }
69453 +#endif
69454 + return 0;
69455 +}
69456 +
69457 +int
69458 +gr_handle_chroot_mount(const struct dentry *dentry,
69459 + const struct vfsmount *mnt, const char *dev_name)
69460 +{
69461 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69462 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
69463 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
69464 + return -EPERM;
69465 + }
69466 +#endif
69467 + return 0;
69468 +}
69469 +
69470 +int
69471 +gr_handle_chroot_pivot(void)
69472 +{
69473 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69474 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
69475 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
69476 + return -EPERM;
69477 + }
69478 +#endif
69479 + return 0;
69480 +}
69481 +
69482 +int
69483 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
69484 +{
69485 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69486 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
69487 + !gr_is_outside_chroot(dentry, mnt)) {
69488 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
69489 + return -EPERM;
69490 + }
69491 +#endif
69492 + return 0;
69493 +}
69494 +
69495 +extern const char *captab_log[];
69496 +extern int captab_log_entries;
69497 +
69498 +int
69499 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69500 +{
69501 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69502 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69503 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69504 + if (cap_raised(chroot_caps, cap)) {
69505 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
69506 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
69507 + }
69508 + return 0;
69509 + }
69510 + }
69511 +#endif
69512 + return 1;
69513 +}
69514 +
69515 +int
69516 +gr_chroot_is_capable(const int cap)
69517 +{
69518 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69519 + return gr_task_chroot_is_capable(current, current_cred(), cap);
69520 +#endif
69521 + return 1;
69522 +}
69523 +
69524 +int
69525 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
69526 +{
69527 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69528 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69529 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69530 + if (cap_raised(chroot_caps, cap)) {
69531 + return 0;
69532 + }
69533 + }
69534 +#endif
69535 + return 1;
69536 +}
69537 +
69538 +int
69539 +gr_chroot_is_capable_nolog(const int cap)
69540 +{
69541 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69542 + return gr_task_chroot_is_capable_nolog(current, cap);
69543 +#endif
69544 + return 1;
69545 +}
69546 +
69547 +int
69548 +gr_handle_chroot_sysctl(const int op)
69549 +{
69550 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69551 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
69552 + proc_is_chrooted(current))
69553 + return -EACCES;
69554 +#endif
69555 + return 0;
69556 +}
69557 +
69558 +void
69559 +gr_handle_chroot_chdir(const struct path *path)
69560 +{
69561 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69562 + if (grsec_enable_chroot_chdir)
69563 + set_fs_pwd(current->fs, path);
69564 +#endif
69565 + return;
69566 +}
69567 +
69568 +int
69569 +gr_handle_chroot_chmod(const struct dentry *dentry,
69570 + const struct vfsmount *mnt, const int mode)
69571 +{
69572 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69573 + /* allow chmod +s on directories, but not files */
69574 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
69575 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
69576 + proc_is_chrooted(current)) {
69577 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
69578 + return -EPERM;
69579 + }
69580 +#endif
69581 + return 0;
69582 +}
69583 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
69584 new file mode 100644
69585 index 0000000..0866ab2
69586 --- /dev/null
69587 +++ b/grsecurity/grsec_disabled.c
69588 @@ -0,0 +1,427 @@
69589 +#include <linux/kernel.h>
69590 +#include <linux/module.h>
69591 +#include <linux/sched.h>
69592 +#include <linux/file.h>
69593 +#include <linux/fs.h>
69594 +#include <linux/kdev_t.h>
69595 +#include <linux/net.h>
69596 +#include <linux/in.h>
69597 +#include <linux/ip.h>
69598 +#include <linux/skbuff.h>
69599 +#include <linux/sysctl.h>
69600 +
69601 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
69602 +void
69603 +pax_set_initial_flags(struct linux_binprm *bprm)
69604 +{
69605 + return;
69606 +}
69607 +#endif
69608 +
69609 +#ifdef CONFIG_SYSCTL
69610 +__u32
69611 +gr_handle_sysctl(const struct ctl_table * table, const int op)
69612 +{
69613 + return 0;
69614 +}
69615 +#endif
69616 +
69617 +#ifdef CONFIG_TASKSTATS
69618 +int gr_is_taskstats_denied(int pid)
69619 +{
69620 + return 0;
69621 +}
69622 +#endif
69623 +
69624 +int
69625 +gr_acl_is_enabled(void)
69626 +{
69627 + return 0;
69628 +}
69629 +
69630 +void
69631 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
69632 +{
69633 + return;
69634 +}
69635 +
69636 +int
69637 +gr_handle_rawio(const struct inode *inode)
69638 +{
69639 + return 0;
69640 +}
69641 +
69642 +void
69643 +gr_acl_handle_psacct(struct task_struct *task, const long code)
69644 +{
69645 + return;
69646 +}
69647 +
69648 +int
69649 +gr_handle_ptrace(struct task_struct *task, const long request)
69650 +{
69651 + return 0;
69652 +}
69653 +
69654 +int
69655 +gr_handle_proc_ptrace(struct task_struct *task)
69656 +{
69657 + return 0;
69658 +}
69659 +
69660 +int
69661 +gr_set_acls(const int type)
69662 +{
69663 + return 0;
69664 +}
69665 +
69666 +int
69667 +gr_check_hidden_task(const struct task_struct *tsk)
69668 +{
69669 + return 0;
69670 +}
69671 +
69672 +int
69673 +gr_check_protected_task(const struct task_struct *task)
69674 +{
69675 + return 0;
69676 +}
69677 +
69678 +int
69679 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
69680 +{
69681 + return 0;
69682 +}
69683 +
69684 +void
69685 +gr_copy_label(struct task_struct *tsk)
69686 +{
69687 + return;
69688 +}
69689 +
69690 +void
69691 +gr_set_pax_flags(struct task_struct *task)
69692 +{
69693 + return;
69694 +}
69695 +
69696 +int
69697 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
69698 + const int unsafe_share)
69699 +{
69700 + return 0;
69701 +}
69702 +
69703 +void
69704 +gr_handle_delete(const ino_t ino, const dev_t dev)
69705 +{
69706 + return;
69707 +}
69708 +
69709 +void
69710 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
69711 +{
69712 + return;
69713 +}
69714 +
69715 +void
69716 +gr_handle_crash(struct task_struct *task, const int sig)
69717 +{
69718 + return;
69719 +}
69720 +
69721 +int
69722 +gr_check_crash_exec(const struct file *filp)
69723 +{
69724 + return 0;
69725 +}
69726 +
69727 +int
69728 +gr_check_crash_uid(const kuid_t uid)
69729 +{
69730 + return 0;
69731 +}
69732 +
69733 +void
69734 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69735 + struct dentry *old_dentry,
69736 + struct dentry *new_dentry,
69737 + struct vfsmount *mnt, const __u8 replace)
69738 +{
69739 + return;
69740 +}
69741 +
69742 +int
69743 +gr_search_socket(const int family, const int type, const int protocol)
69744 +{
69745 + return 1;
69746 +}
69747 +
69748 +int
69749 +gr_search_connectbind(const int mode, const struct socket *sock,
69750 + const struct sockaddr_in *addr)
69751 +{
69752 + return 0;
69753 +}
69754 +
69755 +void
69756 +gr_handle_alertkill(struct task_struct *task)
69757 +{
69758 + return;
69759 +}
69760 +
69761 +__u32
69762 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
69763 +{
69764 + return 1;
69765 +}
69766 +
69767 +__u32
69768 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69769 + const struct vfsmount * mnt)
69770 +{
69771 + return 1;
69772 +}
69773 +
69774 +__u32
69775 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69776 + int acc_mode)
69777 +{
69778 + return 1;
69779 +}
69780 +
69781 +__u32
69782 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
69783 +{
69784 + return 1;
69785 +}
69786 +
69787 +__u32
69788 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
69789 +{
69790 + return 1;
69791 +}
69792 +
69793 +int
69794 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
69795 + unsigned int *vm_flags)
69796 +{
69797 + return 1;
69798 +}
69799 +
69800 +__u32
69801 +gr_acl_handle_truncate(const struct dentry * dentry,
69802 + const struct vfsmount * mnt)
69803 +{
69804 + return 1;
69805 +}
69806 +
69807 +__u32
69808 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69809 +{
69810 + return 1;
69811 +}
69812 +
69813 +__u32
69814 +gr_acl_handle_access(const struct dentry * dentry,
69815 + const struct vfsmount * mnt, const int fmode)
69816 +{
69817 + return 1;
69818 +}
69819 +
69820 +__u32
69821 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69822 + umode_t *mode)
69823 +{
69824 + return 1;
69825 +}
69826 +
69827 +__u32
69828 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69829 +{
69830 + return 1;
69831 +}
69832 +
69833 +__u32
69834 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69835 +{
69836 + return 1;
69837 +}
69838 +
69839 +void
69840 +grsecurity_init(void)
69841 +{
69842 + return;
69843 +}
69844 +
69845 +umode_t gr_acl_umask(void)
69846 +{
69847 + return 0;
69848 +}
69849 +
69850 +__u32
69851 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69852 + const struct dentry * parent_dentry,
69853 + const struct vfsmount * parent_mnt,
69854 + const int mode)
69855 +{
69856 + return 1;
69857 +}
69858 +
69859 +__u32
69860 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69861 + const struct dentry * parent_dentry,
69862 + const struct vfsmount * parent_mnt)
69863 +{
69864 + return 1;
69865 +}
69866 +
69867 +__u32
69868 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69869 + const struct dentry * parent_dentry,
69870 + const struct vfsmount * parent_mnt, const struct filename *from)
69871 +{
69872 + return 1;
69873 +}
69874 +
69875 +__u32
69876 +gr_acl_handle_link(const struct dentry * new_dentry,
69877 + const struct dentry * parent_dentry,
69878 + const struct vfsmount * parent_mnt,
69879 + const struct dentry * old_dentry,
69880 + const struct vfsmount * old_mnt, const struct filename *to)
69881 +{
69882 + return 1;
69883 +}
69884 +
69885 +int
69886 +gr_acl_handle_rename(const struct dentry *new_dentry,
69887 + const struct dentry *parent_dentry,
69888 + const struct vfsmount *parent_mnt,
69889 + const struct dentry *old_dentry,
69890 + const struct inode *old_parent_inode,
69891 + const struct vfsmount *old_mnt, const struct filename *newname)
69892 +{
69893 + return 0;
69894 +}
69895 +
69896 +int
69897 +gr_acl_handle_filldir(const struct file *file, const char *name,
69898 + const int namelen, const ino_t ino)
69899 +{
69900 + return 1;
69901 +}
69902 +
69903 +int
69904 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69905 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69906 +{
69907 + return 1;
69908 +}
69909 +
69910 +int
69911 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69912 +{
69913 + return 0;
69914 +}
69915 +
69916 +int
69917 +gr_search_accept(const struct socket *sock)
69918 +{
69919 + return 0;
69920 +}
69921 +
69922 +int
69923 +gr_search_listen(const struct socket *sock)
69924 +{
69925 + return 0;
69926 +}
69927 +
69928 +int
69929 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69930 +{
69931 + return 0;
69932 +}
69933 +
69934 +__u32
69935 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69936 +{
69937 + return 1;
69938 +}
69939 +
69940 +__u32
69941 +gr_acl_handle_creat(const struct dentry * dentry,
69942 + const struct dentry * p_dentry,
69943 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69944 + const int imode)
69945 +{
69946 + return 1;
69947 +}
69948 +
69949 +void
69950 +gr_acl_handle_exit(void)
69951 +{
69952 + return;
69953 +}
69954 +
69955 +int
69956 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69957 +{
69958 + return 1;
69959 +}
69960 +
69961 +void
69962 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69963 +{
69964 + return;
69965 +}
69966 +
69967 +int
69968 +gr_acl_handle_procpidmem(const struct task_struct *task)
69969 +{
69970 + return 0;
69971 +}
69972 +
69973 +int
69974 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69975 +{
69976 + return 0;
69977 +}
69978 +
69979 +int
69980 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69981 +{
69982 + return 0;
69983 +}
69984 +
69985 +int
69986 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69987 +{
69988 + return 0;
69989 +}
69990 +
69991 +int
69992 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69993 +{
69994 + return 0;
69995 +}
69996 +
69997 +int gr_acl_enable_at_secure(void)
69998 +{
69999 + return 0;
70000 +}
70001 +
70002 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70003 +{
70004 + return dentry->d_sb->s_dev;
70005 +}
70006 +
70007 +void gr_put_exec_file(struct task_struct *task)
70008 +{
70009 + return;
70010 +}
70011 +
70012 +#ifdef CONFIG_SECURITY
70013 +EXPORT_SYMBOL(gr_check_user_change);
70014 +EXPORT_SYMBOL(gr_check_group_change);
70015 +#endif
70016 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70017 new file mode 100644
70018 index 0000000..387032b
70019 --- /dev/null
70020 +++ b/grsecurity/grsec_exec.c
70021 @@ -0,0 +1,187 @@
70022 +#include <linux/kernel.h>
70023 +#include <linux/sched.h>
70024 +#include <linux/file.h>
70025 +#include <linux/binfmts.h>
70026 +#include <linux/fs.h>
70027 +#include <linux/types.h>
70028 +#include <linux/grdefs.h>
70029 +#include <linux/grsecurity.h>
70030 +#include <linux/grinternal.h>
70031 +#include <linux/capability.h>
70032 +#include <linux/module.h>
70033 +#include <linux/compat.h>
70034 +
70035 +#include <asm/uaccess.h>
70036 +
70037 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70038 +static char gr_exec_arg_buf[132];
70039 +static DEFINE_MUTEX(gr_exec_arg_mutex);
70040 +#endif
70041 +
70042 +struct user_arg_ptr {
70043 +#ifdef CONFIG_COMPAT
70044 + bool is_compat;
70045 +#endif
70046 + union {
70047 + const char __user *const __user *native;
70048 +#ifdef CONFIG_COMPAT
70049 + const compat_uptr_t __user *compat;
70050 +#endif
70051 + } ptr;
70052 +};
70053 +
70054 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
70055 +
70056 +void
70057 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
70058 +{
70059 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70060 + char *grarg = gr_exec_arg_buf;
70061 + unsigned int i, x, execlen = 0;
70062 + char c;
70063 +
70064 + if (!((grsec_enable_execlog && grsec_enable_group &&
70065 + in_group_p(grsec_audit_gid))
70066 + || (grsec_enable_execlog && !grsec_enable_group)))
70067 + return;
70068 +
70069 + mutex_lock(&gr_exec_arg_mutex);
70070 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
70071 +
70072 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
70073 + const char __user *p;
70074 + unsigned int len;
70075 +
70076 + p = get_user_arg_ptr(argv, i);
70077 + if (IS_ERR(p))
70078 + goto log;
70079 +
70080 + len = strnlen_user(p, 128 - execlen);
70081 + if (len > 128 - execlen)
70082 + len = 128 - execlen;
70083 + else if (len > 0)
70084 + len--;
70085 + if (copy_from_user(grarg + execlen, p, len))
70086 + goto log;
70087 +
70088 + /* rewrite unprintable characters */
70089 + for (x = 0; x < len; x++) {
70090 + c = *(grarg + execlen + x);
70091 + if (c < 32 || c > 126)
70092 + *(grarg + execlen + x) = ' ';
70093 + }
70094 +
70095 + execlen += len;
70096 + *(grarg + execlen) = ' ';
70097 + *(grarg + execlen + 1) = '\0';
70098 + execlen++;
70099 + }
70100 +
70101 + log:
70102 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
70103 + bprm->file->f_path.mnt, grarg);
70104 + mutex_unlock(&gr_exec_arg_mutex);
70105 +#endif
70106 + return;
70107 +}
70108 +
70109 +#ifdef CONFIG_GRKERNSEC
70110 +extern int gr_acl_is_capable(const int cap);
70111 +extern int gr_acl_is_capable_nolog(const int cap);
70112 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70113 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
70114 +extern int gr_chroot_is_capable(const int cap);
70115 +extern int gr_chroot_is_capable_nolog(const int cap);
70116 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70117 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
70118 +#endif
70119 +
70120 +const char *captab_log[] = {
70121 + "CAP_CHOWN",
70122 + "CAP_DAC_OVERRIDE",
70123 + "CAP_DAC_READ_SEARCH",
70124 + "CAP_FOWNER",
70125 + "CAP_FSETID",
70126 + "CAP_KILL",
70127 + "CAP_SETGID",
70128 + "CAP_SETUID",
70129 + "CAP_SETPCAP",
70130 + "CAP_LINUX_IMMUTABLE",
70131 + "CAP_NET_BIND_SERVICE",
70132 + "CAP_NET_BROADCAST",
70133 + "CAP_NET_ADMIN",
70134 + "CAP_NET_RAW",
70135 + "CAP_IPC_LOCK",
70136 + "CAP_IPC_OWNER",
70137 + "CAP_SYS_MODULE",
70138 + "CAP_SYS_RAWIO",
70139 + "CAP_SYS_CHROOT",
70140 + "CAP_SYS_PTRACE",
70141 + "CAP_SYS_PACCT",
70142 + "CAP_SYS_ADMIN",
70143 + "CAP_SYS_BOOT",
70144 + "CAP_SYS_NICE",
70145 + "CAP_SYS_RESOURCE",
70146 + "CAP_SYS_TIME",
70147 + "CAP_SYS_TTY_CONFIG",
70148 + "CAP_MKNOD",
70149 + "CAP_LEASE",
70150 + "CAP_AUDIT_WRITE",
70151 + "CAP_AUDIT_CONTROL",
70152 + "CAP_SETFCAP",
70153 + "CAP_MAC_OVERRIDE",
70154 + "CAP_MAC_ADMIN",
70155 + "CAP_SYSLOG",
70156 + "CAP_WAKE_ALARM"
70157 +};
70158 +
70159 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
70160 +
70161 +int gr_is_capable(const int cap)
70162 +{
70163 +#ifdef CONFIG_GRKERNSEC
70164 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
70165 + return 1;
70166 + return 0;
70167 +#else
70168 + return 1;
70169 +#endif
70170 +}
70171 +
70172 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70173 +{
70174 +#ifdef CONFIG_GRKERNSEC
70175 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
70176 + return 1;
70177 + return 0;
70178 +#else
70179 + return 1;
70180 +#endif
70181 +}
70182 +
70183 +int gr_is_capable_nolog(const int cap)
70184 +{
70185 +#ifdef CONFIG_GRKERNSEC
70186 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
70187 + return 1;
70188 + return 0;
70189 +#else
70190 + return 1;
70191 +#endif
70192 +}
70193 +
70194 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
70195 +{
70196 +#ifdef CONFIG_GRKERNSEC
70197 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
70198 + return 1;
70199 + return 0;
70200 +#else
70201 + return 1;
70202 +#endif
70203 +}
70204 +
70205 +EXPORT_SYMBOL(gr_is_capable);
70206 +EXPORT_SYMBOL(gr_is_capable_nolog);
70207 +EXPORT_SYMBOL(gr_task_is_capable);
70208 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
70209 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
70210 new file mode 100644
70211 index 0000000..06cc6ea
70212 --- /dev/null
70213 +++ b/grsecurity/grsec_fifo.c
70214 @@ -0,0 +1,24 @@
70215 +#include <linux/kernel.h>
70216 +#include <linux/sched.h>
70217 +#include <linux/fs.h>
70218 +#include <linux/file.h>
70219 +#include <linux/grinternal.h>
70220 +
70221 +int
70222 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
70223 + const struct dentry *dir, const int flag, const int acc_mode)
70224 +{
70225 +#ifdef CONFIG_GRKERNSEC_FIFO
70226 + const struct cred *cred = current_cred();
70227 +
70228 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
70229 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
70230 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
70231 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
70232 + if (!inode_permission(dentry->d_inode, acc_mode))
70233 + 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));
70234 + return -EACCES;
70235 + }
70236 +#endif
70237 + return 0;
70238 +}
70239 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
70240 new file mode 100644
70241 index 0000000..8ca18bf
70242 --- /dev/null
70243 +++ b/grsecurity/grsec_fork.c
70244 @@ -0,0 +1,23 @@
70245 +#include <linux/kernel.h>
70246 +#include <linux/sched.h>
70247 +#include <linux/grsecurity.h>
70248 +#include <linux/grinternal.h>
70249 +#include <linux/errno.h>
70250 +
70251 +void
70252 +gr_log_forkfail(const int retval)
70253 +{
70254 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70255 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
70256 + switch (retval) {
70257 + case -EAGAIN:
70258 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
70259 + break;
70260 + case -ENOMEM:
70261 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
70262 + break;
70263 + }
70264 + }
70265 +#endif
70266 + return;
70267 +}
70268 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
70269 new file mode 100644
70270 index 0000000..a88e901
70271 --- /dev/null
70272 +++ b/grsecurity/grsec_init.c
70273 @@ -0,0 +1,272 @@
70274 +#include <linux/kernel.h>
70275 +#include <linux/sched.h>
70276 +#include <linux/mm.h>
70277 +#include <linux/gracl.h>
70278 +#include <linux/slab.h>
70279 +#include <linux/vmalloc.h>
70280 +#include <linux/percpu.h>
70281 +#include <linux/module.h>
70282 +
70283 +int grsec_enable_ptrace_readexec;
70284 +int grsec_enable_setxid;
70285 +int grsec_enable_symlinkown;
70286 +kgid_t grsec_symlinkown_gid;
70287 +int grsec_enable_brute;
70288 +int grsec_enable_link;
70289 +int grsec_enable_dmesg;
70290 +int grsec_enable_harden_ptrace;
70291 +int grsec_enable_harden_ipc;
70292 +int grsec_enable_fifo;
70293 +int grsec_enable_execlog;
70294 +int grsec_enable_signal;
70295 +int grsec_enable_forkfail;
70296 +int grsec_enable_audit_ptrace;
70297 +int grsec_enable_time;
70298 +int grsec_enable_group;
70299 +kgid_t grsec_audit_gid;
70300 +int grsec_enable_chdir;
70301 +int grsec_enable_mount;
70302 +int grsec_enable_rofs;
70303 +int grsec_deny_new_usb;
70304 +int grsec_enable_chroot_findtask;
70305 +int grsec_enable_chroot_mount;
70306 +int grsec_enable_chroot_shmat;
70307 +int grsec_enable_chroot_fchdir;
70308 +int grsec_enable_chroot_double;
70309 +int grsec_enable_chroot_pivot;
70310 +int grsec_enable_chroot_chdir;
70311 +int grsec_enable_chroot_chmod;
70312 +int grsec_enable_chroot_mknod;
70313 +int grsec_enable_chroot_nice;
70314 +int grsec_enable_chroot_execlog;
70315 +int grsec_enable_chroot_caps;
70316 +int grsec_enable_chroot_sysctl;
70317 +int grsec_enable_chroot_unix;
70318 +int grsec_enable_tpe;
70319 +kgid_t grsec_tpe_gid;
70320 +int grsec_enable_blackhole;
70321 +#ifdef CONFIG_IPV6_MODULE
70322 +EXPORT_SYMBOL(grsec_enable_blackhole);
70323 +#endif
70324 +int grsec_lastack_retries;
70325 +int grsec_enable_tpe_all;
70326 +int grsec_enable_tpe_invert;
70327 +int grsec_enable_socket_all;
70328 +kgid_t grsec_socket_all_gid;
70329 +int grsec_enable_socket_client;
70330 +kgid_t grsec_socket_client_gid;
70331 +int grsec_enable_socket_server;
70332 +kgid_t grsec_socket_server_gid;
70333 +int grsec_resource_logging;
70334 +int grsec_disable_privio;
70335 +int grsec_enable_log_rwxmaps;
70336 +int grsec_lock;
70337 +
70338 +DEFINE_SPINLOCK(grsec_alert_lock);
70339 +unsigned long grsec_alert_wtime = 0;
70340 +unsigned long grsec_alert_fyet = 0;
70341 +
70342 +DEFINE_SPINLOCK(grsec_audit_lock);
70343 +
70344 +DEFINE_RWLOCK(grsec_exec_file_lock);
70345 +
70346 +char *gr_shared_page[4];
70347 +
70348 +char *gr_alert_log_fmt;
70349 +char *gr_audit_log_fmt;
70350 +char *gr_alert_log_buf;
70351 +char *gr_audit_log_buf;
70352 +
70353 +void __init
70354 +grsecurity_init(void)
70355 +{
70356 + int j;
70357 + /* create the per-cpu shared pages */
70358 +
70359 +#ifdef CONFIG_X86
70360 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
70361 +#endif
70362 +
70363 + for (j = 0; j < 4; j++) {
70364 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
70365 + if (gr_shared_page[j] == NULL) {
70366 + panic("Unable to allocate grsecurity shared page");
70367 + return;
70368 + }
70369 + }
70370 +
70371 + /* allocate log buffers */
70372 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
70373 + if (!gr_alert_log_fmt) {
70374 + panic("Unable to allocate grsecurity alert log format buffer");
70375 + return;
70376 + }
70377 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
70378 + if (!gr_audit_log_fmt) {
70379 + panic("Unable to allocate grsecurity audit log format buffer");
70380 + return;
70381 + }
70382 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70383 + if (!gr_alert_log_buf) {
70384 + panic("Unable to allocate grsecurity alert log buffer");
70385 + return;
70386 + }
70387 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70388 + if (!gr_audit_log_buf) {
70389 + panic("Unable to allocate grsecurity audit log buffer");
70390 + return;
70391 + }
70392 +
70393 +#ifdef CONFIG_GRKERNSEC_IO
70394 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
70395 + grsec_disable_privio = 1;
70396 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70397 + grsec_disable_privio = 1;
70398 +#else
70399 + grsec_disable_privio = 0;
70400 +#endif
70401 +#endif
70402 +
70403 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70404 + /* for backward compatibility, tpe_invert always defaults to on if
70405 + enabled in the kernel
70406 + */
70407 + grsec_enable_tpe_invert = 1;
70408 +#endif
70409 +
70410 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70411 +#ifndef CONFIG_GRKERNSEC_SYSCTL
70412 + grsec_lock = 1;
70413 +#endif
70414 +
70415 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70416 + grsec_enable_log_rwxmaps = 1;
70417 +#endif
70418 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
70419 + grsec_enable_group = 1;
70420 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
70421 +#endif
70422 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70423 + grsec_enable_ptrace_readexec = 1;
70424 +#endif
70425 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70426 + grsec_enable_chdir = 1;
70427 +#endif
70428 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
70429 + grsec_enable_harden_ptrace = 1;
70430 +#endif
70431 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70432 + grsec_enable_harden_ipc = 1;
70433 +#endif
70434 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70435 + grsec_enable_mount = 1;
70436 +#endif
70437 +#ifdef CONFIG_GRKERNSEC_LINK
70438 + grsec_enable_link = 1;
70439 +#endif
70440 +#ifdef CONFIG_GRKERNSEC_BRUTE
70441 + grsec_enable_brute = 1;
70442 +#endif
70443 +#ifdef CONFIG_GRKERNSEC_DMESG
70444 + grsec_enable_dmesg = 1;
70445 +#endif
70446 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70447 + grsec_enable_blackhole = 1;
70448 + grsec_lastack_retries = 4;
70449 +#endif
70450 +#ifdef CONFIG_GRKERNSEC_FIFO
70451 + grsec_enable_fifo = 1;
70452 +#endif
70453 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70454 + grsec_enable_execlog = 1;
70455 +#endif
70456 +#ifdef CONFIG_GRKERNSEC_SETXID
70457 + grsec_enable_setxid = 1;
70458 +#endif
70459 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70460 + grsec_enable_signal = 1;
70461 +#endif
70462 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70463 + grsec_enable_forkfail = 1;
70464 +#endif
70465 +#ifdef CONFIG_GRKERNSEC_TIME
70466 + grsec_enable_time = 1;
70467 +#endif
70468 +#ifdef CONFIG_GRKERNSEC_RESLOG
70469 + grsec_resource_logging = 1;
70470 +#endif
70471 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70472 + grsec_enable_chroot_findtask = 1;
70473 +#endif
70474 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70475 + grsec_enable_chroot_unix = 1;
70476 +#endif
70477 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70478 + grsec_enable_chroot_mount = 1;
70479 +#endif
70480 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70481 + grsec_enable_chroot_fchdir = 1;
70482 +#endif
70483 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70484 + grsec_enable_chroot_shmat = 1;
70485 +#endif
70486 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70487 + grsec_enable_audit_ptrace = 1;
70488 +#endif
70489 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70490 + grsec_enable_chroot_double = 1;
70491 +#endif
70492 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70493 + grsec_enable_chroot_pivot = 1;
70494 +#endif
70495 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70496 + grsec_enable_chroot_chdir = 1;
70497 +#endif
70498 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70499 + grsec_enable_chroot_chmod = 1;
70500 +#endif
70501 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70502 + grsec_enable_chroot_mknod = 1;
70503 +#endif
70504 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70505 + grsec_enable_chroot_nice = 1;
70506 +#endif
70507 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70508 + grsec_enable_chroot_execlog = 1;
70509 +#endif
70510 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70511 + grsec_enable_chroot_caps = 1;
70512 +#endif
70513 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70514 + grsec_enable_chroot_sysctl = 1;
70515 +#endif
70516 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70517 + grsec_enable_symlinkown = 1;
70518 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
70519 +#endif
70520 +#ifdef CONFIG_GRKERNSEC_TPE
70521 + grsec_enable_tpe = 1;
70522 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
70523 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70524 + grsec_enable_tpe_all = 1;
70525 +#endif
70526 +#endif
70527 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70528 + grsec_enable_socket_all = 1;
70529 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
70530 +#endif
70531 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70532 + grsec_enable_socket_client = 1;
70533 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
70534 +#endif
70535 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70536 + grsec_enable_socket_server = 1;
70537 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
70538 +#endif
70539 +#endif
70540 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
70541 + grsec_deny_new_usb = 1;
70542 +#endif
70543 +
70544 + return;
70545 +}
70546 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
70547 new file mode 100644
70548 index 0000000..f365de0
70549 --- /dev/null
70550 +++ b/grsecurity/grsec_ipc.c
70551 @@ -0,0 +1,22 @@
70552 +#include <linux/kernel.h>
70553 +#include <linux/mm.h>
70554 +#include <linux/sched.h>
70555 +#include <linux/file.h>
70556 +#include <linux/ipc.h>
70557 +#include <linux/ipc_namespace.h>
70558 +#include <linux/grsecurity.h>
70559 +#include <linux/grinternal.h>
70560 +
70561 +int
70562 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
70563 +{
70564 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70565 + int write = (requested_mode & 00002);
70566 +
70567 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
70568 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
70569 + return 0;
70570 + }
70571 +#endif
70572 + return 1;
70573 +}
70574 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
70575 new file mode 100644
70576 index 0000000..5e05e20
70577 --- /dev/null
70578 +++ b/grsecurity/grsec_link.c
70579 @@ -0,0 +1,58 @@
70580 +#include <linux/kernel.h>
70581 +#include <linux/sched.h>
70582 +#include <linux/fs.h>
70583 +#include <linux/file.h>
70584 +#include <linux/grinternal.h>
70585 +
70586 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
70587 +{
70588 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70589 + const struct inode *link_inode = link->dentry->d_inode;
70590 +
70591 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
70592 + /* ignore root-owned links, e.g. /proc/self */
70593 + gr_is_global_nonroot(link_inode->i_uid) && target &&
70594 + !uid_eq(link_inode->i_uid, target->i_uid)) {
70595 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
70596 + return 1;
70597 + }
70598 +#endif
70599 + return 0;
70600 +}
70601 +
70602 +int
70603 +gr_handle_follow_link(const struct inode *parent,
70604 + const struct inode *inode,
70605 + const struct dentry *dentry, const struct vfsmount *mnt)
70606 +{
70607 +#ifdef CONFIG_GRKERNSEC_LINK
70608 + const struct cred *cred = current_cred();
70609 +
70610 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
70611 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
70612 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
70613 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
70614 + return -EACCES;
70615 + }
70616 +#endif
70617 + return 0;
70618 +}
70619 +
70620 +int
70621 +gr_handle_hardlink(const struct dentry *dentry,
70622 + const struct vfsmount *mnt,
70623 + struct inode *inode, const int mode, const struct filename *to)
70624 +{
70625 +#ifdef CONFIG_GRKERNSEC_LINK
70626 + const struct cred *cred = current_cred();
70627 +
70628 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
70629 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
70630 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
70631 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
70632 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
70633 + return -EPERM;
70634 + }
70635 +#endif
70636 + return 0;
70637 +}
70638 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
70639 new file mode 100644
70640 index 0000000..dbe0a6b
70641 --- /dev/null
70642 +++ b/grsecurity/grsec_log.c
70643 @@ -0,0 +1,341 @@
70644 +#include <linux/kernel.h>
70645 +#include <linux/sched.h>
70646 +#include <linux/file.h>
70647 +#include <linux/tty.h>
70648 +#include <linux/fs.h>
70649 +#include <linux/mm.h>
70650 +#include <linux/grinternal.h>
70651 +
70652 +#ifdef CONFIG_TREE_PREEMPT_RCU
70653 +#define DISABLE_PREEMPT() preempt_disable()
70654 +#define ENABLE_PREEMPT() preempt_enable()
70655 +#else
70656 +#define DISABLE_PREEMPT()
70657 +#define ENABLE_PREEMPT()
70658 +#endif
70659 +
70660 +#define BEGIN_LOCKS(x) \
70661 + DISABLE_PREEMPT(); \
70662 + rcu_read_lock(); \
70663 + read_lock(&tasklist_lock); \
70664 + read_lock(&grsec_exec_file_lock); \
70665 + if (x != GR_DO_AUDIT) \
70666 + spin_lock(&grsec_alert_lock); \
70667 + else \
70668 + spin_lock(&grsec_audit_lock)
70669 +
70670 +#define END_LOCKS(x) \
70671 + if (x != GR_DO_AUDIT) \
70672 + spin_unlock(&grsec_alert_lock); \
70673 + else \
70674 + spin_unlock(&grsec_audit_lock); \
70675 + read_unlock(&grsec_exec_file_lock); \
70676 + read_unlock(&tasklist_lock); \
70677 + rcu_read_unlock(); \
70678 + ENABLE_PREEMPT(); \
70679 + if (x == GR_DONT_AUDIT) \
70680 + gr_handle_alertkill(current)
70681 +
70682 +enum {
70683 + FLOODING,
70684 + NO_FLOODING
70685 +};
70686 +
70687 +extern char *gr_alert_log_fmt;
70688 +extern char *gr_audit_log_fmt;
70689 +extern char *gr_alert_log_buf;
70690 +extern char *gr_audit_log_buf;
70691 +
70692 +static int gr_log_start(int audit)
70693 +{
70694 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
70695 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
70696 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70697 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
70698 + unsigned long curr_secs = get_seconds();
70699 +
70700 + if (audit == GR_DO_AUDIT)
70701 + goto set_fmt;
70702 +
70703 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
70704 + grsec_alert_wtime = curr_secs;
70705 + grsec_alert_fyet = 0;
70706 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
70707 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
70708 + grsec_alert_fyet++;
70709 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
70710 + grsec_alert_wtime = curr_secs;
70711 + grsec_alert_fyet++;
70712 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
70713 + return FLOODING;
70714 + }
70715 + else return FLOODING;
70716 +
70717 +set_fmt:
70718 +#endif
70719 + memset(buf, 0, PAGE_SIZE);
70720 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
70721 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
70722 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70723 + } else if (current->signal->curr_ip) {
70724 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
70725 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
70726 + } else if (gr_acl_is_enabled()) {
70727 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
70728 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70729 + } else {
70730 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
70731 + strcpy(buf, fmt);
70732 + }
70733 +
70734 + return NO_FLOODING;
70735 +}
70736 +
70737 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70738 + __attribute__ ((format (printf, 2, 0)));
70739 +
70740 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70741 +{
70742 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70743 + unsigned int len = strlen(buf);
70744 +
70745 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70746 +
70747 + return;
70748 +}
70749 +
70750 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70751 + __attribute__ ((format (printf, 2, 3)));
70752 +
70753 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70754 +{
70755 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70756 + unsigned int len = strlen(buf);
70757 + va_list ap;
70758 +
70759 + va_start(ap, msg);
70760 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70761 + va_end(ap);
70762 +
70763 + return;
70764 +}
70765 +
70766 +static void gr_log_end(int audit, int append_default)
70767 +{
70768 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70769 + if (append_default) {
70770 + struct task_struct *task = current;
70771 + struct task_struct *parent = task->real_parent;
70772 + const struct cred *cred = __task_cred(task);
70773 + const struct cred *pcred = __task_cred(parent);
70774 + unsigned int len = strlen(buf);
70775 +
70776 + 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));
70777 + }
70778 +
70779 + printk("%s\n", buf);
70780 +
70781 + return;
70782 +}
70783 +
70784 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70785 +{
70786 + int logtype;
70787 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70788 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70789 + void *voidptr = NULL;
70790 + int num1 = 0, num2 = 0;
70791 + unsigned long ulong1 = 0, ulong2 = 0;
70792 + struct dentry *dentry = NULL;
70793 + struct vfsmount *mnt = NULL;
70794 + struct file *file = NULL;
70795 + struct task_struct *task = NULL;
70796 + struct vm_area_struct *vma = NULL;
70797 + const struct cred *cred, *pcred;
70798 + va_list ap;
70799 +
70800 + BEGIN_LOCKS(audit);
70801 + logtype = gr_log_start(audit);
70802 + if (logtype == FLOODING) {
70803 + END_LOCKS(audit);
70804 + return;
70805 + }
70806 + va_start(ap, argtypes);
70807 + switch (argtypes) {
70808 + case GR_TTYSNIFF:
70809 + task = va_arg(ap, struct task_struct *);
70810 + 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));
70811 + break;
70812 + case GR_SYSCTL_HIDDEN:
70813 + str1 = va_arg(ap, char *);
70814 + gr_log_middle_varargs(audit, msg, result, str1);
70815 + break;
70816 + case GR_RBAC:
70817 + dentry = va_arg(ap, struct dentry *);
70818 + mnt = va_arg(ap, struct vfsmount *);
70819 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70820 + break;
70821 + case GR_RBAC_STR:
70822 + dentry = va_arg(ap, struct dentry *);
70823 + mnt = va_arg(ap, struct vfsmount *);
70824 + str1 = va_arg(ap, char *);
70825 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70826 + break;
70827 + case GR_STR_RBAC:
70828 + str1 = va_arg(ap, char *);
70829 + dentry = va_arg(ap, struct dentry *);
70830 + mnt = va_arg(ap, struct vfsmount *);
70831 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70832 + break;
70833 + case GR_RBAC_MODE2:
70834 + dentry = va_arg(ap, struct dentry *);
70835 + mnt = va_arg(ap, struct vfsmount *);
70836 + str1 = va_arg(ap, char *);
70837 + str2 = va_arg(ap, char *);
70838 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70839 + break;
70840 + case GR_RBAC_MODE3:
70841 + dentry = va_arg(ap, struct dentry *);
70842 + mnt = va_arg(ap, struct vfsmount *);
70843 + str1 = va_arg(ap, char *);
70844 + str2 = va_arg(ap, char *);
70845 + str3 = va_arg(ap, char *);
70846 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70847 + break;
70848 + case GR_FILENAME:
70849 + dentry = va_arg(ap, struct dentry *);
70850 + mnt = va_arg(ap, struct vfsmount *);
70851 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70852 + break;
70853 + case GR_STR_FILENAME:
70854 + str1 = va_arg(ap, char *);
70855 + dentry = va_arg(ap, struct dentry *);
70856 + mnt = va_arg(ap, struct vfsmount *);
70857 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70858 + break;
70859 + case GR_FILENAME_STR:
70860 + dentry = va_arg(ap, struct dentry *);
70861 + mnt = va_arg(ap, struct vfsmount *);
70862 + str1 = va_arg(ap, char *);
70863 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70864 + break;
70865 + case GR_FILENAME_TWO_INT:
70866 + dentry = va_arg(ap, struct dentry *);
70867 + mnt = va_arg(ap, struct vfsmount *);
70868 + num1 = va_arg(ap, int);
70869 + num2 = va_arg(ap, int);
70870 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70871 + break;
70872 + case GR_FILENAME_TWO_INT_STR:
70873 + dentry = va_arg(ap, struct dentry *);
70874 + mnt = va_arg(ap, struct vfsmount *);
70875 + num1 = va_arg(ap, int);
70876 + num2 = va_arg(ap, int);
70877 + str1 = va_arg(ap, char *);
70878 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70879 + break;
70880 + case GR_TEXTREL:
70881 + file = va_arg(ap, struct file *);
70882 + ulong1 = va_arg(ap, unsigned long);
70883 + ulong2 = va_arg(ap, unsigned long);
70884 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70885 + break;
70886 + case GR_PTRACE:
70887 + task = va_arg(ap, struct task_struct *);
70888 + 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));
70889 + break;
70890 + case GR_RESOURCE:
70891 + task = va_arg(ap, struct task_struct *);
70892 + cred = __task_cred(task);
70893 + pcred = __task_cred(task->real_parent);
70894 + ulong1 = va_arg(ap, unsigned long);
70895 + str1 = va_arg(ap, char *);
70896 + ulong2 = va_arg(ap, unsigned long);
70897 + 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));
70898 + break;
70899 + case GR_CAP:
70900 + task = va_arg(ap, struct task_struct *);
70901 + cred = __task_cred(task);
70902 + pcred = __task_cred(task->real_parent);
70903 + str1 = va_arg(ap, char *);
70904 + 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));
70905 + break;
70906 + case GR_SIG:
70907 + str1 = va_arg(ap, char *);
70908 + voidptr = va_arg(ap, void *);
70909 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70910 + break;
70911 + case GR_SIG2:
70912 + task = va_arg(ap, struct task_struct *);
70913 + cred = __task_cred(task);
70914 + pcred = __task_cred(task->real_parent);
70915 + num1 = va_arg(ap, int);
70916 + 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));
70917 + break;
70918 + case GR_CRASH1:
70919 + task = va_arg(ap, struct task_struct *);
70920 + cred = __task_cred(task);
70921 + pcred = __task_cred(task->real_parent);
70922 + ulong1 = va_arg(ap, unsigned long);
70923 + 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);
70924 + break;
70925 + case GR_CRASH2:
70926 + task = va_arg(ap, struct task_struct *);
70927 + cred = __task_cred(task);
70928 + pcred = __task_cred(task->real_parent);
70929 + ulong1 = va_arg(ap, unsigned long);
70930 + 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);
70931 + break;
70932 + case GR_RWXMAP:
70933 + file = va_arg(ap, struct file *);
70934 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70935 + break;
70936 + case GR_RWXMAPVMA:
70937 + vma = va_arg(ap, struct vm_area_struct *);
70938 + if (vma->vm_file)
70939 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70940 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70941 + str1 = "<stack>";
70942 + else if (vma->vm_start <= current->mm->brk &&
70943 + vma->vm_end >= current->mm->start_brk)
70944 + str1 = "<heap>";
70945 + else
70946 + str1 = "<anonymous mapping>";
70947 + gr_log_middle_varargs(audit, msg, str1);
70948 + break;
70949 + case GR_PSACCT:
70950 + {
70951 + unsigned int wday, cday;
70952 + __u8 whr, chr;
70953 + __u8 wmin, cmin;
70954 + __u8 wsec, csec;
70955 + char cur_tty[64] = { 0 };
70956 + char parent_tty[64] = { 0 };
70957 +
70958 + task = va_arg(ap, struct task_struct *);
70959 + wday = va_arg(ap, unsigned int);
70960 + cday = va_arg(ap, unsigned int);
70961 + whr = va_arg(ap, int);
70962 + chr = va_arg(ap, int);
70963 + wmin = va_arg(ap, int);
70964 + cmin = va_arg(ap, int);
70965 + wsec = va_arg(ap, int);
70966 + csec = va_arg(ap, int);
70967 + ulong1 = va_arg(ap, unsigned long);
70968 + cred = __task_cred(task);
70969 + pcred = __task_cred(task->real_parent);
70970 +
70971 + 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));
70972 + }
70973 + break;
70974 + default:
70975 + gr_log_middle(audit, msg, ap);
70976 + }
70977 + va_end(ap);
70978 + // these don't need DEFAULTSECARGS printed on the end
70979 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70980 + gr_log_end(audit, 0);
70981 + else
70982 + gr_log_end(audit, 1);
70983 + END_LOCKS(audit);
70984 +}
70985 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70986 new file mode 100644
70987 index 0000000..f536303
70988 --- /dev/null
70989 +++ b/grsecurity/grsec_mem.c
70990 @@ -0,0 +1,40 @@
70991 +#include <linux/kernel.h>
70992 +#include <linux/sched.h>
70993 +#include <linux/mm.h>
70994 +#include <linux/mman.h>
70995 +#include <linux/grinternal.h>
70996 +
70997 +void
70998 +gr_handle_ioperm(void)
70999 +{
71000 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
71001 + return;
71002 +}
71003 +
71004 +void
71005 +gr_handle_iopl(void)
71006 +{
71007 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
71008 + return;
71009 +}
71010 +
71011 +void
71012 +gr_handle_mem_readwrite(u64 from, u64 to)
71013 +{
71014 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
71015 + return;
71016 +}
71017 +
71018 +void
71019 +gr_handle_vm86(void)
71020 +{
71021 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
71022 + return;
71023 +}
71024 +
71025 +void
71026 +gr_log_badprocpid(const char *entry)
71027 +{
71028 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
71029 + return;
71030 +}
71031 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
71032 new file mode 100644
71033 index 0000000..2131422
71034 --- /dev/null
71035 +++ b/grsecurity/grsec_mount.c
71036 @@ -0,0 +1,62 @@
71037 +#include <linux/kernel.h>
71038 +#include <linux/sched.h>
71039 +#include <linux/mount.h>
71040 +#include <linux/grsecurity.h>
71041 +#include <linux/grinternal.h>
71042 +
71043 +void
71044 +gr_log_remount(const char *devname, const int retval)
71045 +{
71046 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71047 + if (grsec_enable_mount && (retval >= 0))
71048 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
71049 +#endif
71050 + return;
71051 +}
71052 +
71053 +void
71054 +gr_log_unmount(const char *devname, const int retval)
71055 +{
71056 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71057 + if (grsec_enable_mount && (retval >= 0))
71058 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
71059 +#endif
71060 + return;
71061 +}
71062 +
71063 +void
71064 +gr_log_mount(const char *from, const char *to, const int retval)
71065 +{
71066 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71067 + if (grsec_enable_mount && (retval >= 0))
71068 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
71069 +#endif
71070 + return;
71071 +}
71072 +
71073 +int
71074 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
71075 +{
71076 +#ifdef CONFIG_GRKERNSEC_ROFS
71077 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
71078 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
71079 + return -EPERM;
71080 + } else
71081 + return 0;
71082 +#endif
71083 + return 0;
71084 +}
71085 +
71086 +int
71087 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
71088 +{
71089 +#ifdef CONFIG_GRKERNSEC_ROFS
71090 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
71091 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
71092 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
71093 + return -EPERM;
71094 + } else
71095 + return 0;
71096 +#endif
71097 + return 0;
71098 +}
71099 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
71100 new file mode 100644
71101 index 0000000..6ee9d50
71102 --- /dev/null
71103 +++ b/grsecurity/grsec_pax.c
71104 @@ -0,0 +1,45 @@
71105 +#include <linux/kernel.h>
71106 +#include <linux/sched.h>
71107 +#include <linux/mm.h>
71108 +#include <linux/file.h>
71109 +#include <linux/grinternal.h>
71110 +#include <linux/grsecurity.h>
71111 +
71112 +void
71113 +gr_log_textrel(struct vm_area_struct * vma)
71114 +{
71115 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71116 + if (grsec_enable_log_rwxmaps)
71117 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
71118 +#endif
71119 + return;
71120 +}
71121 +
71122 +void gr_log_ptgnustack(struct file *file)
71123 +{
71124 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71125 + if (grsec_enable_log_rwxmaps)
71126 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
71127 +#endif
71128 + return;
71129 +}
71130 +
71131 +void
71132 +gr_log_rwxmmap(struct file *file)
71133 +{
71134 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71135 + if (grsec_enable_log_rwxmaps)
71136 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
71137 +#endif
71138 + return;
71139 +}
71140 +
71141 +void
71142 +gr_log_rwxmprotect(struct vm_area_struct *vma)
71143 +{
71144 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71145 + if (grsec_enable_log_rwxmaps)
71146 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
71147 +#endif
71148 + return;
71149 +}
71150 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
71151 new file mode 100644
71152 index 0000000..f7f29aa
71153 --- /dev/null
71154 +++ b/grsecurity/grsec_ptrace.c
71155 @@ -0,0 +1,30 @@
71156 +#include <linux/kernel.h>
71157 +#include <linux/sched.h>
71158 +#include <linux/grinternal.h>
71159 +#include <linux/security.h>
71160 +
71161 +void
71162 +gr_audit_ptrace(struct task_struct *task)
71163 +{
71164 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71165 + if (grsec_enable_audit_ptrace)
71166 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
71167 +#endif
71168 + return;
71169 +}
71170 +
71171 +int
71172 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
71173 +{
71174 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71175 + const struct dentry *dentry = file->f_path.dentry;
71176 + const struct vfsmount *mnt = file->f_path.mnt;
71177 +
71178 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
71179 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
71180 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
71181 + return -EACCES;
71182 + }
71183 +#endif
71184 + return 0;
71185 +}
71186 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
71187 new file mode 100644
71188 index 0000000..4e29cc7
71189 --- /dev/null
71190 +++ b/grsecurity/grsec_sig.c
71191 @@ -0,0 +1,246 @@
71192 +#include <linux/kernel.h>
71193 +#include <linux/sched.h>
71194 +#include <linux/fs.h>
71195 +#include <linux/delay.h>
71196 +#include <linux/grsecurity.h>
71197 +#include <linux/grinternal.h>
71198 +#include <linux/hardirq.h>
71199 +
71200 +char *signames[] = {
71201 + [SIGSEGV] = "Segmentation fault",
71202 + [SIGILL] = "Illegal instruction",
71203 + [SIGABRT] = "Abort",
71204 + [SIGBUS] = "Invalid alignment/Bus error"
71205 +};
71206 +
71207 +void
71208 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
71209 +{
71210 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71211 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
71212 + (sig == SIGABRT) || (sig == SIGBUS))) {
71213 + if (task_pid_nr(t) == task_pid_nr(current)) {
71214 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
71215 + } else {
71216 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
71217 + }
71218 + }
71219 +#endif
71220 + return;
71221 +}
71222 +
71223 +int
71224 +gr_handle_signal(const struct task_struct *p, const int sig)
71225 +{
71226 +#ifdef CONFIG_GRKERNSEC
71227 + /* ignore the 0 signal for protected task checks */
71228 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
71229 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
71230 + return -EPERM;
71231 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
71232 + return -EPERM;
71233 + }
71234 +#endif
71235 + return 0;
71236 +}
71237 +
71238 +#ifdef CONFIG_GRKERNSEC
71239 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
71240 +
71241 +int gr_fake_force_sig(int sig, struct task_struct *t)
71242 +{
71243 + unsigned long int flags;
71244 + int ret, blocked, ignored;
71245 + struct k_sigaction *action;
71246 +
71247 + spin_lock_irqsave(&t->sighand->siglock, flags);
71248 + action = &t->sighand->action[sig-1];
71249 + ignored = action->sa.sa_handler == SIG_IGN;
71250 + blocked = sigismember(&t->blocked, sig);
71251 + if (blocked || ignored) {
71252 + action->sa.sa_handler = SIG_DFL;
71253 + if (blocked) {
71254 + sigdelset(&t->blocked, sig);
71255 + recalc_sigpending_and_wake(t);
71256 + }
71257 + }
71258 + if (action->sa.sa_handler == SIG_DFL)
71259 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
71260 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
71261 +
71262 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
71263 +
71264 + return ret;
71265 +}
71266 +#endif
71267 +
71268 +#ifdef CONFIG_GRKERNSEC_BRUTE
71269 +#define GR_USER_BAN_TIME (15 * 60)
71270 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
71271 +
71272 +static int __get_dumpable(unsigned long mm_flags)
71273 +{
71274 + int ret;
71275 +
71276 + ret = mm_flags & MMF_DUMPABLE_MASK;
71277 + return (ret >= 2) ? 2 : ret;
71278 +}
71279 +#endif
71280 +
71281 +void gr_handle_brute_attach(unsigned long mm_flags)
71282 +{
71283 +#ifdef CONFIG_GRKERNSEC_BRUTE
71284 + struct task_struct *p = current;
71285 + kuid_t uid = GLOBAL_ROOT_UID;
71286 + int daemon = 0;
71287 +
71288 + if (!grsec_enable_brute)
71289 + return;
71290 +
71291 + rcu_read_lock();
71292 + read_lock(&tasklist_lock);
71293 + read_lock(&grsec_exec_file_lock);
71294 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
71295 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
71296 + p->real_parent->brute = 1;
71297 + daemon = 1;
71298 + } else {
71299 + const struct cred *cred = __task_cred(p), *cred2;
71300 + struct task_struct *tsk, *tsk2;
71301 +
71302 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
71303 + struct user_struct *user;
71304 +
71305 + uid = cred->uid;
71306 +
71307 + /* this is put upon execution past expiration */
71308 + user = find_user(uid);
71309 + if (user == NULL)
71310 + goto unlock;
71311 + user->suid_banned = 1;
71312 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
71313 + if (user->suid_ban_expires == ~0UL)
71314 + user->suid_ban_expires--;
71315 +
71316 + /* only kill other threads of the same binary, from the same user */
71317 + do_each_thread(tsk2, tsk) {
71318 + cred2 = __task_cred(tsk);
71319 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
71320 + gr_fake_force_sig(SIGKILL, tsk);
71321 + } while_each_thread(tsk2, tsk);
71322 + }
71323 + }
71324 +unlock:
71325 + read_unlock(&grsec_exec_file_lock);
71326 + read_unlock(&tasklist_lock);
71327 + rcu_read_unlock();
71328 +
71329 + if (gr_is_global_nonroot(uid))
71330 + 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);
71331 + else if (daemon)
71332 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
71333 +
71334 +#endif
71335 + return;
71336 +}
71337 +
71338 +void gr_handle_brute_check(void)
71339 +{
71340 +#ifdef CONFIG_GRKERNSEC_BRUTE
71341 + struct task_struct *p = current;
71342 +
71343 + if (unlikely(p->brute)) {
71344 + if (!grsec_enable_brute)
71345 + p->brute = 0;
71346 + else if (time_before(get_seconds(), p->brute_expires))
71347 + msleep(30 * 1000);
71348 + }
71349 +#endif
71350 + return;
71351 +}
71352 +
71353 +void gr_handle_kernel_exploit(void)
71354 +{
71355 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71356 + const struct cred *cred;
71357 + struct task_struct *tsk, *tsk2;
71358 + struct user_struct *user;
71359 + kuid_t uid;
71360 +
71361 + if (in_irq() || in_serving_softirq() || in_nmi())
71362 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
71363 +
71364 + uid = current_uid();
71365 +
71366 + if (gr_is_global_root(uid))
71367 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
71368 + else {
71369 + /* kill all the processes of this user, hold a reference
71370 + to their creds struct, and prevent them from creating
71371 + another process until system reset
71372 + */
71373 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
71374 + GR_GLOBAL_UID(uid));
71375 + /* we intentionally leak this ref */
71376 + user = get_uid(current->cred->user);
71377 + if (user)
71378 + user->kernel_banned = 1;
71379 +
71380 + /* kill all processes of this user */
71381 + read_lock(&tasklist_lock);
71382 + do_each_thread(tsk2, tsk) {
71383 + cred = __task_cred(tsk);
71384 + if (uid_eq(cred->uid, uid))
71385 + gr_fake_force_sig(SIGKILL, tsk);
71386 + } while_each_thread(tsk2, tsk);
71387 + read_unlock(&tasklist_lock);
71388 + }
71389 +#endif
71390 +}
71391 +
71392 +#ifdef CONFIG_GRKERNSEC_BRUTE
71393 +static bool suid_ban_expired(struct user_struct *user)
71394 +{
71395 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
71396 + user->suid_banned = 0;
71397 + user->suid_ban_expires = 0;
71398 + free_uid(user);
71399 + return true;
71400 + }
71401 +
71402 + return false;
71403 +}
71404 +#endif
71405 +
71406 +int gr_process_kernel_exec_ban(void)
71407 +{
71408 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71409 + if (unlikely(current->cred->user->kernel_banned))
71410 + return -EPERM;
71411 +#endif
71412 + return 0;
71413 +}
71414 +
71415 +int gr_process_kernel_setuid_ban(struct user_struct *user)
71416 +{
71417 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71418 + if (unlikely(user->kernel_banned))
71419 + gr_fake_force_sig(SIGKILL, current);
71420 +#endif
71421 + return 0;
71422 +}
71423 +
71424 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
71425 +{
71426 +#ifdef CONFIG_GRKERNSEC_BRUTE
71427 + struct user_struct *user = current->cred->user;
71428 + if (unlikely(user->suid_banned)) {
71429 + if (suid_ban_expired(user))
71430 + return 0;
71431 + /* disallow execution of suid binaries only */
71432 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
71433 + return -EPERM;
71434 + }
71435 +#endif
71436 + return 0;
71437 +}
71438 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
71439 new file mode 100644
71440 index 0000000..4030d57
71441 --- /dev/null
71442 +++ b/grsecurity/grsec_sock.c
71443 @@ -0,0 +1,244 @@
71444 +#include <linux/kernel.h>
71445 +#include <linux/module.h>
71446 +#include <linux/sched.h>
71447 +#include <linux/file.h>
71448 +#include <linux/net.h>
71449 +#include <linux/in.h>
71450 +#include <linux/ip.h>
71451 +#include <net/sock.h>
71452 +#include <net/inet_sock.h>
71453 +#include <linux/grsecurity.h>
71454 +#include <linux/grinternal.h>
71455 +#include <linux/gracl.h>
71456 +
71457 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
71458 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
71459 +
71460 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
71461 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
71462 +
71463 +#ifdef CONFIG_UNIX_MODULE
71464 +EXPORT_SYMBOL(gr_acl_handle_unix);
71465 +EXPORT_SYMBOL(gr_acl_handle_mknod);
71466 +EXPORT_SYMBOL(gr_handle_chroot_unix);
71467 +EXPORT_SYMBOL(gr_handle_create);
71468 +#endif
71469 +
71470 +#ifdef CONFIG_GRKERNSEC
71471 +#define gr_conn_table_size 32749
71472 +struct conn_table_entry {
71473 + struct conn_table_entry *next;
71474 + struct signal_struct *sig;
71475 +};
71476 +
71477 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
71478 +DEFINE_SPINLOCK(gr_conn_table_lock);
71479 +
71480 +extern const char * gr_socktype_to_name(unsigned char type);
71481 +extern const char * gr_proto_to_name(unsigned char proto);
71482 +extern const char * gr_sockfamily_to_name(unsigned char family);
71483 +
71484 +static __inline__ int
71485 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
71486 +{
71487 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
71488 +}
71489 +
71490 +static __inline__ int
71491 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
71492 + __u16 sport, __u16 dport)
71493 +{
71494 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
71495 + sig->gr_sport == sport && sig->gr_dport == dport))
71496 + return 1;
71497 + else
71498 + return 0;
71499 +}
71500 +
71501 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
71502 +{
71503 + struct conn_table_entry **match;
71504 + unsigned int index;
71505 +
71506 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71507 + sig->gr_sport, sig->gr_dport,
71508 + gr_conn_table_size);
71509 +
71510 + newent->sig = sig;
71511 +
71512 + match = &gr_conn_table[index];
71513 + newent->next = *match;
71514 + *match = newent;
71515 +
71516 + return;
71517 +}
71518 +
71519 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
71520 +{
71521 + struct conn_table_entry *match, *last = NULL;
71522 + unsigned int index;
71523 +
71524 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71525 + sig->gr_sport, sig->gr_dport,
71526 + gr_conn_table_size);
71527 +
71528 + match = gr_conn_table[index];
71529 + while (match && !conn_match(match->sig,
71530 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
71531 + sig->gr_dport)) {
71532 + last = match;
71533 + match = match->next;
71534 + }
71535 +
71536 + if (match) {
71537 + if (last)
71538 + last->next = match->next;
71539 + else
71540 + gr_conn_table[index] = NULL;
71541 + kfree(match);
71542 + }
71543 +
71544 + return;
71545 +}
71546 +
71547 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
71548 + __u16 sport, __u16 dport)
71549 +{
71550 + struct conn_table_entry *match;
71551 + unsigned int index;
71552 +
71553 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
71554 +
71555 + match = gr_conn_table[index];
71556 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
71557 + match = match->next;
71558 +
71559 + if (match)
71560 + return match->sig;
71561 + else
71562 + return NULL;
71563 +}
71564 +
71565 +#endif
71566 +
71567 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
71568 +{
71569 +#ifdef CONFIG_GRKERNSEC
71570 + struct signal_struct *sig = task->signal;
71571 + struct conn_table_entry *newent;
71572 +
71573 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
71574 + if (newent == NULL)
71575 + return;
71576 + /* no bh lock needed since we are called with bh disabled */
71577 + spin_lock(&gr_conn_table_lock);
71578 + gr_del_task_from_ip_table_nolock(sig);
71579 + sig->gr_saddr = inet->inet_rcv_saddr;
71580 + sig->gr_daddr = inet->inet_daddr;
71581 + sig->gr_sport = inet->inet_sport;
71582 + sig->gr_dport = inet->inet_dport;
71583 + gr_add_to_task_ip_table_nolock(sig, newent);
71584 + spin_unlock(&gr_conn_table_lock);
71585 +#endif
71586 + return;
71587 +}
71588 +
71589 +void gr_del_task_from_ip_table(struct task_struct *task)
71590 +{
71591 +#ifdef CONFIG_GRKERNSEC
71592 + spin_lock_bh(&gr_conn_table_lock);
71593 + gr_del_task_from_ip_table_nolock(task->signal);
71594 + spin_unlock_bh(&gr_conn_table_lock);
71595 +#endif
71596 + return;
71597 +}
71598 +
71599 +void
71600 +gr_attach_curr_ip(const struct sock *sk)
71601 +{
71602 +#ifdef CONFIG_GRKERNSEC
71603 + struct signal_struct *p, *set;
71604 + const struct inet_sock *inet = inet_sk(sk);
71605 +
71606 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
71607 + return;
71608 +
71609 + set = current->signal;
71610 +
71611 + spin_lock_bh(&gr_conn_table_lock);
71612 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
71613 + inet->inet_dport, inet->inet_sport);
71614 + if (unlikely(p != NULL)) {
71615 + set->curr_ip = p->curr_ip;
71616 + set->used_accept = 1;
71617 + gr_del_task_from_ip_table_nolock(p);
71618 + spin_unlock_bh(&gr_conn_table_lock);
71619 + return;
71620 + }
71621 + spin_unlock_bh(&gr_conn_table_lock);
71622 +
71623 + set->curr_ip = inet->inet_daddr;
71624 + set->used_accept = 1;
71625 +#endif
71626 + return;
71627 +}
71628 +
71629 +int
71630 +gr_handle_sock_all(const int family, const int type, const int protocol)
71631 +{
71632 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71633 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
71634 + (family != AF_UNIX)) {
71635 + if (family == AF_INET)
71636 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
71637 + else
71638 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
71639 + return -EACCES;
71640 + }
71641 +#endif
71642 + return 0;
71643 +}
71644 +
71645 +int
71646 +gr_handle_sock_server(const struct sockaddr *sck)
71647 +{
71648 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71649 + if (grsec_enable_socket_server &&
71650 + in_group_p(grsec_socket_server_gid) &&
71651 + sck && (sck->sa_family != AF_UNIX) &&
71652 + (sck->sa_family != AF_LOCAL)) {
71653 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71654 + return -EACCES;
71655 + }
71656 +#endif
71657 + return 0;
71658 +}
71659 +
71660 +int
71661 +gr_handle_sock_server_other(const struct sock *sck)
71662 +{
71663 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71664 + if (grsec_enable_socket_server &&
71665 + in_group_p(grsec_socket_server_gid) &&
71666 + sck && (sck->sk_family != AF_UNIX) &&
71667 + (sck->sk_family != AF_LOCAL)) {
71668 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71669 + return -EACCES;
71670 + }
71671 +#endif
71672 + return 0;
71673 +}
71674 +
71675 +int
71676 +gr_handle_sock_client(const struct sockaddr *sck)
71677 +{
71678 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71679 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
71680 + sck && (sck->sa_family != AF_UNIX) &&
71681 + (sck->sa_family != AF_LOCAL)) {
71682 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
71683 + return -EACCES;
71684 + }
71685 +#endif
71686 + return 0;
71687 +}
71688 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
71689 new file mode 100644
71690 index 0000000..8159888
71691 --- /dev/null
71692 +++ b/grsecurity/grsec_sysctl.c
71693 @@ -0,0 +1,479 @@
71694 +#include <linux/kernel.h>
71695 +#include <linux/sched.h>
71696 +#include <linux/sysctl.h>
71697 +#include <linux/grsecurity.h>
71698 +#include <linux/grinternal.h>
71699 +
71700 +int
71701 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
71702 +{
71703 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71704 + if (dirname == NULL || name == NULL)
71705 + return 0;
71706 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
71707 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
71708 + return -EACCES;
71709 + }
71710 +#endif
71711 + return 0;
71712 +}
71713 +
71714 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
71715 +static int __maybe_unused __read_only one = 1;
71716 +#endif
71717 +
71718 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
71719 + defined(CONFIG_GRKERNSEC_DENYUSB)
71720 +struct ctl_table grsecurity_table[] = {
71721 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71722 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
71723 +#ifdef CONFIG_GRKERNSEC_IO
71724 + {
71725 + .procname = "disable_priv_io",
71726 + .data = &grsec_disable_privio,
71727 + .maxlen = sizeof(int),
71728 + .mode = 0600,
71729 + .proc_handler = &proc_dointvec,
71730 + },
71731 +#endif
71732 +#endif
71733 +#ifdef CONFIG_GRKERNSEC_LINK
71734 + {
71735 + .procname = "linking_restrictions",
71736 + .data = &grsec_enable_link,
71737 + .maxlen = sizeof(int),
71738 + .mode = 0600,
71739 + .proc_handler = &proc_dointvec,
71740 + },
71741 +#endif
71742 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71743 + {
71744 + .procname = "enforce_symlinksifowner",
71745 + .data = &grsec_enable_symlinkown,
71746 + .maxlen = sizeof(int),
71747 + .mode = 0600,
71748 + .proc_handler = &proc_dointvec,
71749 + },
71750 + {
71751 + .procname = "symlinkown_gid",
71752 + .data = &grsec_symlinkown_gid,
71753 + .maxlen = sizeof(int),
71754 + .mode = 0600,
71755 + .proc_handler = &proc_dointvec,
71756 + },
71757 +#endif
71758 +#ifdef CONFIG_GRKERNSEC_BRUTE
71759 + {
71760 + .procname = "deter_bruteforce",
71761 + .data = &grsec_enable_brute,
71762 + .maxlen = sizeof(int),
71763 + .mode = 0600,
71764 + .proc_handler = &proc_dointvec,
71765 + },
71766 +#endif
71767 +#ifdef CONFIG_GRKERNSEC_FIFO
71768 + {
71769 + .procname = "fifo_restrictions",
71770 + .data = &grsec_enable_fifo,
71771 + .maxlen = sizeof(int),
71772 + .mode = 0600,
71773 + .proc_handler = &proc_dointvec,
71774 + },
71775 +#endif
71776 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71777 + {
71778 + .procname = "ptrace_readexec",
71779 + .data = &grsec_enable_ptrace_readexec,
71780 + .maxlen = sizeof(int),
71781 + .mode = 0600,
71782 + .proc_handler = &proc_dointvec,
71783 + },
71784 +#endif
71785 +#ifdef CONFIG_GRKERNSEC_SETXID
71786 + {
71787 + .procname = "consistent_setxid",
71788 + .data = &grsec_enable_setxid,
71789 + .maxlen = sizeof(int),
71790 + .mode = 0600,
71791 + .proc_handler = &proc_dointvec,
71792 + },
71793 +#endif
71794 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71795 + {
71796 + .procname = "ip_blackhole",
71797 + .data = &grsec_enable_blackhole,
71798 + .maxlen = sizeof(int),
71799 + .mode = 0600,
71800 + .proc_handler = &proc_dointvec,
71801 + },
71802 + {
71803 + .procname = "lastack_retries",
71804 + .data = &grsec_lastack_retries,
71805 + .maxlen = sizeof(int),
71806 + .mode = 0600,
71807 + .proc_handler = &proc_dointvec,
71808 + },
71809 +#endif
71810 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71811 + {
71812 + .procname = "exec_logging",
71813 + .data = &grsec_enable_execlog,
71814 + .maxlen = sizeof(int),
71815 + .mode = 0600,
71816 + .proc_handler = &proc_dointvec,
71817 + },
71818 +#endif
71819 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71820 + {
71821 + .procname = "rwxmap_logging",
71822 + .data = &grsec_enable_log_rwxmaps,
71823 + .maxlen = sizeof(int),
71824 + .mode = 0600,
71825 + .proc_handler = &proc_dointvec,
71826 + },
71827 +#endif
71828 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71829 + {
71830 + .procname = "signal_logging",
71831 + .data = &grsec_enable_signal,
71832 + .maxlen = sizeof(int),
71833 + .mode = 0600,
71834 + .proc_handler = &proc_dointvec,
71835 + },
71836 +#endif
71837 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71838 + {
71839 + .procname = "forkfail_logging",
71840 + .data = &grsec_enable_forkfail,
71841 + .maxlen = sizeof(int),
71842 + .mode = 0600,
71843 + .proc_handler = &proc_dointvec,
71844 + },
71845 +#endif
71846 +#ifdef CONFIG_GRKERNSEC_TIME
71847 + {
71848 + .procname = "timechange_logging",
71849 + .data = &grsec_enable_time,
71850 + .maxlen = sizeof(int),
71851 + .mode = 0600,
71852 + .proc_handler = &proc_dointvec,
71853 + },
71854 +#endif
71855 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71856 + {
71857 + .procname = "chroot_deny_shmat",
71858 + .data = &grsec_enable_chroot_shmat,
71859 + .maxlen = sizeof(int),
71860 + .mode = 0600,
71861 + .proc_handler = &proc_dointvec,
71862 + },
71863 +#endif
71864 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71865 + {
71866 + .procname = "chroot_deny_unix",
71867 + .data = &grsec_enable_chroot_unix,
71868 + .maxlen = sizeof(int),
71869 + .mode = 0600,
71870 + .proc_handler = &proc_dointvec,
71871 + },
71872 +#endif
71873 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71874 + {
71875 + .procname = "chroot_deny_mount",
71876 + .data = &grsec_enable_chroot_mount,
71877 + .maxlen = sizeof(int),
71878 + .mode = 0600,
71879 + .proc_handler = &proc_dointvec,
71880 + },
71881 +#endif
71882 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71883 + {
71884 + .procname = "chroot_deny_fchdir",
71885 + .data = &grsec_enable_chroot_fchdir,
71886 + .maxlen = sizeof(int),
71887 + .mode = 0600,
71888 + .proc_handler = &proc_dointvec,
71889 + },
71890 +#endif
71891 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71892 + {
71893 + .procname = "chroot_deny_chroot",
71894 + .data = &grsec_enable_chroot_double,
71895 + .maxlen = sizeof(int),
71896 + .mode = 0600,
71897 + .proc_handler = &proc_dointvec,
71898 + },
71899 +#endif
71900 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71901 + {
71902 + .procname = "chroot_deny_pivot",
71903 + .data = &grsec_enable_chroot_pivot,
71904 + .maxlen = sizeof(int),
71905 + .mode = 0600,
71906 + .proc_handler = &proc_dointvec,
71907 + },
71908 +#endif
71909 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71910 + {
71911 + .procname = "chroot_enforce_chdir",
71912 + .data = &grsec_enable_chroot_chdir,
71913 + .maxlen = sizeof(int),
71914 + .mode = 0600,
71915 + .proc_handler = &proc_dointvec,
71916 + },
71917 +#endif
71918 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71919 + {
71920 + .procname = "chroot_deny_chmod",
71921 + .data = &grsec_enable_chroot_chmod,
71922 + .maxlen = sizeof(int),
71923 + .mode = 0600,
71924 + .proc_handler = &proc_dointvec,
71925 + },
71926 +#endif
71927 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71928 + {
71929 + .procname = "chroot_deny_mknod",
71930 + .data = &grsec_enable_chroot_mknod,
71931 + .maxlen = sizeof(int),
71932 + .mode = 0600,
71933 + .proc_handler = &proc_dointvec,
71934 + },
71935 +#endif
71936 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71937 + {
71938 + .procname = "chroot_restrict_nice",
71939 + .data = &grsec_enable_chroot_nice,
71940 + .maxlen = sizeof(int),
71941 + .mode = 0600,
71942 + .proc_handler = &proc_dointvec,
71943 + },
71944 +#endif
71945 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71946 + {
71947 + .procname = "chroot_execlog",
71948 + .data = &grsec_enable_chroot_execlog,
71949 + .maxlen = sizeof(int),
71950 + .mode = 0600,
71951 + .proc_handler = &proc_dointvec,
71952 + },
71953 +#endif
71954 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71955 + {
71956 + .procname = "chroot_caps",
71957 + .data = &grsec_enable_chroot_caps,
71958 + .maxlen = sizeof(int),
71959 + .mode = 0600,
71960 + .proc_handler = &proc_dointvec,
71961 + },
71962 +#endif
71963 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71964 + {
71965 + .procname = "chroot_deny_sysctl",
71966 + .data = &grsec_enable_chroot_sysctl,
71967 + .maxlen = sizeof(int),
71968 + .mode = 0600,
71969 + .proc_handler = &proc_dointvec,
71970 + },
71971 +#endif
71972 +#ifdef CONFIG_GRKERNSEC_TPE
71973 + {
71974 + .procname = "tpe",
71975 + .data = &grsec_enable_tpe,
71976 + .maxlen = sizeof(int),
71977 + .mode = 0600,
71978 + .proc_handler = &proc_dointvec,
71979 + },
71980 + {
71981 + .procname = "tpe_gid",
71982 + .data = &grsec_tpe_gid,
71983 + .maxlen = sizeof(int),
71984 + .mode = 0600,
71985 + .proc_handler = &proc_dointvec,
71986 + },
71987 +#endif
71988 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71989 + {
71990 + .procname = "tpe_invert",
71991 + .data = &grsec_enable_tpe_invert,
71992 + .maxlen = sizeof(int),
71993 + .mode = 0600,
71994 + .proc_handler = &proc_dointvec,
71995 + },
71996 +#endif
71997 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71998 + {
71999 + .procname = "tpe_restrict_all",
72000 + .data = &grsec_enable_tpe_all,
72001 + .maxlen = sizeof(int),
72002 + .mode = 0600,
72003 + .proc_handler = &proc_dointvec,
72004 + },
72005 +#endif
72006 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72007 + {
72008 + .procname = "socket_all",
72009 + .data = &grsec_enable_socket_all,
72010 + .maxlen = sizeof(int),
72011 + .mode = 0600,
72012 + .proc_handler = &proc_dointvec,
72013 + },
72014 + {
72015 + .procname = "socket_all_gid",
72016 + .data = &grsec_socket_all_gid,
72017 + .maxlen = sizeof(int),
72018 + .mode = 0600,
72019 + .proc_handler = &proc_dointvec,
72020 + },
72021 +#endif
72022 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72023 + {
72024 + .procname = "socket_client",
72025 + .data = &grsec_enable_socket_client,
72026 + .maxlen = sizeof(int),
72027 + .mode = 0600,
72028 + .proc_handler = &proc_dointvec,
72029 + },
72030 + {
72031 + .procname = "socket_client_gid",
72032 + .data = &grsec_socket_client_gid,
72033 + .maxlen = sizeof(int),
72034 + .mode = 0600,
72035 + .proc_handler = &proc_dointvec,
72036 + },
72037 +#endif
72038 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72039 + {
72040 + .procname = "socket_server",
72041 + .data = &grsec_enable_socket_server,
72042 + .maxlen = sizeof(int),
72043 + .mode = 0600,
72044 + .proc_handler = &proc_dointvec,
72045 + },
72046 + {
72047 + .procname = "socket_server_gid",
72048 + .data = &grsec_socket_server_gid,
72049 + .maxlen = sizeof(int),
72050 + .mode = 0600,
72051 + .proc_handler = &proc_dointvec,
72052 + },
72053 +#endif
72054 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
72055 + {
72056 + .procname = "audit_group",
72057 + .data = &grsec_enable_group,
72058 + .maxlen = sizeof(int),
72059 + .mode = 0600,
72060 + .proc_handler = &proc_dointvec,
72061 + },
72062 + {
72063 + .procname = "audit_gid",
72064 + .data = &grsec_audit_gid,
72065 + .maxlen = sizeof(int),
72066 + .mode = 0600,
72067 + .proc_handler = &proc_dointvec,
72068 + },
72069 +#endif
72070 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
72071 + {
72072 + .procname = "audit_chdir",
72073 + .data = &grsec_enable_chdir,
72074 + .maxlen = sizeof(int),
72075 + .mode = 0600,
72076 + .proc_handler = &proc_dointvec,
72077 + },
72078 +#endif
72079 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72080 + {
72081 + .procname = "audit_mount",
72082 + .data = &grsec_enable_mount,
72083 + .maxlen = sizeof(int),
72084 + .mode = 0600,
72085 + .proc_handler = &proc_dointvec,
72086 + },
72087 +#endif
72088 +#ifdef CONFIG_GRKERNSEC_DMESG
72089 + {
72090 + .procname = "dmesg",
72091 + .data = &grsec_enable_dmesg,
72092 + .maxlen = sizeof(int),
72093 + .mode = 0600,
72094 + .proc_handler = &proc_dointvec,
72095 + },
72096 +#endif
72097 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72098 + {
72099 + .procname = "chroot_findtask",
72100 + .data = &grsec_enable_chroot_findtask,
72101 + .maxlen = sizeof(int),
72102 + .mode = 0600,
72103 + .proc_handler = &proc_dointvec,
72104 + },
72105 +#endif
72106 +#ifdef CONFIG_GRKERNSEC_RESLOG
72107 + {
72108 + .procname = "resource_logging",
72109 + .data = &grsec_resource_logging,
72110 + .maxlen = sizeof(int),
72111 + .mode = 0600,
72112 + .proc_handler = &proc_dointvec,
72113 + },
72114 +#endif
72115 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72116 + {
72117 + .procname = "audit_ptrace",
72118 + .data = &grsec_enable_audit_ptrace,
72119 + .maxlen = sizeof(int),
72120 + .mode = 0600,
72121 + .proc_handler = &proc_dointvec,
72122 + },
72123 +#endif
72124 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
72125 + {
72126 + .procname = "harden_ptrace",
72127 + .data = &grsec_enable_harden_ptrace,
72128 + .maxlen = sizeof(int),
72129 + .mode = 0600,
72130 + .proc_handler = &proc_dointvec,
72131 + },
72132 +#endif
72133 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
72134 + {
72135 + .procname = "harden_ipc",
72136 + .data = &grsec_enable_harden_ipc,
72137 + .maxlen = sizeof(int),
72138 + .mode = 0600,
72139 + .proc_handler = &proc_dointvec,
72140 + },
72141 +#endif
72142 + {
72143 + .procname = "grsec_lock",
72144 + .data = &grsec_lock,
72145 + .maxlen = sizeof(int),
72146 + .mode = 0600,
72147 + .proc_handler = &proc_dointvec,
72148 + },
72149 +#endif
72150 +#ifdef CONFIG_GRKERNSEC_ROFS
72151 + {
72152 + .procname = "romount_protect",
72153 + .data = &grsec_enable_rofs,
72154 + .maxlen = sizeof(int),
72155 + .mode = 0600,
72156 + .proc_handler = &proc_dointvec_minmax,
72157 + .extra1 = &one,
72158 + .extra2 = &one,
72159 + },
72160 +#endif
72161 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
72162 + {
72163 + .procname = "deny_new_usb",
72164 + .data = &grsec_deny_new_usb,
72165 + .maxlen = sizeof(int),
72166 + .mode = 0600,
72167 + .proc_handler = &proc_dointvec,
72168 + },
72169 +#endif
72170 + { }
72171 +};
72172 +#endif
72173 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
72174 new file mode 100644
72175 index 0000000..0dc13c3
72176 --- /dev/null
72177 +++ b/grsecurity/grsec_time.c
72178 @@ -0,0 +1,16 @@
72179 +#include <linux/kernel.h>
72180 +#include <linux/sched.h>
72181 +#include <linux/grinternal.h>
72182 +#include <linux/module.h>
72183 +
72184 +void
72185 +gr_log_timechange(void)
72186 +{
72187 +#ifdef CONFIG_GRKERNSEC_TIME
72188 + if (grsec_enable_time)
72189 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
72190 +#endif
72191 + return;
72192 +}
72193 +
72194 +EXPORT_SYMBOL(gr_log_timechange);
72195 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
72196 new file mode 100644
72197 index 0000000..ee57dcf
72198 --- /dev/null
72199 +++ b/grsecurity/grsec_tpe.c
72200 @@ -0,0 +1,73 @@
72201 +#include <linux/kernel.h>
72202 +#include <linux/sched.h>
72203 +#include <linux/file.h>
72204 +#include <linux/fs.h>
72205 +#include <linux/grinternal.h>
72206 +
72207 +extern int gr_acl_tpe_check(void);
72208 +
72209 +int
72210 +gr_tpe_allow(const struct file *file)
72211 +{
72212 +#ifdef CONFIG_GRKERNSEC
72213 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
72214 + const struct cred *cred = current_cred();
72215 + char *msg = NULL;
72216 + char *msg2 = NULL;
72217 +
72218 + // never restrict root
72219 + if (gr_is_global_root(cred->uid))
72220 + return 1;
72221 +
72222 + if (grsec_enable_tpe) {
72223 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72224 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
72225 + msg = "not being in trusted group";
72226 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
72227 + msg = "being in untrusted group";
72228 +#else
72229 + if (in_group_p(grsec_tpe_gid))
72230 + msg = "being in untrusted group";
72231 +#endif
72232 + }
72233 + if (!msg && gr_acl_tpe_check())
72234 + msg = "being in untrusted role";
72235 +
72236 + // not in any affected group/role
72237 + if (!msg)
72238 + goto next_check;
72239 +
72240 + if (gr_is_global_nonroot(inode->i_uid))
72241 + msg2 = "file in non-root-owned directory";
72242 + else if (inode->i_mode & S_IWOTH)
72243 + msg2 = "file in world-writable directory";
72244 + else if (inode->i_mode & S_IWGRP)
72245 + msg2 = "file in group-writable directory";
72246 +
72247 + if (msg && msg2) {
72248 + char fullmsg[70] = {0};
72249 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
72250 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
72251 + return 0;
72252 + }
72253 + msg = NULL;
72254 +next_check:
72255 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72256 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
72257 + return 1;
72258 +
72259 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
72260 + msg = "directory not owned by user";
72261 + else if (inode->i_mode & S_IWOTH)
72262 + msg = "file in world-writable directory";
72263 + else if (inode->i_mode & S_IWGRP)
72264 + msg = "file in group-writable directory";
72265 +
72266 + if (msg) {
72267 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
72268 + return 0;
72269 + }
72270 +#endif
72271 +#endif
72272 + return 1;
72273 +}
72274 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
72275 new file mode 100644
72276 index 0000000..ae02d8e
72277 --- /dev/null
72278 +++ b/grsecurity/grsec_usb.c
72279 @@ -0,0 +1,15 @@
72280 +#include <linux/kernel.h>
72281 +#include <linux/grinternal.h>
72282 +#include <linux/module.h>
72283 +
72284 +int gr_handle_new_usb(void)
72285 +{
72286 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72287 + if (grsec_deny_new_usb) {
72288 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
72289 + return 1;
72290 + }
72291 +#endif
72292 + return 0;
72293 +}
72294 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
72295 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
72296 new file mode 100644
72297 index 0000000..9f7b1ac
72298 --- /dev/null
72299 +++ b/grsecurity/grsum.c
72300 @@ -0,0 +1,61 @@
72301 +#include <linux/err.h>
72302 +#include <linux/kernel.h>
72303 +#include <linux/sched.h>
72304 +#include <linux/mm.h>
72305 +#include <linux/scatterlist.h>
72306 +#include <linux/crypto.h>
72307 +#include <linux/gracl.h>
72308 +
72309 +
72310 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
72311 +#error "crypto and sha256 must be built into the kernel"
72312 +#endif
72313 +
72314 +int
72315 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
72316 +{
72317 + char *p;
72318 + struct crypto_hash *tfm;
72319 + struct hash_desc desc;
72320 + struct scatterlist sg;
72321 + unsigned char temp_sum[GR_SHA_LEN];
72322 + volatile int retval = 0;
72323 + volatile int dummy = 0;
72324 + unsigned int i;
72325 +
72326 + sg_init_table(&sg, 1);
72327 +
72328 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
72329 + if (IS_ERR(tfm)) {
72330 + /* should never happen, since sha256 should be built in */
72331 + return 1;
72332 + }
72333 +
72334 + desc.tfm = tfm;
72335 + desc.flags = 0;
72336 +
72337 + crypto_hash_init(&desc);
72338 +
72339 + p = salt;
72340 + sg_set_buf(&sg, p, GR_SALT_LEN);
72341 + crypto_hash_update(&desc, &sg, sg.length);
72342 +
72343 + p = entry->pw;
72344 + sg_set_buf(&sg, p, strlen(p));
72345 +
72346 + crypto_hash_update(&desc, &sg, sg.length);
72347 +
72348 + crypto_hash_final(&desc, temp_sum);
72349 +
72350 + memset(entry->pw, 0, GR_PW_LEN);
72351 +
72352 + for (i = 0; i < GR_SHA_LEN; i++)
72353 + if (sum[i] != temp_sum[i])
72354 + retval = 1;
72355 + else
72356 + dummy = 1; // waste a cycle
72357 +
72358 + crypto_free_hash(tfm);
72359 +
72360 + return retval;
72361 +}
72362 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
72363 index 77ff547..181834f 100644
72364 --- a/include/asm-generic/4level-fixup.h
72365 +++ b/include/asm-generic/4level-fixup.h
72366 @@ -13,8 +13,10 @@
72367 #define pmd_alloc(mm, pud, address) \
72368 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
72369 NULL: pmd_offset(pud, address))
72370 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
72371
72372 #define pud_alloc(mm, pgd, address) (pgd)
72373 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
72374 #define pud_offset(pgd, start) (pgd)
72375 #define pud_none(pud) 0
72376 #define pud_bad(pud) 0
72377 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
72378 index b7babf0..04ad282 100644
72379 --- a/include/asm-generic/atomic-long.h
72380 +++ b/include/asm-generic/atomic-long.h
72381 @@ -22,6 +22,12 @@
72382
72383 typedef atomic64_t atomic_long_t;
72384
72385 +#ifdef CONFIG_PAX_REFCOUNT
72386 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
72387 +#else
72388 +typedef atomic64_t atomic_long_unchecked_t;
72389 +#endif
72390 +
72391 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
72392
72393 static inline long atomic_long_read(atomic_long_t *l)
72394 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72395 return (long)atomic64_read(v);
72396 }
72397
72398 +#ifdef CONFIG_PAX_REFCOUNT
72399 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72400 +{
72401 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72402 +
72403 + return (long)atomic64_read_unchecked(v);
72404 +}
72405 +#endif
72406 +
72407 static inline void atomic_long_set(atomic_long_t *l, long i)
72408 {
72409 atomic64_t *v = (atomic64_t *)l;
72410 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72411 atomic64_set(v, i);
72412 }
72413
72414 +#ifdef CONFIG_PAX_REFCOUNT
72415 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72416 +{
72417 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72418 +
72419 + atomic64_set_unchecked(v, i);
72420 +}
72421 +#endif
72422 +
72423 static inline void atomic_long_inc(atomic_long_t *l)
72424 {
72425 atomic64_t *v = (atomic64_t *)l;
72426 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72427 atomic64_inc(v);
72428 }
72429
72430 +#ifdef CONFIG_PAX_REFCOUNT
72431 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72432 +{
72433 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72434 +
72435 + atomic64_inc_unchecked(v);
72436 +}
72437 +#endif
72438 +
72439 static inline void atomic_long_dec(atomic_long_t *l)
72440 {
72441 atomic64_t *v = (atomic64_t *)l;
72442 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72443 atomic64_dec(v);
72444 }
72445
72446 +#ifdef CONFIG_PAX_REFCOUNT
72447 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72448 +{
72449 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72450 +
72451 + atomic64_dec_unchecked(v);
72452 +}
72453 +#endif
72454 +
72455 static inline void atomic_long_add(long i, atomic_long_t *l)
72456 {
72457 atomic64_t *v = (atomic64_t *)l;
72458 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72459 atomic64_add(i, v);
72460 }
72461
72462 +#ifdef CONFIG_PAX_REFCOUNT
72463 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72464 +{
72465 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72466 +
72467 + atomic64_add_unchecked(i, v);
72468 +}
72469 +#endif
72470 +
72471 static inline void atomic_long_sub(long i, atomic_long_t *l)
72472 {
72473 atomic64_t *v = (atomic64_t *)l;
72474 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72475 atomic64_sub(i, v);
72476 }
72477
72478 +#ifdef CONFIG_PAX_REFCOUNT
72479 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72480 +{
72481 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72482 +
72483 + atomic64_sub_unchecked(i, v);
72484 +}
72485 +#endif
72486 +
72487 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72488 {
72489 atomic64_t *v = (atomic64_t *)l;
72490 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72491 return (long)atomic64_add_return(i, v);
72492 }
72493
72494 +#ifdef CONFIG_PAX_REFCOUNT
72495 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72496 +{
72497 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72498 +
72499 + return (long)atomic64_add_return_unchecked(i, v);
72500 +}
72501 +#endif
72502 +
72503 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72504 {
72505 atomic64_t *v = (atomic64_t *)l;
72506 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72507 return (long)atomic64_inc_return(v);
72508 }
72509
72510 +#ifdef CONFIG_PAX_REFCOUNT
72511 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72512 +{
72513 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72514 +
72515 + return (long)atomic64_inc_return_unchecked(v);
72516 +}
72517 +#endif
72518 +
72519 static inline long atomic_long_dec_return(atomic_long_t *l)
72520 {
72521 atomic64_t *v = (atomic64_t *)l;
72522 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72523
72524 typedef atomic_t atomic_long_t;
72525
72526 +#ifdef CONFIG_PAX_REFCOUNT
72527 +typedef atomic_unchecked_t atomic_long_unchecked_t;
72528 +#else
72529 +typedef atomic_t atomic_long_unchecked_t;
72530 +#endif
72531 +
72532 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
72533 static inline long atomic_long_read(atomic_long_t *l)
72534 {
72535 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72536 return (long)atomic_read(v);
72537 }
72538
72539 +#ifdef CONFIG_PAX_REFCOUNT
72540 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72541 +{
72542 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72543 +
72544 + return (long)atomic_read_unchecked(v);
72545 +}
72546 +#endif
72547 +
72548 static inline void atomic_long_set(atomic_long_t *l, long i)
72549 {
72550 atomic_t *v = (atomic_t *)l;
72551 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72552 atomic_set(v, i);
72553 }
72554
72555 +#ifdef CONFIG_PAX_REFCOUNT
72556 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72557 +{
72558 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72559 +
72560 + atomic_set_unchecked(v, i);
72561 +}
72562 +#endif
72563 +
72564 static inline void atomic_long_inc(atomic_long_t *l)
72565 {
72566 atomic_t *v = (atomic_t *)l;
72567 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72568 atomic_inc(v);
72569 }
72570
72571 +#ifdef CONFIG_PAX_REFCOUNT
72572 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72573 +{
72574 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72575 +
72576 + atomic_inc_unchecked(v);
72577 +}
72578 +#endif
72579 +
72580 static inline void atomic_long_dec(atomic_long_t *l)
72581 {
72582 atomic_t *v = (atomic_t *)l;
72583 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72584 atomic_dec(v);
72585 }
72586
72587 +#ifdef CONFIG_PAX_REFCOUNT
72588 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72589 +{
72590 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72591 +
72592 + atomic_dec_unchecked(v);
72593 +}
72594 +#endif
72595 +
72596 static inline void atomic_long_add(long i, atomic_long_t *l)
72597 {
72598 atomic_t *v = (atomic_t *)l;
72599 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72600 atomic_add(i, v);
72601 }
72602
72603 +#ifdef CONFIG_PAX_REFCOUNT
72604 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72605 +{
72606 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72607 +
72608 + atomic_add_unchecked(i, v);
72609 +}
72610 +#endif
72611 +
72612 static inline void atomic_long_sub(long i, atomic_long_t *l)
72613 {
72614 atomic_t *v = (atomic_t *)l;
72615 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72616 atomic_sub(i, v);
72617 }
72618
72619 +#ifdef CONFIG_PAX_REFCOUNT
72620 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72621 +{
72622 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72623 +
72624 + atomic_sub_unchecked(i, v);
72625 +}
72626 +#endif
72627 +
72628 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72629 {
72630 atomic_t *v = (atomic_t *)l;
72631 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72632 return (long)atomic_add_return(i, v);
72633 }
72634
72635 +#ifdef CONFIG_PAX_REFCOUNT
72636 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72637 +{
72638 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72639 +
72640 + return (long)atomic_add_return_unchecked(i, v);
72641 +}
72642 +
72643 +#endif
72644 +
72645 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72646 {
72647 atomic_t *v = (atomic_t *)l;
72648 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72649 return (long)atomic_inc_return(v);
72650 }
72651
72652 +#ifdef CONFIG_PAX_REFCOUNT
72653 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72654 +{
72655 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72656 +
72657 + return (long)atomic_inc_return_unchecked(v);
72658 +}
72659 +#endif
72660 +
72661 static inline long atomic_long_dec_return(atomic_long_t *l)
72662 {
72663 atomic_t *v = (atomic_t *)l;
72664 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72665
72666 #endif /* BITS_PER_LONG == 64 */
72667
72668 +#ifdef CONFIG_PAX_REFCOUNT
72669 +static inline void pax_refcount_needs_these_functions(void)
72670 +{
72671 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
72672 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
72673 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
72674 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
72675 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
72676 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
72677 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
72678 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
72679 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
72680 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
72681 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
72682 +#ifdef CONFIG_X86
72683 + atomic_clear_mask_unchecked(0, NULL);
72684 + atomic_set_mask_unchecked(0, NULL);
72685 +#endif
72686 +
72687 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
72688 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
72689 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
72690 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
72691 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
72692 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
72693 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
72694 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
72695 +}
72696 +#else
72697 +#define atomic_read_unchecked(v) atomic_read(v)
72698 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
72699 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
72700 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
72701 +#define atomic_inc_unchecked(v) atomic_inc(v)
72702 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
72703 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
72704 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
72705 +#define atomic_dec_unchecked(v) atomic_dec(v)
72706 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
72707 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
72708 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
72709 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
72710 +
72711 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
72712 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
72713 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
72714 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
72715 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
72716 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
72717 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
72718 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
72719 +#endif
72720 +
72721 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
72722 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
72723 index 33bd2de..f31bff97 100644
72724 --- a/include/asm-generic/atomic.h
72725 +++ b/include/asm-generic/atomic.h
72726 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
72727 * Atomically clears the bits set in @mask from @v
72728 */
72729 #ifndef atomic_clear_mask
72730 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
72731 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
72732 {
72733 unsigned long flags;
72734
72735 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
72736 index b18ce4f..2ee2843 100644
72737 --- a/include/asm-generic/atomic64.h
72738 +++ b/include/asm-generic/atomic64.h
72739 @@ -16,6 +16,8 @@ typedef struct {
72740 long long counter;
72741 } atomic64_t;
72742
72743 +typedef atomic64_t atomic64_unchecked_t;
72744 +
72745 #define ATOMIC64_INIT(i) { (i) }
72746
72747 extern long long atomic64_read(const atomic64_t *v);
72748 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
72749 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
72750 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
72751
72752 +#define atomic64_read_unchecked(v) atomic64_read(v)
72753 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
72754 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
72755 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
72756 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
72757 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
72758 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
72759 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
72760 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
72761 +
72762 #endif /* _ASM_GENERIC_ATOMIC64_H */
72763 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
72764 index 1bfcfe5..e04c5c9 100644
72765 --- a/include/asm-generic/cache.h
72766 +++ b/include/asm-generic/cache.h
72767 @@ -6,7 +6,7 @@
72768 * cache lines need to provide their own cache.h.
72769 */
72770
72771 -#define L1_CACHE_SHIFT 5
72772 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
72773 +#define L1_CACHE_SHIFT 5UL
72774 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
72775
72776 #endif /* __ASM_GENERIC_CACHE_H */
72777 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72778 index 0d68a1e..b74a761 100644
72779 --- a/include/asm-generic/emergency-restart.h
72780 +++ b/include/asm-generic/emergency-restart.h
72781 @@ -1,7 +1,7 @@
72782 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72783 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72784
72785 -static inline void machine_emergency_restart(void)
72786 +static inline __noreturn void machine_emergency_restart(void)
72787 {
72788 machine_restart(NULL);
72789 }
72790 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72791 index 90f99c7..00ce236 100644
72792 --- a/include/asm-generic/kmap_types.h
72793 +++ b/include/asm-generic/kmap_types.h
72794 @@ -2,9 +2,9 @@
72795 #define _ASM_GENERIC_KMAP_TYPES_H
72796
72797 #ifdef __WITH_KM_FENCE
72798 -# define KM_TYPE_NR 41
72799 +# define KM_TYPE_NR 42
72800 #else
72801 -# define KM_TYPE_NR 20
72802 +# define KM_TYPE_NR 21
72803 #endif
72804
72805 #endif
72806 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72807 index 9ceb03b..62b0b8f 100644
72808 --- a/include/asm-generic/local.h
72809 +++ b/include/asm-generic/local.h
72810 @@ -23,24 +23,37 @@ typedef struct
72811 atomic_long_t a;
72812 } local_t;
72813
72814 +typedef struct {
72815 + atomic_long_unchecked_t a;
72816 +} local_unchecked_t;
72817 +
72818 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72819
72820 #define local_read(l) atomic_long_read(&(l)->a)
72821 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72822 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72823 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72824 #define local_inc(l) atomic_long_inc(&(l)->a)
72825 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72826 #define local_dec(l) atomic_long_dec(&(l)->a)
72827 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72828 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72829 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72830 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72831 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72832
72833 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72834 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72835 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72836 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72837 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72838 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72839 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72840 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72841 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72842
72843 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72844 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72845 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72846 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72847 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72848 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72849 index 725612b..9cc513a 100644
72850 --- a/include/asm-generic/pgtable-nopmd.h
72851 +++ b/include/asm-generic/pgtable-nopmd.h
72852 @@ -1,14 +1,19 @@
72853 #ifndef _PGTABLE_NOPMD_H
72854 #define _PGTABLE_NOPMD_H
72855
72856 -#ifndef __ASSEMBLY__
72857 -
72858 #include <asm-generic/pgtable-nopud.h>
72859
72860 -struct mm_struct;
72861 -
72862 #define __PAGETABLE_PMD_FOLDED
72863
72864 +#define PMD_SHIFT PUD_SHIFT
72865 +#define PTRS_PER_PMD 1
72866 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72867 +#define PMD_MASK (~(PMD_SIZE-1))
72868 +
72869 +#ifndef __ASSEMBLY__
72870 +
72871 +struct mm_struct;
72872 +
72873 /*
72874 * Having the pmd type consist of a pud gets the size right, and allows
72875 * us to conceptually access the pud entry that this pmd is folded into
72876 @@ -16,11 +21,6 @@ struct mm_struct;
72877 */
72878 typedef struct { pud_t pud; } pmd_t;
72879
72880 -#define PMD_SHIFT PUD_SHIFT
72881 -#define PTRS_PER_PMD 1
72882 -#define PMD_SIZE (1UL << PMD_SHIFT)
72883 -#define PMD_MASK (~(PMD_SIZE-1))
72884 -
72885 /*
72886 * The "pud_xxx()" functions here are trivial for a folded two-level
72887 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72888 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72889 index 810431d..0ec4804f 100644
72890 --- a/include/asm-generic/pgtable-nopud.h
72891 +++ b/include/asm-generic/pgtable-nopud.h
72892 @@ -1,10 +1,15 @@
72893 #ifndef _PGTABLE_NOPUD_H
72894 #define _PGTABLE_NOPUD_H
72895
72896 -#ifndef __ASSEMBLY__
72897 -
72898 #define __PAGETABLE_PUD_FOLDED
72899
72900 +#define PUD_SHIFT PGDIR_SHIFT
72901 +#define PTRS_PER_PUD 1
72902 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72903 +#define PUD_MASK (~(PUD_SIZE-1))
72904 +
72905 +#ifndef __ASSEMBLY__
72906 +
72907 /*
72908 * Having the pud type consist of a pgd gets the size right, and allows
72909 * us to conceptually access the pgd entry that this pud is folded into
72910 @@ -12,11 +17,6 @@
72911 */
72912 typedef struct { pgd_t pgd; } pud_t;
72913
72914 -#define PUD_SHIFT PGDIR_SHIFT
72915 -#define PTRS_PER_PUD 1
72916 -#define PUD_SIZE (1UL << PUD_SHIFT)
72917 -#define PUD_MASK (~(PUD_SIZE-1))
72918 -
72919 /*
72920 * The "pgd_xxx()" functions here are trivial for a folded two-level
72921 * setup: the pud is never bad, and a pud always exists (as it's folded
72922 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72923 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72924
72925 #define pgd_populate(mm, pgd, pud) do { } while (0)
72926 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72927 /*
72928 * (puds are folded into pgds so this doesn't get actually called,
72929 * but the define is needed for a generic inline function.)
72930 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72931 index f330d28..83ce28f 100644
72932 --- a/include/asm-generic/pgtable.h
72933 +++ b/include/asm-generic/pgtable.h
72934 @@ -737,6 +737,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72935 }
72936 #endif /* CONFIG_NUMA_BALANCING */
72937
72938 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72939 +#ifdef CONFIG_PAX_KERNEXEC
72940 +#error KERNEXEC requires pax_open_kernel
72941 +#else
72942 +static inline unsigned long pax_open_kernel(void) { return 0; }
72943 +#endif
72944 +#endif
72945 +
72946 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72947 +#ifdef CONFIG_PAX_KERNEXEC
72948 +#error KERNEXEC requires pax_close_kernel
72949 +#else
72950 +static inline unsigned long pax_close_kernel(void) { return 0; }
72951 +#endif
72952 +#endif
72953 +
72954 #endif /* CONFIG_MMU */
72955
72956 #endif /* !__ASSEMBLY__ */
72957 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72958 index dc1269c..48a4f51 100644
72959 --- a/include/asm-generic/uaccess.h
72960 +++ b/include/asm-generic/uaccess.h
72961 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72962 return __clear_user(to, n);
72963 }
72964
72965 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72966 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72967 +#error UDEREF requires pax_open_userland
72968 +#else
72969 +static inline unsigned long pax_open_userland(void) { return 0; }
72970 +#endif
72971 +#endif
72972 +
72973 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72974 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72975 +#error UDEREF requires pax_close_userland
72976 +#else
72977 +static inline unsigned long pax_close_userland(void) { return 0; }
72978 +#endif
72979 +#endif
72980 +
72981 #endif /* __ASM_GENERIC_UACCESS_H */
72982 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72983 index 83e2c31..eeb4a04 100644
72984 --- a/include/asm-generic/vmlinux.lds.h
72985 +++ b/include/asm-generic/vmlinux.lds.h
72986 @@ -232,6 +232,7 @@
72987 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72988 VMLINUX_SYMBOL(__start_rodata) = .; \
72989 *(.rodata) *(.rodata.*) \
72990 + *(.data..read_only) \
72991 *(__vermagic) /* Kernel version magic */ \
72992 . = ALIGN(8); \
72993 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72994 @@ -715,17 +716,18 @@
72995 * section in the linker script will go there too. @phdr should have
72996 * a leading colon.
72997 *
72998 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72999 + * Note that this macros defines per_cpu_load as an absolute symbol.
73000 * If there is no need to put the percpu section at a predetermined
73001 * address, use PERCPU_SECTION.
73002 */
73003 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
73004 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
73005 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
73006 + per_cpu_load = .; \
73007 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
73008 - LOAD_OFFSET) { \
73009 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
73010 PERCPU_INPUT(cacheline) \
73011 } phdr \
73012 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
73013 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
73014
73015 /**
73016 * PERCPU_SECTION - define output section for percpu area, simple version
73017 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
73018 index 418d270..bfd2794 100644
73019 --- a/include/crypto/algapi.h
73020 +++ b/include/crypto/algapi.h
73021 @@ -34,7 +34,7 @@ struct crypto_type {
73022 unsigned int maskclear;
73023 unsigned int maskset;
73024 unsigned int tfmsize;
73025 -};
73026 +} __do_const;
73027
73028 struct crypto_instance {
73029 struct crypto_alg alg;
73030 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
73031 index b46fb45..b30d6d5 100644
73032 --- a/include/drm/drmP.h
73033 +++ b/include/drm/drmP.h
73034 @@ -66,6 +66,7 @@
73035 #include <linux/workqueue.h>
73036 #include <linux/poll.h>
73037 #include <asm/pgalloc.h>
73038 +#include <asm/local.h>
73039 #include <drm/drm.h>
73040 #include <drm/drm_sarea.h>
73041 #include <drm/drm_vma_manager.h>
73042 @@ -277,10 +278,12 @@ do { \
73043 * \param cmd command.
73044 * \param arg argument.
73045 */
73046 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
73047 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
73048 + struct drm_file *file_priv);
73049 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
73050 struct drm_file *file_priv);
73051
73052 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73053 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
73054 unsigned long arg);
73055
73056 #define DRM_IOCTL_NR(n) _IOC_NR(n)
73057 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73058 struct drm_ioctl_desc {
73059 unsigned int cmd;
73060 int flags;
73061 - drm_ioctl_t *func;
73062 + drm_ioctl_t func;
73063 unsigned int cmd_drv;
73064 const char *name;
73065 -};
73066 +} __do_const;
73067
73068 /**
73069 * Creates a driver or general drm_ioctl_desc array entry for the given
73070 @@ -1027,7 +1030,7 @@ struct drm_info_list {
73071 int (*show)(struct seq_file*, void*); /** show callback */
73072 u32 driver_features; /**< Required driver features for this entry */
73073 void *data;
73074 -};
73075 +} __do_const;
73076
73077 /**
73078 * debugfs node structure. This structure represents a debugfs file.
73079 @@ -1098,7 +1101,7 @@ struct drm_device {
73080
73081 /** \name Usage Counters */
73082 /*@{ */
73083 - int open_count; /**< Outstanding files open */
73084 + local_t open_count; /**< Outstanding files open */
73085 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
73086 atomic_t vma_count; /**< Outstanding vma areas open */
73087 int buf_use; /**< Buffers in use -- cannot alloc */
73088 @@ -1109,7 +1112,7 @@ struct drm_device {
73089 /*@{ */
73090 unsigned long counters;
73091 enum drm_stat_type types[15];
73092 - atomic_t counts[15];
73093 + atomic_unchecked_t counts[15];
73094 /*@} */
73095
73096 struct list_head filelist;
73097 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
73098 index f43d556..94d9343 100644
73099 --- a/include/drm/drm_crtc_helper.h
73100 +++ b/include/drm/drm_crtc_helper.h
73101 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
73102 struct drm_connector *connector);
73103 /* disable encoder when not in use - more explicit than dpms off */
73104 void (*disable)(struct drm_encoder *encoder);
73105 -};
73106 +} __no_const;
73107
73108 /**
73109 * drm_connector_helper_funcs - helper operations for connectors
73110 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
73111 index 8a10f5c..5de7f5c 100644
73112 --- a/include/drm/i915_pciids.h
73113 +++ b/include/drm/i915_pciids.h
73114 @@ -37,7 +37,7 @@
73115 */
73116 #define INTEL_VGA_DEVICE(id, info) { \
73117 0x8086, id, \
73118 - ~0, ~0, \
73119 + PCI_ANY_ID, PCI_ANY_ID, \
73120 0x030000, 0xff0000, \
73121 (unsigned long) info }
73122
73123 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
73124 index 72dcbe8..8db58d7 100644
73125 --- a/include/drm/ttm/ttm_memory.h
73126 +++ b/include/drm/ttm/ttm_memory.h
73127 @@ -48,7 +48,7 @@
73128
73129 struct ttm_mem_shrink {
73130 int (*do_shrink) (struct ttm_mem_shrink *);
73131 -};
73132 +} __no_const;
73133
73134 /**
73135 * struct ttm_mem_global - Global memory accounting structure.
73136 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
73137 index 4b840e8..155d235 100644
73138 --- a/include/keys/asymmetric-subtype.h
73139 +++ b/include/keys/asymmetric-subtype.h
73140 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
73141 /* Verify the signature on a key of this subtype (optional) */
73142 int (*verify_signature)(const struct key *key,
73143 const struct public_key_signature *sig);
73144 -};
73145 +} __do_const;
73146
73147 /**
73148 * asymmetric_key_subtype - Get the subtype from an asymmetric key
73149 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
73150 index c1da539..1dcec55 100644
73151 --- a/include/linux/atmdev.h
73152 +++ b/include/linux/atmdev.h
73153 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
73154 #endif
73155
73156 struct k_atm_aal_stats {
73157 -#define __HANDLE_ITEM(i) atomic_t i
73158 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73159 __AAL_STAT_ITEMS
73160 #undef __HANDLE_ITEM
73161 };
73162 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
73163 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
73164 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
73165 struct module *owner;
73166 -};
73167 +} __do_const ;
73168
73169 struct atmphy_ops {
73170 int (*start)(struct atm_dev *dev);
73171 diff --git a/include/linux/audit.h b/include/linux/audit.h
73172 index 729a4d1..9b304ae 100644
73173 --- a/include/linux/audit.h
73174 +++ b/include/linux/audit.h
73175 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
73176 extern unsigned int audit_serial(void);
73177 extern int auditsc_get_stamp(struct audit_context *ctx,
73178 struct timespec *t, unsigned int *serial);
73179 -extern int audit_set_loginuid(kuid_t loginuid);
73180 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
73181
73182 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
73183 {
73184 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
73185 index e8112ae..05b8e7f 100644
73186 --- a/include/linux/binfmts.h
73187 +++ b/include/linux/binfmts.h
73188 @@ -73,8 +73,10 @@ struct linux_binfmt {
73189 int (*load_binary)(struct linux_binprm *);
73190 int (*load_shlib)(struct file *);
73191 int (*core_dump)(struct coredump_params *cprm);
73192 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
73193 + void (*handle_mmap)(struct file *);
73194 unsigned long min_coredump; /* minimal dump size */
73195 -};
73196 +} __do_const;
73197
73198 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
73199
73200 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
73201 index a3b6b82..cd8f69c 100644
73202 --- a/include/linux/bitops.h
73203 +++ b/include/linux/bitops.h
73204 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
73205 * @word: value to rotate
73206 * @shift: bits to roll
73207 */
73208 -static inline __u32 rol32(__u32 word, unsigned int shift)
73209 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
73210 {
73211 return (word << shift) | (word >> (32 - shift));
73212 }
73213 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
73214 * @word: value to rotate
73215 * @shift: bits to roll
73216 */
73217 -static inline __u32 ror32(__u32 word, unsigned int shift)
73218 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
73219 {
73220 return (word >> shift) | (word << (32 - shift));
73221 }
73222 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
73223 index 0e6f765..885bb2b 100644
73224 --- a/include/linux/blkdev.h
73225 +++ b/include/linux/blkdev.h
73226 @@ -1537,7 +1537,7 @@ struct block_device_operations {
73227 /* this callback is with swap_lock and sometimes page table lock held */
73228 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
73229 struct module *owner;
73230 -};
73231 +} __do_const;
73232
73233 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
73234 unsigned long);
73235 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
73236 index 7c2e030..b72475d 100644
73237 --- a/include/linux/blktrace_api.h
73238 +++ b/include/linux/blktrace_api.h
73239 @@ -23,7 +23,7 @@ struct blk_trace {
73240 struct dentry *dir;
73241 struct dentry *dropped_file;
73242 struct dentry *msg_file;
73243 - atomic_t dropped;
73244 + atomic_unchecked_t dropped;
73245 };
73246
73247 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
73248 diff --git a/include/linux/cache.h b/include/linux/cache.h
73249 index 4c57065..40346da 100644
73250 --- a/include/linux/cache.h
73251 +++ b/include/linux/cache.h
73252 @@ -16,6 +16,14 @@
73253 #define __read_mostly
73254 #endif
73255
73256 +#ifndef __read_only
73257 +#ifdef CONFIG_PAX_KERNEXEC
73258 +#error KERNEXEC requires __read_only
73259 +#else
73260 +#define __read_only __read_mostly
73261 +#endif
73262 +#endif
73263 +
73264 #ifndef ____cacheline_aligned
73265 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
73266 #endif
73267 diff --git a/include/linux/capability.h b/include/linux/capability.h
73268 index a6ee1f9..e1ca49d 100644
73269 --- a/include/linux/capability.h
73270 +++ b/include/linux/capability.h
73271 @@ -212,8 +212,13 @@ extern bool capable(int cap);
73272 extern bool ns_capable(struct user_namespace *ns, int cap);
73273 extern bool inode_capable(const struct inode *inode, int cap);
73274 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
73275 +extern bool capable_nolog(int cap);
73276 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
73277 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
73278
73279 /* audit system wants to get cap info from files as well */
73280 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
73281
73282 +extern int is_privileged_binary(const struct dentry *dentry);
73283 +
73284 #endif /* !_LINUX_CAPABILITY_H */
73285 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
73286 index 8609d57..86e4d79 100644
73287 --- a/include/linux/cdrom.h
73288 +++ b/include/linux/cdrom.h
73289 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
73290
73291 /* driver specifications */
73292 const int capability; /* capability flags */
73293 - int n_minors; /* number of active minor devices */
73294 /* handle uniform packets for scsi type devices (scsi,atapi) */
73295 int (*generic_packet) (struct cdrom_device_info *,
73296 struct packet_command *);
73297 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
73298 index 4ce9056..86caac6 100644
73299 --- a/include/linux/cleancache.h
73300 +++ b/include/linux/cleancache.h
73301 @@ -31,7 +31,7 @@ struct cleancache_ops {
73302 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
73303 void (*invalidate_inode)(int, struct cleancache_filekey);
73304 void (*invalidate_fs)(int);
73305 -};
73306 +} __no_const;
73307
73308 extern struct cleancache_ops *
73309 cleancache_register_ops(struct cleancache_ops *ops);
73310 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
73311 index 73bdb69..d66d47a 100644
73312 --- a/include/linux/clk-provider.h
73313 +++ b/include/linux/clk-provider.h
73314 @@ -141,6 +141,7 @@ struct clk_ops {
73315 unsigned long);
73316 void (*init)(struct clk_hw *hw);
73317 };
73318 +typedef struct clk_ops __no_const clk_ops_no_const;
73319
73320 /**
73321 * struct clk_init_data - holds init data that's common to all clocks and is
73322 diff --git a/include/linux/compat.h b/include/linux/compat.h
73323 index 345da00..b6eff26 100644
73324 --- a/include/linux/compat.h
73325 +++ b/include/linux/compat.h
73326 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
73327 compat_size_t __user *len_ptr);
73328
73329 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
73330 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
73331 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
73332 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
73333 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
73334 compat_ssize_t msgsz, int msgflg);
73335 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
73336 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
73337 compat_ulong_t addr, compat_ulong_t data);
73338 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
73339 - compat_long_t addr, compat_long_t data);
73340 + compat_ulong_t addr, compat_ulong_t data);
73341
73342 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
73343 /*
73344 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
73345 index ded4299..da50e3b 100644
73346 --- a/include/linux/compiler-gcc4.h
73347 +++ b/include/linux/compiler-gcc4.h
73348 @@ -39,9 +39,29 @@
73349 # define __compiletime_warning(message) __attribute__((warning(message)))
73350 # define __compiletime_error(message) __attribute__((error(message)))
73351 #endif /* __CHECKER__ */
73352 +
73353 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
73354 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
73355 +#define __bos0(ptr) __bos((ptr), 0)
73356 +#define __bos1(ptr) __bos((ptr), 1)
73357 #endif /* GCC_VERSION >= 40300 */
73358
73359 #if GCC_VERSION >= 40500
73360 +
73361 +#ifdef CONSTIFY_PLUGIN
73362 +#define __no_const __attribute__((no_const))
73363 +#define __do_const __attribute__((do_const))
73364 +#endif
73365 +
73366 +#ifdef SIZE_OVERFLOW_PLUGIN
73367 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
73368 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
73369 +#endif
73370 +
73371 +#ifdef LATENT_ENTROPY_PLUGIN
73372 +#define __latent_entropy __attribute__((latent_entropy))
73373 +#endif
73374 +
73375 /*
73376 * Mark a position in code as unreachable. This can be used to
73377 * suppress control flow warnings after asm blocks that transfer
73378 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
73379 index 92669cd..1771a15 100644
73380 --- a/include/linux/compiler.h
73381 +++ b/include/linux/compiler.h
73382 @@ -5,11 +5,14 @@
73383
73384 #ifdef __CHECKER__
73385 # define __user __attribute__((noderef, address_space(1)))
73386 +# define __force_user __force __user
73387 # define __kernel __attribute__((address_space(0)))
73388 +# define __force_kernel __force __kernel
73389 # define __safe __attribute__((safe))
73390 # define __force __attribute__((force))
73391 # define __nocast __attribute__((nocast))
73392 # define __iomem __attribute__((noderef, address_space(2)))
73393 +# define __force_iomem __force __iomem
73394 # define __must_hold(x) __attribute__((context(x,1,1)))
73395 # define __acquires(x) __attribute__((context(x,0,1)))
73396 # define __releases(x) __attribute__((context(x,1,0)))
73397 @@ -17,20 +20,37 @@
73398 # define __release(x) __context__(x,-1)
73399 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
73400 # define __percpu __attribute__((noderef, address_space(3)))
73401 +# define __force_percpu __force __percpu
73402 #ifdef CONFIG_SPARSE_RCU_POINTER
73403 # define __rcu __attribute__((noderef, address_space(4)))
73404 +# define __force_rcu __force __rcu
73405 #else
73406 # define __rcu
73407 +# define __force_rcu
73408 #endif
73409 extern void __chk_user_ptr(const volatile void __user *);
73410 extern void __chk_io_ptr(const volatile void __iomem *);
73411 #else
73412 -# define __user
73413 -# define __kernel
73414 +# ifdef CHECKER_PLUGIN
73415 +//# define __user
73416 +//# define __force_user
73417 +//# define __kernel
73418 +//# define __force_kernel
73419 +# else
73420 +# ifdef STRUCTLEAK_PLUGIN
73421 +# define __user __attribute__((user))
73422 +# else
73423 +# define __user
73424 +# endif
73425 +# define __force_user
73426 +# define __kernel
73427 +# define __force_kernel
73428 +# endif
73429 # define __safe
73430 # define __force
73431 # define __nocast
73432 # define __iomem
73433 +# define __force_iomem
73434 # define __chk_user_ptr(x) (void)0
73435 # define __chk_io_ptr(x) (void)0
73436 # define __builtin_warning(x, y...) (1)
73437 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
73438 # define __release(x) (void)0
73439 # define __cond_lock(x,c) (c)
73440 # define __percpu
73441 +# define __force_percpu
73442 # define __rcu
73443 +# define __force_rcu
73444 #endif
73445
73446 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
73447 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73448 # define __attribute_const__ /* unimplemented */
73449 #endif
73450
73451 +#ifndef __no_const
73452 +# define __no_const
73453 +#endif
73454 +
73455 +#ifndef __do_const
73456 +# define __do_const
73457 +#endif
73458 +
73459 +#ifndef __size_overflow
73460 +# define __size_overflow(...)
73461 +#endif
73462 +
73463 +#ifndef __intentional_overflow
73464 +# define __intentional_overflow(...)
73465 +#endif
73466 +
73467 +#ifndef __latent_entropy
73468 +# define __latent_entropy
73469 +#endif
73470 +
73471 /*
73472 * Tell gcc if a function is cold. The compiler will assume any path
73473 * directly leading to the call is unlikely.
73474 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73475 #define __cold
73476 #endif
73477
73478 +#ifndef __alloc_size
73479 +#define __alloc_size(...)
73480 +#endif
73481 +
73482 +#ifndef __bos
73483 +#define __bos(ptr, arg)
73484 +#endif
73485 +
73486 +#ifndef __bos0
73487 +#define __bos0(ptr)
73488 +#endif
73489 +
73490 +#ifndef __bos1
73491 +#define __bos1(ptr)
73492 +#endif
73493 +
73494 /* Simple shorthand for a section definition */
73495 #ifndef __section
73496 # define __section(S) __attribute__ ((__section__(#S)))
73497 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73498 * use is to mediate communication between process-level code and irq/NMI
73499 * handlers, all running on the same CPU.
73500 */
73501 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
73502 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
73503 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
73504
73505 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
73506 #ifdef CONFIG_KPROBES
73507 diff --git a/include/linux/completion.h b/include/linux/completion.h
73508 index 3cd574d..240dcb0 100644
73509 --- a/include/linux/completion.h
73510 +++ b/include/linux/completion.h
73511 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
73512
73513 extern void wait_for_completion(struct completion *);
73514 extern void wait_for_completion_io(struct completion *);
73515 -extern int wait_for_completion_interruptible(struct completion *x);
73516 -extern int wait_for_completion_killable(struct completion *x);
73517 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
73518 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
73519 extern unsigned long wait_for_completion_timeout(struct completion *x,
73520 - unsigned long timeout);
73521 + unsigned long timeout) __intentional_overflow(-1);
73522 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
73523 - unsigned long timeout);
73524 + unsigned long timeout) __intentional_overflow(-1);
73525 extern long wait_for_completion_interruptible_timeout(
73526 - struct completion *x, unsigned long timeout);
73527 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73528 extern long wait_for_completion_killable_timeout(
73529 - struct completion *x, unsigned long timeout);
73530 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73531 extern bool try_wait_for_completion(struct completion *x);
73532 extern bool completion_done(struct completion *x);
73533
73534 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
73535 index 34025df..d94bbbc 100644
73536 --- a/include/linux/configfs.h
73537 +++ b/include/linux/configfs.h
73538 @@ -125,7 +125,7 @@ struct configfs_attribute {
73539 const char *ca_name;
73540 struct module *ca_owner;
73541 umode_t ca_mode;
73542 -};
73543 +} __do_const;
73544
73545 /*
73546 * Users often need to create attribute structures for their configurable
73547 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
73548 index fcabc42..cba5d93 100644
73549 --- a/include/linux/cpufreq.h
73550 +++ b/include/linux/cpufreq.h
73551 @@ -167,6 +167,7 @@ struct global_attr {
73552 ssize_t (*store)(struct kobject *a, struct attribute *b,
73553 const char *c, size_t count);
73554 };
73555 +typedef struct global_attr __no_const global_attr_no_const;
73556
73557 #define define_one_global_ro(_name) \
73558 static struct global_attr _name = \
73559 @@ -208,7 +209,7 @@ struct cpufreq_driver {
73560 int (*suspend) (struct cpufreq_policy *policy);
73561 int (*resume) (struct cpufreq_policy *policy);
73562 struct freq_attr **attr;
73563 -};
73564 +} __do_const;
73565
73566 /* flags */
73567 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
73568 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
73569 index 781addc..d1e1fe6 100644
73570 --- a/include/linux/cpuidle.h
73571 +++ b/include/linux/cpuidle.h
73572 @@ -50,7 +50,8 @@ struct cpuidle_state {
73573 int index);
73574
73575 int (*enter_dead) (struct cpuidle_device *dev, int index);
73576 -};
73577 +} __do_const;
73578 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
73579
73580 /* Idle State Flags */
73581 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
73582 @@ -192,7 +193,7 @@ struct cpuidle_governor {
73583 void (*reflect) (struct cpuidle_device *dev, int index);
73584
73585 struct module *owner;
73586 -};
73587 +} __do_const;
73588
73589 #ifdef CONFIG_CPU_IDLE
73590
73591 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
73592 index d08e4d2..95fad61 100644
73593 --- a/include/linux/cpumask.h
73594 +++ b/include/linux/cpumask.h
73595 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73596 }
73597
73598 /* Valid inputs for n are -1 and 0. */
73599 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73600 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73601 {
73602 return n+1;
73603 }
73604
73605 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73606 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73607 {
73608 return n+1;
73609 }
73610
73611 -static inline unsigned int cpumask_next_and(int n,
73612 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
73613 const struct cpumask *srcp,
73614 const struct cpumask *andp)
73615 {
73616 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73617 *
73618 * Returns >= nr_cpu_ids if no further cpus set.
73619 */
73620 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73621 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73622 {
73623 /* -1 is a legal arg here. */
73624 if (n != -1)
73625 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73626 *
73627 * Returns >= nr_cpu_ids if no further cpus unset.
73628 */
73629 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73630 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73631 {
73632 /* -1 is a legal arg here. */
73633 if (n != -1)
73634 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73635 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
73636 }
73637
73638 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
73639 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
73640 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
73641
73642 /**
73643 diff --git a/include/linux/cred.h b/include/linux/cred.h
73644 index 04421e8..6bce4ef 100644
73645 --- a/include/linux/cred.h
73646 +++ b/include/linux/cred.h
73647 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
73648 static inline void validate_process_creds(void)
73649 {
73650 }
73651 +static inline void validate_task_creds(struct task_struct *task)
73652 +{
73653 +}
73654 #endif
73655
73656 /**
73657 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
73658 index b92eadf..b4ecdc1 100644
73659 --- a/include/linux/crypto.h
73660 +++ b/include/linux/crypto.h
73661 @@ -373,7 +373,7 @@ struct cipher_tfm {
73662 const u8 *key, unsigned int keylen);
73663 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73664 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73665 -};
73666 +} __no_const;
73667
73668 struct hash_tfm {
73669 int (*init)(struct hash_desc *desc);
73670 @@ -394,13 +394,13 @@ struct compress_tfm {
73671 int (*cot_decompress)(struct crypto_tfm *tfm,
73672 const u8 *src, unsigned int slen,
73673 u8 *dst, unsigned int *dlen);
73674 -};
73675 +} __no_const;
73676
73677 struct rng_tfm {
73678 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
73679 unsigned int dlen);
73680 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
73681 -};
73682 +} __no_const;
73683
73684 #define crt_ablkcipher crt_u.ablkcipher
73685 #define crt_aead crt_u.aead
73686 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
73687 index 653589e..4ef254a 100644
73688 --- a/include/linux/ctype.h
73689 +++ b/include/linux/ctype.h
73690 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
73691 * Fast implementation of tolower() for internal usage. Do not use in your
73692 * code.
73693 */
73694 -static inline char _tolower(const char c)
73695 +static inline unsigned char _tolower(const unsigned char c)
73696 {
73697 return c | 0x20;
73698 }
73699 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
73700 index 7925bf0..d5143d2 100644
73701 --- a/include/linux/decompress/mm.h
73702 +++ b/include/linux/decompress/mm.h
73703 @@ -77,7 +77,7 @@ static void free(void *where)
73704 * warnings when not needed (indeed large_malloc / large_free are not
73705 * needed by inflate */
73706
73707 -#define malloc(a) kmalloc(a, GFP_KERNEL)
73708 +#define malloc(a) kmalloc((a), GFP_KERNEL)
73709 #define free(a) kfree(a)
73710
73711 #define large_malloc(a) vmalloc(a)
73712 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
73713 index 5f1ab92..39c35ae 100644
73714 --- a/include/linux/devfreq.h
73715 +++ b/include/linux/devfreq.h
73716 @@ -114,7 +114,7 @@ struct devfreq_governor {
73717 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
73718 int (*event_handler)(struct devfreq *devfreq,
73719 unsigned int event, void *data);
73720 -};
73721 +} __do_const;
73722
73723 /**
73724 * struct devfreq - Device devfreq structure
73725 diff --git a/include/linux/device.h b/include/linux/device.h
73726 index 2a9d6ed..d14551e3 100644
73727 --- a/include/linux/device.h
73728 +++ b/include/linux/device.h
73729 @@ -313,7 +313,7 @@ struct subsys_interface {
73730 struct list_head node;
73731 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
73732 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
73733 -};
73734 +} __do_const;
73735
73736 int subsys_interface_register(struct subsys_interface *sif);
73737 void subsys_interface_unregister(struct subsys_interface *sif);
73738 @@ -501,7 +501,7 @@ struct device_type {
73739 void (*release)(struct device *dev);
73740
73741 const struct dev_pm_ops *pm;
73742 -};
73743 +} __do_const;
73744
73745 /* interface for exporting device attributes */
73746 struct device_attribute {
73747 @@ -511,11 +511,12 @@ struct device_attribute {
73748 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
73749 const char *buf, size_t count);
73750 };
73751 +typedef struct device_attribute __no_const device_attribute_no_const;
73752
73753 struct dev_ext_attribute {
73754 struct device_attribute attr;
73755 void *var;
73756 -};
73757 +} __do_const;
73758
73759 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
73760 char *buf);
73761 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
73762 index 3a8d0a2..c762be2 100644
73763 --- a/include/linux/dma-mapping.h
73764 +++ b/include/linux/dma-mapping.h
73765 @@ -54,7 +54,7 @@ struct dma_map_ops {
73766 u64 (*get_required_mask)(struct device *dev);
73767 #endif
73768 int is_phys;
73769 -};
73770 +} __do_const;
73771
73772 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
73773
73774 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
73775 index 0bc7275..4ccbf11 100644
73776 --- a/include/linux/dmaengine.h
73777 +++ b/include/linux/dmaengine.h
73778 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
73779 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
73780 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
73781
73782 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73783 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73784 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
73785 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73786 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73787 struct dma_pinned_list *pinned_list, struct page *page,
73788 unsigned int offset, size_t len);
73789
73790 diff --git a/include/linux/efi.h b/include/linux/efi.h
73791 index 5f8f176..62a0556 100644
73792 --- a/include/linux/efi.h
73793 +++ b/include/linux/efi.h
73794 @@ -745,6 +745,7 @@ struct efivar_operations {
73795 efi_set_variable_t *set_variable;
73796 efi_query_variable_store_t *query_variable_store;
73797 };
73798 +typedef struct efivar_operations __no_const efivar_operations_no_const;
73799
73800 struct efivars {
73801 /*
73802 diff --git a/include/linux/elf.h b/include/linux/elf.h
73803 index 40a3c0e..4c45a38 100644
73804 --- a/include/linux/elf.h
73805 +++ b/include/linux/elf.h
73806 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
73807 #define elf_note elf32_note
73808 #define elf_addr_t Elf32_Off
73809 #define Elf_Half Elf32_Half
73810 +#define elf_dyn Elf32_Dyn
73811
73812 #else
73813
73814 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
73815 #define elf_note elf64_note
73816 #define elf_addr_t Elf64_Off
73817 #define Elf_Half Elf64_Half
73818 +#define elf_dyn Elf64_Dyn
73819
73820 #endif
73821
73822 diff --git a/include/linux/err.h b/include/linux/err.h
73823 index 15f92e0..e825a8e 100644
73824 --- a/include/linux/err.h
73825 +++ b/include/linux/err.h
73826 @@ -19,12 +19,12 @@
73827
73828 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
73829
73830 -static inline void * __must_check ERR_PTR(long error)
73831 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
73832 {
73833 return (void *) error;
73834 }
73835
73836 -static inline long __must_check PTR_ERR(__force const void *ptr)
73837 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
73838 {
73839 return (long) ptr;
73840 }
73841 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
73842 index fcb51c8..bdafcf6 100644
73843 --- a/include/linux/extcon.h
73844 +++ b/include/linux/extcon.h
73845 @@ -134,7 +134,7 @@ struct extcon_dev {
73846 /* /sys/class/extcon/.../mutually_exclusive/... */
73847 struct attribute_group attr_g_muex;
73848 struct attribute **attrs_muex;
73849 - struct device_attribute *d_attrs_muex;
73850 + device_attribute_no_const *d_attrs_muex;
73851 };
73852
73853 /**
73854 diff --git a/include/linux/fb.h b/include/linux/fb.h
73855 index ffac70a..ca3e711 100644
73856 --- a/include/linux/fb.h
73857 +++ b/include/linux/fb.h
73858 @@ -304,7 +304,7 @@ struct fb_ops {
73859 /* called at KDB enter and leave time to prepare the console */
73860 int (*fb_debug_enter)(struct fb_info *info);
73861 int (*fb_debug_leave)(struct fb_info *info);
73862 -};
73863 +} __do_const;
73864
73865 #ifdef CONFIG_FB_TILEBLITTING
73866 #define FB_TILE_CURSOR_NONE 0
73867 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73868 index 085197b..0fa6f0b 100644
73869 --- a/include/linux/fdtable.h
73870 +++ b/include/linux/fdtable.h
73871 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73872 void put_files_struct(struct files_struct *fs);
73873 void reset_files_struct(struct files_struct *);
73874 int unshare_files(struct files_struct **);
73875 -struct files_struct *dup_fd(struct files_struct *, int *);
73876 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73877 void do_close_on_exec(struct files_struct *);
73878 int iterate_fd(struct files_struct *, unsigned,
73879 int (*)(const void *, struct file *, unsigned),
73880 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73881 index 8293262..2b3b8bd 100644
73882 --- a/include/linux/frontswap.h
73883 +++ b/include/linux/frontswap.h
73884 @@ -11,7 +11,7 @@ struct frontswap_ops {
73885 int (*load)(unsigned, pgoff_t, struct page *);
73886 void (*invalidate_page)(unsigned, pgoff_t);
73887 void (*invalidate_area)(unsigned);
73888 -};
73889 +} __no_const;
73890
73891 extern bool frontswap_enabled;
73892 extern struct frontswap_ops *
73893 diff --git a/include/linux/fs.h b/include/linux/fs.h
73894 index 3f40547..46f76eb 100644
73895 --- a/include/linux/fs.h
73896 +++ b/include/linux/fs.h
73897 @@ -1552,7 +1552,8 @@ struct file_operations {
73898 long (*fallocate)(struct file *file, int mode, loff_t offset,
73899 loff_t len);
73900 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73901 -};
73902 +} __do_const;
73903 +typedef struct file_operations __no_const file_operations_no_const;
73904
73905 struct inode_operations {
73906 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73907 @@ -2745,4 +2746,14 @@ static inline bool dir_relax(struct inode *inode)
73908 return !IS_DEADDIR(inode);
73909 }
73910
73911 +static inline bool is_sidechannel_device(const struct inode *inode)
73912 +{
73913 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73914 + umode_t mode = inode->i_mode;
73915 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73916 +#else
73917 + return false;
73918 +#endif
73919 +}
73920 +
73921 #endif /* _LINUX_FS_H */
73922 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73923 index 0efc3e6..e0e1e5f 100644
73924 --- a/include/linux/fs_struct.h
73925 +++ b/include/linux/fs_struct.h
73926 @@ -6,7 +6,7 @@
73927 #include <linux/seqlock.h>
73928
73929 struct fs_struct {
73930 - int users;
73931 + atomic_t users;
73932 spinlock_t lock;
73933 seqcount_t seq;
73934 int umask;
73935 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73936 index 7823e9e..56b6f2f 100644
73937 --- a/include/linux/fscache-cache.h
73938 +++ b/include/linux/fscache-cache.h
73939 @@ -113,7 +113,7 @@ struct fscache_operation {
73940 fscache_operation_release_t release;
73941 };
73942
73943 -extern atomic_t fscache_op_debug_id;
73944 +extern atomic_unchecked_t fscache_op_debug_id;
73945 extern void fscache_op_work_func(struct work_struct *work);
73946
73947 extern void fscache_enqueue_operation(struct fscache_operation *);
73948 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73949 INIT_WORK(&op->work, fscache_op_work_func);
73950 atomic_set(&op->usage, 1);
73951 op->state = FSCACHE_OP_ST_INITIALISED;
73952 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73953 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73954 op->processor = processor;
73955 op->release = release;
73956 INIT_LIST_HEAD(&op->pend_link);
73957 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73958 index 19b4645..3b73dfc 100644
73959 --- a/include/linux/fscache.h
73960 +++ b/include/linux/fscache.h
73961 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73962 * - this is mandatory for any object that may have data
73963 */
73964 void (*now_uncached)(void *cookie_netfs_data);
73965 -};
73966 +} __do_const;
73967
73968 /*
73969 * fscache cached network filesystem type
73970 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73971 index 1c804b0..1432c2b 100644
73972 --- a/include/linux/fsnotify.h
73973 +++ b/include/linux/fsnotify.h
73974 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73975 struct inode *inode = file_inode(file);
73976 __u32 mask = FS_ACCESS;
73977
73978 + if (is_sidechannel_device(inode))
73979 + return;
73980 +
73981 if (S_ISDIR(inode->i_mode))
73982 mask |= FS_ISDIR;
73983
73984 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73985 struct inode *inode = file_inode(file);
73986 __u32 mask = FS_MODIFY;
73987
73988 + if (is_sidechannel_device(inode))
73989 + return;
73990 +
73991 if (S_ISDIR(inode->i_mode))
73992 mask |= FS_ISDIR;
73993
73994 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73995 */
73996 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73997 {
73998 - return kstrdup(name, GFP_KERNEL);
73999 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
74000 }
74001
74002 /*
74003 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
74004 index 9f3c275..8bdff5d 100644
74005 --- a/include/linux/genhd.h
74006 +++ b/include/linux/genhd.h
74007 @@ -194,7 +194,7 @@ struct gendisk {
74008 struct kobject *slave_dir;
74009
74010 struct timer_rand_state *random;
74011 - atomic_t sync_io; /* RAID */
74012 + atomic_unchecked_t sync_io; /* RAID */
74013 struct disk_events *ev;
74014 #ifdef CONFIG_BLK_DEV_INTEGRITY
74015 struct blk_integrity *integrity;
74016 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
74017 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
74018
74019 /* drivers/char/random.c */
74020 -extern void add_disk_randomness(struct gendisk *disk);
74021 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
74022 extern void rand_initialize_disk(struct gendisk *disk);
74023
74024 static inline sector_t get_start_sect(struct block_device *bdev)
74025 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
74026 index 023bc34..b02b46a 100644
74027 --- a/include/linux/genl_magic_func.h
74028 +++ b/include/linux/genl_magic_func.h
74029 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
74030 },
74031
74032 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
74033 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
74034 +static struct genl_ops ZZZ_genl_ops[] = {
74035 #include GENL_MAGIC_INCLUDE_FILE
74036 };
74037
74038 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
74039 index 9b4dd49..61fd41d 100644
74040 --- a/include/linux/gfp.h
74041 +++ b/include/linux/gfp.h
74042 @@ -35,6 +35,13 @@ struct vm_area_struct;
74043 #define ___GFP_NO_KSWAPD 0x400000u
74044 #define ___GFP_OTHER_NODE 0x800000u
74045 #define ___GFP_WRITE 0x1000000u
74046 +
74047 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74048 +#define ___GFP_USERCOPY 0x2000000u
74049 +#else
74050 +#define ___GFP_USERCOPY 0
74051 +#endif
74052 +
74053 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
74054
74055 /*
74056 @@ -92,6 +99,7 @@ struct vm_area_struct;
74057 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
74058 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
74059 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
74060 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
74061
74062 /*
74063 * This may seem redundant, but it's a way of annotating false positives vs.
74064 @@ -99,7 +107,7 @@ struct vm_area_struct;
74065 */
74066 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
74067
74068 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
74069 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
74070 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
74071
74072 /* This equals 0, but use constants in case they ever change */
74073 @@ -153,6 +161,8 @@ struct vm_area_struct;
74074 /* 4GB DMA on some platforms */
74075 #define GFP_DMA32 __GFP_DMA32
74076
74077 +#define GFP_USERCOPY __GFP_USERCOPY
74078 +
74079 /* Convert GFP flags to their corresponding migrate type */
74080 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
74081 {
74082 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
74083 new file mode 100644
74084 index 0000000..edb2cb6
74085 --- /dev/null
74086 +++ b/include/linux/gracl.h
74087 @@ -0,0 +1,340 @@
74088 +#ifndef GR_ACL_H
74089 +#define GR_ACL_H
74090 +
74091 +#include <linux/grdefs.h>
74092 +#include <linux/resource.h>
74093 +#include <linux/capability.h>
74094 +#include <linux/dcache.h>
74095 +#include <asm/resource.h>
74096 +
74097 +/* Major status information */
74098 +
74099 +#define GR_VERSION "grsecurity 3.0"
74100 +#define GRSECURITY_VERSION 0x3000
74101 +
74102 +enum {
74103 + GR_SHUTDOWN = 0,
74104 + GR_ENABLE = 1,
74105 + GR_SPROLE = 2,
74106 + GR_OLDRELOAD = 3,
74107 + GR_SEGVMOD = 4,
74108 + GR_STATUS = 5,
74109 + GR_UNSPROLE = 6,
74110 + GR_PASSSET = 7,
74111 + GR_SPROLEPAM = 8,
74112 + GR_RELOAD = 9,
74113 +};
74114 +
74115 +/* Password setup definitions
74116 + * kernel/grhash.c */
74117 +enum {
74118 + GR_PW_LEN = 128,
74119 + GR_SALT_LEN = 16,
74120 + GR_SHA_LEN = 32,
74121 +};
74122 +
74123 +enum {
74124 + GR_SPROLE_LEN = 64,
74125 +};
74126 +
74127 +enum {
74128 + GR_NO_GLOB = 0,
74129 + GR_REG_GLOB,
74130 + GR_CREATE_GLOB
74131 +};
74132 +
74133 +#define GR_NLIMITS 32
74134 +
74135 +/* Begin Data Structures */
74136 +
74137 +struct sprole_pw {
74138 + unsigned char *rolename;
74139 + unsigned char salt[GR_SALT_LEN];
74140 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
74141 +};
74142 +
74143 +struct name_entry {
74144 + __u32 key;
74145 + ino_t inode;
74146 + dev_t device;
74147 + char *name;
74148 + __u16 len;
74149 + __u8 deleted;
74150 + struct name_entry *prev;
74151 + struct name_entry *next;
74152 +};
74153 +
74154 +struct inodev_entry {
74155 + struct name_entry *nentry;
74156 + struct inodev_entry *prev;
74157 + struct inodev_entry *next;
74158 +};
74159 +
74160 +struct acl_role_db {
74161 + struct acl_role_label **r_hash;
74162 + __u32 r_size;
74163 +};
74164 +
74165 +struct inodev_db {
74166 + struct inodev_entry **i_hash;
74167 + __u32 i_size;
74168 +};
74169 +
74170 +struct name_db {
74171 + struct name_entry **n_hash;
74172 + __u32 n_size;
74173 +};
74174 +
74175 +struct crash_uid {
74176 + uid_t uid;
74177 + unsigned long expires;
74178 +};
74179 +
74180 +struct gr_hash_struct {
74181 + void **table;
74182 + void **nametable;
74183 + void *first;
74184 + __u32 table_size;
74185 + __u32 used_size;
74186 + int type;
74187 +};
74188 +
74189 +/* Userspace Grsecurity ACL data structures */
74190 +
74191 +struct acl_subject_label {
74192 + char *filename;
74193 + ino_t inode;
74194 + dev_t device;
74195 + __u32 mode;
74196 + kernel_cap_t cap_mask;
74197 + kernel_cap_t cap_lower;
74198 + kernel_cap_t cap_invert_audit;
74199 +
74200 + struct rlimit res[GR_NLIMITS];
74201 + __u32 resmask;
74202 +
74203 + __u8 user_trans_type;
74204 + __u8 group_trans_type;
74205 + uid_t *user_transitions;
74206 + gid_t *group_transitions;
74207 + __u16 user_trans_num;
74208 + __u16 group_trans_num;
74209 +
74210 + __u32 sock_families[2];
74211 + __u32 ip_proto[8];
74212 + __u32 ip_type;
74213 + struct acl_ip_label **ips;
74214 + __u32 ip_num;
74215 + __u32 inaddr_any_override;
74216 +
74217 + __u32 crashes;
74218 + unsigned long expires;
74219 +
74220 + struct acl_subject_label *parent_subject;
74221 + struct gr_hash_struct *hash;
74222 + struct acl_subject_label *prev;
74223 + struct acl_subject_label *next;
74224 +
74225 + struct acl_object_label **obj_hash;
74226 + __u32 obj_hash_size;
74227 + __u16 pax_flags;
74228 +};
74229 +
74230 +struct role_allowed_ip {
74231 + __u32 addr;
74232 + __u32 netmask;
74233 +
74234 + struct role_allowed_ip *prev;
74235 + struct role_allowed_ip *next;
74236 +};
74237 +
74238 +struct role_transition {
74239 + char *rolename;
74240 +
74241 + struct role_transition *prev;
74242 + struct role_transition *next;
74243 +};
74244 +
74245 +struct acl_role_label {
74246 + char *rolename;
74247 + uid_t uidgid;
74248 + __u16 roletype;
74249 +
74250 + __u16 auth_attempts;
74251 + unsigned long expires;
74252 +
74253 + struct acl_subject_label *root_label;
74254 + struct gr_hash_struct *hash;
74255 +
74256 + struct acl_role_label *prev;
74257 + struct acl_role_label *next;
74258 +
74259 + struct role_transition *transitions;
74260 + struct role_allowed_ip *allowed_ips;
74261 + uid_t *domain_children;
74262 + __u16 domain_child_num;
74263 +
74264 + umode_t umask;
74265 +
74266 + struct acl_subject_label **subj_hash;
74267 + __u32 subj_hash_size;
74268 +};
74269 +
74270 +struct user_acl_role_db {
74271 + struct acl_role_label **r_table;
74272 + __u32 num_pointers; /* Number of allocations to track */
74273 + __u32 num_roles; /* Number of roles */
74274 + __u32 num_domain_children; /* Number of domain children */
74275 + __u32 num_subjects; /* Number of subjects */
74276 + __u32 num_objects; /* Number of objects */
74277 +};
74278 +
74279 +struct acl_object_label {
74280 + char *filename;
74281 + ino_t inode;
74282 + dev_t device;
74283 + __u32 mode;
74284 +
74285 + struct acl_subject_label *nested;
74286 + struct acl_object_label *globbed;
74287 +
74288 + /* next two structures not used */
74289 +
74290 + struct acl_object_label *prev;
74291 + struct acl_object_label *next;
74292 +};
74293 +
74294 +struct acl_ip_label {
74295 + char *iface;
74296 + __u32 addr;
74297 + __u32 netmask;
74298 + __u16 low, high;
74299 + __u8 mode;
74300 + __u32 type;
74301 + __u32 proto[8];
74302 +
74303 + /* next two structures not used */
74304 +
74305 + struct acl_ip_label *prev;
74306 + struct acl_ip_label *next;
74307 +};
74308 +
74309 +struct gr_arg {
74310 + struct user_acl_role_db role_db;
74311 + unsigned char pw[GR_PW_LEN];
74312 + unsigned char salt[GR_SALT_LEN];
74313 + unsigned char sum[GR_SHA_LEN];
74314 + unsigned char sp_role[GR_SPROLE_LEN];
74315 + struct sprole_pw *sprole_pws;
74316 + dev_t segv_device;
74317 + ino_t segv_inode;
74318 + uid_t segv_uid;
74319 + __u16 num_sprole_pws;
74320 + __u16 mode;
74321 +};
74322 +
74323 +struct gr_arg_wrapper {
74324 + struct gr_arg *arg;
74325 + __u32 version;
74326 + __u32 size;
74327 +};
74328 +
74329 +struct subject_map {
74330 + struct acl_subject_label *user;
74331 + struct acl_subject_label *kernel;
74332 + struct subject_map *prev;
74333 + struct subject_map *next;
74334 +};
74335 +
74336 +struct acl_subj_map_db {
74337 + struct subject_map **s_hash;
74338 + __u32 s_size;
74339 +};
74340 +
74341 +struct gr_policy_state {
74342 + struct sprole_pw **acl_special_roles;
74343 + __u16 num_sprole_pws;
74344 + struct acl_role_label *kernel_role;
74345 + struct acl_role_label *role_list;
74346 + struct acl_role_label *default_role;
74347 + struct acl_role_db acl_role_set;
74348 + struct acl_subj_map_db subj_map_set;
74349 + struct name_db name_set;
74350 + struct inodev_db inodev_set;
74351 +};
74352 +
74353 +struct gr_alloc_state {
74354 + unsigned long alloc_stack_next;
74355 + unsigned long alloc_stack_size;
74356 + void **alloc_stack;
74357 +};
74358 +
74359 +struct gr_reload_state {
74360 + struct gr_policy_state oldpolicy;
74361 + struct gr_alloc_state oldalloc;
74362 + struct gr_policy_state newpolicy;
74363 + struct gr_alloc_state newalloc;
74364 + struct gr_policy_state *oldpolicy_ptr;
74365 + struct gr_alloc_state *oldalloc_ptr;
74366 + unsigned char oldmode;
74367 +};
74368 +
74369 +/* End Data Structures Section */
74370 +
74371 +/* Hash functions generated by empirical testing by Brad Spengler
74372 + Makes good use of the low bits of the inode. Generally 0-1 times
74373 + in loop for successful match. 0-3 for unsuccessful match.
74374 + Shift/add algorithm with modulus of table size and an XOR*/
74375 +
74376 +static __inline__ unsigned int
74377 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
74378 +{
74379 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
74380 +}
74381 +
74382 + static __inline__ unsigned int
74383 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
74384 +{
74385 + return ((const unsigned long)userp % sz);
74386 +}
74387 +
74388 +static __inline__ unsigned int
74389 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
74390 +{
74391 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
74392 +}
74393 +
74394 +static __inline__ unsigned int
74395 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
74396 +{
74397 + return full_name_hash((const unsigned char *)name, len) % sz;
74398 +}
74399 +
74400 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
74401 + subj = NULL; \
74402 + iter = 0; \
74403 + while (iter < role->subj_hash_size) { \
74404 + if (subj == NULL) \
74405 + subj = role->subj_hash[iter]; \
74406 + if (subj == NULL) { \
74407 + iter++; \
74408 + continue; \
74409 + }
74410 +
74411 +#define FOR_EACH_SUBJECT_END(subj,iter) \
74412 + subj = subj->next; \
74413 + if (subj == NULL) \
74414 + iter++; \
74415 + }
74416 +
74417 +
74418 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
74419 + subj = role->hash->first; \
74420 + while (subj != NULL) {
74421 +
74422 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
74423 + subj = subj->next; \
74424 + }
74425 +
74426 +#endif
74427 +
74428 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
74429 new file mode 100644
74430 index 0000000..33ebd1f
74431 --- /dev/null
74432 +++ b/include/linux/gracl_compat.h
74433 @@ -0,0 +1,156 @@
74434 +#ifndef GR_ACL_COMPAT_H
74435 +#define GR_ACL_COMPAT_H
74436 +
74437 +#include <linux/resource.h>
74438 +#include <asm/resource.h>
74439 +
74440 +struct sprole_pw_compat {
74441 + compat_uptr_t rolename;
74442 + unsigned char salt[GR_SALT_LEN];
74443 + unsigned char sum[GR_SHA_LEN];
74444 +};
74445 +
74446 +struct gr_hash_struct_compat {
74447 + compat_uptr_t table;
74448 + compat_uptr_t nametable;
74449 + compat_uptr_t first;
74450 + __u32 table_size;
74451 + __u32 used_size;
74452 + int type;
74453 +};
74454 +
74455 +struct acl_subject_label_compat {
74456 + compat_uptr_t filename;
74457 + compat_ino_t inode;
74458 + __u32 device;
74459 + __u32 mode;
74460 + kernel_cap_t cap_mask;
74461 + kernel_cap_t cap_lower;
74462 + kernel_cap_t cap_invert_audit;
74463 +
74464 + struct compat_rlimit res[GR_NLIMITS];
74465 + __u32 resmask;
74466 +
74467 + __u8 user_trans_type;
74468 + __u8 group_trans_type;
74469 + compat_uptr_t user_transitions;
74470 + compat_uptr_t group_transitions;
74471 + __u16 user_trans_num;
74472 + __u16 group_trans_num;
74473 +
74474 + __u32 sock_families[2];
74475 + __u32 ip_proto[8];
74476 + __u32 ip_type;
74477 + compat_uptr_t ips;
74478 + __u32 ip_num;
74479 + __u32 inaddr_any_override;
74480 +
74481 + __u32 crashes;
74482 + compat_ulong_t expires;
74483 +
74484 + compat_uptr_t parent_subject;
74485 + compat_uptr_t hash;
74486 + compat_uptr_t prev;
74487 + compat_uptr_t next;
74488 +
74489 + compat_uptr_t obj_hash;
74490 + __u32 obj_hash_size;
74491 + __u16 pax_flags;
74492 +};
74493 +
74494 +struct role_allowed_ip_compat {
74495 + __u32 addr;
74496 + __u32 netmask;
74497 +
74498 + compat_uptr_t prev;
74499 + compat_uptr_t next;
74500 +};
74501 +
74502 +struct role_transition_compat {
74503 + compat_uptr_t rolename;
74504 +
74505 + compat_uptr_t prev;
74506 + compat_uptr_t next;
74507 +};
74508 +
74509 +struct acl_role_label_compat {
74510 + compat_uptr_t rolename;
74511 + uid_t uidgid;
74512 + __u16 roletype;
74513 +
74514 + __u16 auth_attempts;
74515 + compat_ulong_t expires;
74516 +
74517 + compat_uptr_t root_label;
74518 + compat_uptr_t hash;
74519 +
74520 + compat_uptr_t prev;
74521 + compat_uptr_t next;
74522 +
74523 + compat_uptr_t transitions;
74524 + compat_uptr_t allowed_ips;
74525 + compat_uptr_t domain_children;
74526 + __u16 domain_child_num;
74527 +
74528 + umode_t umask;
74529 +
74530 + compat_uptr_t subj_hash;
74531 + __u32 subj_hash_size;
74532 +};
74533 +
74534 +struct user_acl_role_db_compat {
74535 + compat_uptr_t r_table;
74536 + __u32 num_pointers;
74537 + __u32 num_roles;
74538 + __u32 num_domain_children;
74539 + __u32 num_subjects;
74540 + __u32 num_objects;
74541 +};
74542 +
74543 +struct acl_object_label_compat {
74544 + compat_uptr_t filename;
74545 + compat_ino_t inode;
74546 + __u32 device;
74547 + __u32 mode;
74548 +
74549 + compat_uptr_t nested;
74550 + compat_uptr_t globbed;
74551 +
74552 + compat_uptr_t prev;
74553 + compat_uptr_t next;
74554 +};
74555 +
74556 +struct acl_ip_label_compat {
74557 + compat_uptr_t iface;
74558 + __u32 addr;
74559 + __u32 netmask;
74560 + __u16 low, high;
74561 + __u8 mode;
74562 + __u32 type;
74563 + __u32 proto[8];
74564 +
74565 + compat_uptr_t prev;
74566 + compat_uptr_t next;
74567 +};
74568 +
74569 +struct gr_arg_compat {
74570 + struct user_acl_role_db_compat role_db;
74571 + unsigned char pw[GR_PW_LEN];
74572 + unsigned char salt[GR_SALT_LEN];
74573 + unsigned char sum[GR_SHA_LEN];
74574 + unsigned char sp_role[GR_SPROLE_LEN];
74575 + compat_uptr_t sprole_pws;
74576 + __u32 segv_device;
74577 + compat_ino_t segv_inode;
74578 + uid_t segv_uid;
74579 + __u16 num_sprole_pws;
74580 + __u16 mode;
74581 +};
74582 +
74583 +struct gr_arg_wrapper_compat {
74584 + compat_uptr_t arg;
74585 + __u32 version;
74586 + __u32 size;
74587 +};
74588 +
74589 +#endif
74590 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
74591 new file mode 100644
74592 index 0000000..323ecf2
74593 --- /dev/null
74594 +++ b/include/linux/gralloc.h
74595 @@ -0,0 +1,9 @@
74596 +#ifndef __GRALLOC_H
74597 +#define __GRALLOC_H
74598 +
74599 +void acl_free_all(void);
74600 +int acl_alloc_stack_init(unsigned long size);
74601 +void *acl_alloc(unsigned long len);
74602 +void *acl_alloc_num(unsigned long num, unsigned long len);
74603 +
74604 +#endif
74605 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
74606 new file mode 100644
74607 index 0000000..be66033
74608 --- /dev/null
74609 +++ b/include/linux/grdefs.h
74610 @@ -0,0 +1,140 @@
74611 +#ifndef GRDEFS_H
74612 +#define GRDEFS_H
74613 +
74614 +/* Begin grsecurity status declarations */
74615 +
74616 +enum {
74617 + GR_READY = 0x01,
74618 + GR_STATUS_INIT = 0x00 // disabled state
74619 +};
74620 +
74621 +/* Begin ACL declarations */
74622 +
74623 +/* Role flags */
74624 +
74625 +enum {
74626 + GR_ROLE_USER = 0x0001,
74627 + GR_ROLE_GROUP = 0x0002,
74628 + GR_ROLE_DEFAULT = 0x0004,
74629 + GR_ROLE_SPECIAL = 0x0008,
74630 + GR_ROLE_AUTH = 0x0010,
74631 + GR_ROLE_NOPW = 0x0020,
74632 + GR_ROLE_GOD = 0x0040,
74633 + GR_ROLE_LEARN = 0x0080,
74634 + GR_ROLE_TPE = 0x0100,
74635 + GR_ROLE_DOMAIN = 0x0200,
74636 + GR_ROLE_PAM = 0x0400,
74637 + GR_ROLE_PERSIST = 0x0800
74638 +};
74639 +
74640 +/* ACL Subject and Object mode flags */
74641 +enum {
74642 + GR_DELETED = 0x80000000
74643 +};
74644 +
74645 +/* ACL Object-only mode flags */
74646 +enum {
74647 + GR_READ = 0x00000001,
74648 + GR_APPEND = 0x00000002,
74649 + GR_WRITE = 0x00000004,
74650 + GR_EXEC = 0x00000008,
74651 + GR_FIND = 0x00000010,
74652 + GR_INHERIT = 0x00000020,
74653 + GR_SETID = 0x00000040,
74654 + GR_CREATE = 0x00000080,
74655 + GR_DELETE = 0x00000100,
74656 + GR_LINK = 0x00000200,
74657 + GR_AUDIT_READ = 0x00000400,
74658 + GR_AUDIT_APPEND = 0x00000800,
74659 + GR_AUDIT_WRITE = 0x00001000,
74660 + GR_AUDIT_EXEC = 0x00002000,
74661 + GR_AUDIT_FIND = 0x00004000,
74662 + GR_AUDIT_INHERIT= 0x00008000,
74663 + GR_AUDIT_SETID = 0x00010000,
74664 + GR_AUDIT_CREATE = 0x00020000,
74665 + GR_AUDIT_DELETE = 0x00040000,
74666 + GR_AUDIT_LINK = 0x00080000,
74667 + GR_PTRACERD = 0x00100000,
74668 + GR_NOPTRACE = 0x00200000,
74669 + GR_SUPPRESS = 0x00400000,
74670 + GR_NOLEARN = 0x00800000,
74671 + GR_INIT_TRANSFER= 0x01000000
74672 +};
74673 +
74674 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
74675 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
74676 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
74677 +
74678 +/* ACL subject-only mode flags */
74679 +enum {
74680 + GR_KILL = 0x00000001,
74681 + GR_VIEW = 0x00000002,
74682 + GR_PROTECTED = 0x00000004,
74683 + GR_LEARN = 0x00000008,
74684 + GR_OVERRIDE = 0x00000010,
74685 + /* just a placeholder, this mode is only used in userspace */
74686 + GR_DUMMY = 0x00000020,
74687 + GR_PROTSHM = 0x00000040,
74688 + GR_KILLPROC = 0x00000080,
74689 + GR_KILLIPPROC = 0x00000100,
74690 + /* just a placeholder, this mode is only used in userspace */
74691 + GR_NOTROJAN = 0x00000200,
74692 + GR_PROTPROCFD = 0x00000400,
74693 + GR_PROCACCT = 0x00000800,
74694 + GR_RELAXPTRACE = 0x00001000,
74695 + //GR_NESTED = 0x00002000,
74696 + GR_INHERITLEARN = 0x00004000,
74697 + GR_PROCFIND = 0x00008000,
74698 + GR_POVERRIDE = 0x00010000,
74699 + GR_KERNELAUTH = 0x00020000,
74700 + GR_ATSECURE = 0x00040000,
74701 + GR_SHMEXEC = 0x00080000
74702 +};
74703 +
74704 +enum {
74705 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
74706 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
74707 + GR_PAX_ENABLE_MPROTECT = 0x0004,
74708 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
74709 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
74710 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
74711 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
74712 + GR_PAX_DISABLE_MPROTECT = 0x0400,
74713 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
74714 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
74715 +};
74716 +
74717 +enum {
74718 + GR_ID_USER = 0x01,
74719 + GR_ID_GROUP = 0x02,
74720 +};
74721 +
74722 +enum {
74723 + GR_ID_ALLOW = 0x01,
74724 + GR_ID_DENY = 0x02,
74725 +};
74726 +
74727 +#define GR_CRASH_RES 31
74728 +#define GR_UIDTABLE_MAX 500
74729 +
74730 +/* begin resource learning section */
74731 +enum {
74732 + GR_RLIM_CPU_BUMP = 60,
74733 + GR_RLIM_FSIZE_BUMP = 50000,
74734 + GR_RLIM_DATA_BUMP = 10000,
74735 + GR_RLIM_STACK_BUMP = 1000,
74736 + GR_RLIM_CORE_BUMP = 10000,
74737 + GR_RLIM_RSS_BUMP = 500000,
74738 + GR_RLIM_NPROC_BUMP = 1,
74739 + GR_RLIM_NOFILE_BUMP = 5,
74740 + GR_RLIM_MEMLOCK_BUMP = 50000,
74741 + GR_RLIM_AS_BUMP = 500000,
74742 + GR_RLIM_LOCKS_BUMP = 2,
74743 + GR_RLIM_SIGPENDING_BUMP = 5,
74744 + GR_RLIM_MSGQUEUE_BUMP = 10000,
74745 + GR_RLIM_NICE_BUMP = 1,
74746 + GR_RLIM_RTPRIO_BUMP = 1,
74747 + GR_RLIM_RTTIME_BUMP = 1000000
74748 +};
74749 +
74750 +#endif
74751 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
74752 new file mode 100644
74753 index 0000000..d25522e
74754 --- /dev/null
74755 +++ b/include/linux/grinternal.h
74756 @@ -0,0 +1,229 @@
74757 +#ifndef __GRINTERNAL_H
74758 +#define __GRINTERNAL_H
74759 +
74760 +#ifdef CONFIG_GRKERNSEC
74761 +
74762 +#include <linux/fs.h>
74763 +#include <linux/mnt_namespace.h>
74764 +#include <linux/nsproxy.h>
74765 +#include <linux/gracl.h>
74766 +#include <linux/grdefs.h>
74767 +#include <linux/grmsg.h>
74768 +
74769 +void gr_add_learn_entry(const char *fmt, ...)
74770 + __attribute__ ((format (printf, 1, 2)));
74771 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
74772 + const struct vfsmount *mnt);
74773 +__u32 gr_check_create(const struct dentry *new_dentry,
74774 + const struct dentry *parent,
74775 + const struct vfsmount *mnt, const __u32 mode);
74776 +int gr_check_protected_task(const struct task_struct *task);
74777 +__u32 to_gr_audit(const __u32 reqmode);
74778 +int gr_set_acls(const int type);
74779 +int gr_acl_is_enabled(void);
74780 +char gr_roletype_to_char(void);
74781 +
74782 +void gr_handle_alertkill(struct task_struct *task);
74783 +char *gr_to_filename(const struct dentry *dentry,
74784 + const struct vfsmount *mnt);
74785 +char *gr_to_filename1(const struct dentry *dentry,
74786 + const struct vfsmount *mnt);
74787 +char *gr_to_filename2(const struct dentry *dentry,
74788 + const struct vfsmount *mnt);
74789 +char *gr_to_filename3(const struct dentry *dentry,
74790 + const struct vfsmount *mnt);
74791 +
74792 +extern int grsec_enable_ptrace_readexec;
74793 +extern int grsec_enable_harden_ptrace;
74794 +extern int grsec_enable_link;
74795 +extern int grsec_enable_fifo;
74796 +extern int grsec_enable_execve;
74797 +extern int grsec_enable_shm;
74798 +extern int grsec_enable_execlog;
74799 +extern int grsec_enable_signal;
74800 +extern int grsec_enable_audit_ptrace;
74801 +extern int grsec_enable_forkfail;
74802 +extern int grsec_enable_time;
74803 +extern int grsec_enable_rofs;
74804 +extern int grsec_deny_new_usb;
74805 +extern int grsec_enable_chroot_shmat;
74806 +extern int grsec_enable_chroot_mount;
74807 +extern int grsec_enable_chroot_double;
74808 +extern int grsec_enable_chroot_pivot;
74809 +extern int grsec_enable_chroot_chdir;
74810 +extern int grsec_enable_chroot_chmod;
74811 +extern int grsec_enable_chroot_mknod;
74812 +extern int grsec_enable_chroot_fchdir;
74813 +extern int grsec_enable_chroot_nice;
74814 +extern int grsec_enable_chroot_execlog;
74815 +extern int grsec_enable_chroot_caps;
74816 +extern int grsec_enable_chroot_sysctl;
74817 +extern int grsec_enable_chroot_unix;
74818 +extern int grsec_enable_symlinkown;
74819 +extern kgid_t grsec_symlinkown_gid;
74820 +extern int grsec_enable_tpe;
74821 +extern kgid_t grsec_tpe_gid;
74822 +extern int grsec_enable_tpe_all;
74823 +extern int grsec_enable_tpe_invert;
74824 +extern int grsec_enable_socket_all;
74825 +extern kgid_t grsec_socket_all_gid;
74826 +extern int grsec_enable_socket_client;
74827 +extern kgid_t grsec_socket_client_gid;
74828 +extern int grsec_enable_socket_server;
74829 +extern kgid_t grsec_socket_server_gid;
74830 +extern kgid_t grsec_audit_gid;
74831 +extern int grsec_enable_group;
74832 +extern int grsec_enable_log_rwxmaps;
74833 +extern int grsec_enable_mount;
74834 +extern int grsec_enable_chdir;
74835 +extern int grsec_resource_logging;
74836 +extern int grsec_enable_blackhole;
74837 +extern int grsec_lastack_retries;
74838 +extern int grsec_enable_brute;
74839 +extern int grsec_enable_harden_ipc;
74840 +extern int grsec_lock;
74841 +
74842 +extern spinlock_t grsec_alert_lock;
74843 +extern unsigned long grsec_alert_wtime;
74844 +extern unsigned long grsec_alert_fyet;
74845 +
74846 +extern spinlock_t grsec_audit_lock;
74847 +
74848 +extern rwlock_t grsec_exec_file_lock;
74849 +
74850 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
74851 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
74852 + (tsk)->exec_file->f_path.mnt) : "/")
74853 +
74854 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
74855 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
74856 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74857 +
74858 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
74859 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
74860 + (tsk)->exec_file->f_path.mnt) : "/")
74861 +
74862 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74863 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74864 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74865 +
74866 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74867 +
74868 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74869 +
74870 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74871 +{
74872 + if (file1 && file2) {
74873 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74874 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74875 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74876 + return true;
74877 + }
74878 +
74879 + return false;
74880 +}
74881 +
74882 +#define GR_CHROOT_CAPS {{ \
74883 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74884 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74885 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74886 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74887 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74888 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74889 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74890 +
74891 +#define security_learn(normal_msg,args...) \
74892 +({ \
74893 + read_lock(&grsec_exec_file_lock); \
74894 + gr_add_learn_entry(normal_msg "\n", ## args); \
74895 + read_unlock(&grsec_exec_file_lock); \
74896 +})
74897 +
74898 +enum {
74899 + GR_DO_AUDIT,
74900 + GR_DONT_AUDIT,
74901 + /* used for non-audit messages that we shouldn't kill the task on */
74902 + GR_DONT_AUDIT_GOOD
74903 +};
74904 +
74905 +enum {
74906 + GR_TTYSNIFF,
74907 + GR_RBAC,
74908 + GR_RBAC_STR,
74909 + GR_STR_RBAC,
74910 + GR_RBAC_MODE2,
74911 + GR_RBAC_MODE3,
74912 + GR_FILENAME,
74913 + GR_SYSCTL_HIDDEN,
74914 + GR_NOARGS,
74915 + GR_ONE_INT,
74916 + GR_ONE_INT_TWO_STR,
74917 + GR_ONE_STR,
74918 + GR_STR_INT,
74919 + GR_TWO_STR_INT,
74920 + GR_TWO_INT,
74921 + GR_TWO_U64,
74922 + GR_THREE_INT,
74923 + GR_FIVE_INT_TWO_STR,
74924 + GR_TWO_STR,
74925 + GR_THREE_STR,
74926 + GR_FOUR_STR,
74927 + GR_STR_FILENAME,
74928 + GR_FILENAME_STR,
74929 + GR_FILENAME_TWO_INT,
74930 + GR_FILENAME_TWO_INT_STR,
74931 + GR_TEXTREL,
74932 + GR_PTRACE,
74933 + GR_RESOURCE,
74934 + GR_CAP,
74935 + GR_SIG,
74936 + GR_SIG2,
74937 + GR_CRASH1,
74938 + GR_CRASH2,
74939 + GR_PSACCT,
74940 + GR_RWXMAP,
74941 + GR_RWXMAPVMA
74942 +};
74943 +
74944 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74945 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74946 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74947 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74948 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74949 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74950 +#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)
74951 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74952 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74953 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74954 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74955 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74956 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74957 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74958 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74959 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74960 +#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)
74961 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74962 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74963 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74964 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74965 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74966 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74967 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74968 +#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)
74969 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74970 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74971 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74972 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74973 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74974 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74975 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74976 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74977 +#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)
74978 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74979 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74980 +
74981 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74982 +
74983 +#endif
74984 +
74985 +#endif
74986 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74987 new file mode 100644
74988 index 0000000..378a81a
74989 --- /dev/null
74990 +++ b/include/linux/grmsg.h
74991 @@ -0,0 +1,114 @@
74992 +#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"
74993 +#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"
74994 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74995 +#define GR_STOPMOD_MSG "denied modification of module state by "
74996 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74997 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74998 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74999 +#define GR_IOPL_MSG "denied use of iopl() by "
75000 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
75001 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
75002 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
75003 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
75004 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
75005 +#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"
75006 +#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"
75007 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
75008 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
75009 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
75010 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
75011 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
75012 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
75013 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
75014 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
75015 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
75016 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
75017 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
75018 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
75019 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
75020 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
75021 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
75022 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
75023 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
75024 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
75025 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
75026 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
75027 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
75028 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
75029 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
75030 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
75031 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
75032 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
75033 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
75034 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
75035 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
75036 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
75037 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
75038 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
75039 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
75040 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
75041 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
75042 +#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"
75043 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
75044 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
75045 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
75046 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
75047 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
75048 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
75049 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
75050 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
75051 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
75052 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
75053 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
75054 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
75055 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
75056 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
75057 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
75058 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
75059 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
75060 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
75061 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
75062 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
75063 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
75064 +#define GR_NICE_CHROOT_MSG "denied priority change by "
75065 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
75066 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
75067 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
75068 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
75069 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
75070 +#define GR_TIME_MSG "time set by "
75071 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
75072 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
75073 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
75074 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
75075 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
75076 +#define GR_BIND_MSG "denied bind() by "
75077 +#define GR_CONNECT_MSG "denied connect() by "
75078 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
75079 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
75080 +#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"
75081 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
75082 +#define GR_CAP_ACL_MSG "use of %s denied for "
75083 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
75084 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
75085 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
75086 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
75087 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
75088 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
75089 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
75090 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
75091 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
75092 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
75093 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
75094 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
75095 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
75096 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
75097 +#define GR_VM86_MSG "denied use of vm86 by "
75098 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
75099 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
75100 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
75101 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
75102 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
75103 +#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 "
75104 +#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 "
75105 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
75106 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
75107 new file mode 100644
75108 index 0000000..b2edfb1
75109 --- /dev/null
75110 +++ b/include/linux/grsecurity.h
75111 @@ -0,0 +1,243 @@
75112 +#ifndef GR_SECURITY_H
75113 +#define GR_SECURITY_H
75114 +#include <linux/fs.h>
75115 +#include <linux/fs_struct.h>
75116 +#include <linux/binfmts.h>
75117 +#include <linux/gracl.h>
75118 +
75119 +/* notify of brain-dead configs */
75120 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75121 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
75122 +#endif
75123 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
75124 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
75125 +#endif
75126 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
75127 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
75128 +#endif
75129 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
75130 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
75131 +#endif
75132 +
75133 +int gr_handle_new_usb(void);
75134 +
75135 +void gr_handle_brute_attach(unsigned long mm_flags);
75136 +void gr_handle_brute_check(void);
75137 +void gr_handle_kernel_exploit(void);
75138 +
75139 +char gr_roletype_to_char(void);
75140 +
75141 +int gr_acl_enable_at_secure(void);
75142 +
75143 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
75144 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
75145 +
75146 +void gr_del_task_from_ip_table(struct task_struct *p);
75147 +
75148 +int gr_pid_is_chrooted(struct task_struct *p);
75149 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
75150 +int gr_handle_chroot_nice(void);
75151 +int gr_handle_chroot_sysctl(const int op);
75152 +int gr_handle_chroot_setpriority(struct task_struct *p,
75153 + const int niceval);
75154 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
75155 +int gr_handle_chroot_chroot(const struct dentry *dentry,
75156 + const struct vfsmount *mnt);
75157 +void gr_handle_chroot_chdir(const struct path *path);
75158 +int gr_handle_chroot_chmod(const struct dentry *dentry,
75159 + const struct vfsmount *mnt, const int mode);
75160 +int gr_handle_chroot_mknod(const struct dentry *dentry,
75161 + const struct vfsmount *mnt, const int mode);
75162 +int gr_handle_chroot_mount(const struct dentry *dentry,
75163 + const struct vfsmount *mnt,
75164 + const char *dev_name);
75165 +int gr_handle_chroot_pivot(void);
75166 +int gr_handle_chroot_unix(const pid_t pid);
75167 +
75168 +int gr_handle_rawio(const struct inode *inode);
75169 +
75170 +void gr_handle_ioperm(void);
75171 +void gr_handle_iopl(void);
75172 +
75173 +umode_t gr_acl_umask(void);
75174 +
75175 +int gr_tpe_allow(const struct file *file);
75176 +
75177 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
75178 +void gr_clear_chroot_entries(struct task_struct *task);
75179 +
75180 +void gr_log_forkfail(const int retval);
75181 +void gr_log_timechange(void);
75182 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
75183 +void gr_log_chdir(const struct dentry *dentry,
75184 + const struct vfsmount *mnt);
75185 +void gr_log_chroot_exec(const struct dentry *dentry,
75186 + const struct vfsmount *mnt);
75187 +void gr_log_remount(const char *devname, const int retval);
75188 +void gr_log_unmount(const char *devname, const int retval);
75189 +void gr_log_mount(const char *from, const char *to, const int retval);
75190 +void gr_log_textrel(struct vm_area_struct *vma);
75191 +void gr_log_ptgnustack(struct file *file);
75192 +void gr_log_rwxmmap(struct file *file);
75193 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
75194 +
75195 +int gr_handle_follow_link(const struct inode *parent,
75196 + const struct inode *inode,
75197 + const struct dentry *dentry,
75198 + const struct vfsmount *mnt);
75199 +int gr_handle_fifo(const struct dentry *dentry,
75200 + const struct vfsmount *mnt,
75201 + const struct dentry *dir, const int flag,
75202 + const int acc_mode);
75203 +int gr_handle_hardlink(const struct dentry *dentry,
75204 + const struct vfsmount *mnt,
75205 + struct inode *inode,
75206 + const int mode, const struct filename *to);
75207 +
75208 +int gr_is_capable(const int cap);
75209 +int gr_is_capable_nolog(const int cap);
75210 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
75211 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
75212 +
75213 +void gr_copy_label(struct task_struct *tsk);
75214 +void gr_handle_crash(struct task_struct *task, const int sig);
75215 +int gr_handle_signal(const struct task_struct *p, const int sig);
75216 +int gr_check_crash_uid(const kuid_t uid);
75217 +int gr_check_protected_task(const struct task_struct *task);
75218 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
75219 +int gr_acl_handle_mmap(const struct file *file,
75220 + const unsigned long prot);
75221 +int gr_acl_handle_mprotect(const struct file *file,
75222 + const unsigned long prot);
75223 +int gr_check_hidden_task(const struct task_struct *tsk);
75224 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
75225 + const struct vfsmount *mnt);
75226 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
75227 + const struct vfsmount *mnt);
75228 +__u32 gr_acl_handle_access(const struct dentry *dentry,
75229 + const struct vfsmount *mnt, const int fmode);
75230 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
75231 + const struct vfsmount *mnt, umode_t *mode);
75232 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
75233 + const struct vfsmount *mnt);
75234 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
75235 + const struct vfsmount *mnt);
75236 +int gr_handle_ptrace(struct task_struct *task, const long request);
75237 +int gr_handle_proc_ptrace(struct task_struct *task);
75238 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
75239 + const struct vfsmount *mnt);
75240 +int gr_check_crash_exec(const struct file *filp);
75241 +int gr_acl_is_enabled(void);
75242 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
75243 + const kgid_t gid);
75244 +int gr_set_proc_label(const struct dentry *dentry,
75245 + const struct vfsmount *mnt,
75246 + const int unsafe_flags);
75247 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
75248 + const struct vfsmount *mnt);
75249 +__u32 gr_acl_handle_open(const struct dentry *dentry,
75250 + const struct vfsmount *mnt, int acc_mode);
75251 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
75252 + const struct dentry *p_dentry,
75253 + const struct vfsmount *p_mnt,
75254 + int open_flags, int acc_mode, const int imode);
75255 +void gr_handle_create(const struct dentry *dentry,
75256 + const struct vfsmount *mnt);
75257 +void gr_handle_proc_create(const struct dentry *dentry,
75258 + const struct inode *inode);
75259 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
75260 + const struct dentry *parent_dentry,
75261 + const struct vfsmount *parent_mnt,
75262 + const int mode);
75263 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
75264 + const struct dentry *parent_dentry,
75265 + const struct vfsmount *parent_mnt);
75266 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
75267 + const struct vfsmount *mnt);
75268 +void gr_handle_delete(const ino_t ino, const dev_t dev);
75269 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
75270 + const struct vfsmount *mnt);
75271 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
75272 + const struct dentry *parent_dentry,
75273 + const struct vfsmount *parent_mnt,
75274 + const struct filename *from);
75275 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
75276 + const struct dentry *parent_dentry,
75277 + const struct vfsmount *parent_mnt,
75278 + const struct dentry *old_dentry,
75279 + const struct vfsmount *old_mnt, const struct filename *to);
75280 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
75281 +int gr_acl_handle_rename(struct dentry *new_dentry,
75282 + struct dentry *parent_dentry,
75283 + const struct vfsmount *parent_mnt,
75284 + struct dentry *old_dentry,
75285 + struct inode *old_parent_inode,
75286 + struct vfsmount *old_mnt, const struct filename *newname);
75287 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
75288 + struct dentry *old_dentry,
75289 + struct dentry *new_dentry,
75290 + struct vfsmount *mnt, const __u8 replace);
75291 +__u32 gr_check_link(const struct dentry *new_dentry,
75292 + const struct dentry *parent_dentry,
75293 + const struct vfsmount *parent_mnt,
75294 + const struct dentry *old_dentry,
75295 + const struct vfsmount *old_mnt);
75296 +int gr_acl_handle_filldir(const struct file *file, const char *name,
75297 + const unsigned int namelen, const ino_t ino);
75298 +
75299 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
75300 + const struct vfsmount *mnt);
75301 +void gr_acl_handle_exit(void);
75302 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
75303 +int gr_acl_handle_procpidmem(const struct task_struct *task);
75304 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
75305 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
75306 +void gr_audit_ptrace(struct task_struct *task);
75307 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
75308 +void gr_put_exec_file(struct task_struct *task);
75309 +
75310 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
75311 +
75312 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
75313 +extern void gr_learn_resource(const struct task_struct *task, const int res,
75314 + const unsigned long wanted, const int gt);
75315 +#else
75316 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
75317 + const unsigned long wanted, const int gt)
75318 +{
75319 +}
75320 +#endif
75321 +
75322 +#ifdef CONFIG_GRKERNSEC_RESLOG
75323 +extern void gr_log_resource(const struct task_struct *task, const int res,
75324 + const unsigned long wanted, const int gt);
75325 +#else
75326 +static inline void gr_log_resource(const struct task_struct *task, const int res,
75327 + const unsigned long wanted, const int gt)
75328 +{
75329 +}
75330 +#endif
75331 +
75332 +#ifdef CONFIG_GRKERNSEC
75333 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
75334 +void gr_handle_vm86(void);
75335 +void gr_handle_mem_readwrite(u64 from, u64 to);
75336 +
75337 +void gr_log_badprocpid(const char *entry);
75338 +
75339 +extern int grsec_enable_dmesg;
75340 +extern int grsec_disable_privio;
75341 +
75342 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75343 +extern kgid_t grsec_proc_gid;
75344 +#endif
75345 +
75346 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
75347 +extern int grsec_enable_chroot_findtask;
75348 +#endif
75349 +#ifdef CONFIG_GRKERNSEC_SETXID
75350 +extern int grsec_enable_setxid;
75351 +#endif
75352 +#endif
75353 +
75354 +#endif
75355 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
75356 new file mode 100644
75357 index 0000000..e7ffaaf
75358 --- /dev/null
75359 +++ b/include/linux/grsock.h
75360 @@ -0,0 +1,19 @@
75361 +#ifndef __GRSOCK_H
75362 +#define __GRSOCK_H
75363 +
75364 +extern void gr_attach_curr_ip(const struct sock *sk);
75365 +extern int gr_handle_sock_all(const int family, const int type,
75366 + const int protocol);
75367 +extern int gr_handle_sock_server(const struct sockaddr *sck);
75368 +extern int gr_handle_sock_server_other(const struct sock *sck);
75369 +extern int gr_handle_sock_client(const struct sockaddr *sck);
75370 +extern int gr_search_connect(struct socket * sock,
75371 + struct sockaddr_in * addr);
75372 +extern int gr_search_bind(struct socket * sock,
75373 + struct sockaddr_in * addr);
75374 +extern int gr_search_listen(struct socket * sock);
75375 +extern int gr_search_accept(struct socket * sock);
75376 +extern int gr_search_socket(const int domain, const int type,
75377 + const int protocol);
75378 +
75379 +#endif
75380 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
75381 index 7fb31da..08b5114 100644
75382 --- a/include/linux/highmem.h
75383 +++ b/include/linux/highmem.h
75384 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
75385 kunmap_atomic(kaddr);
75386 }
75387
75388 +static inline void sanitize_highpage(struct page *page)
75389 +{
75390 + void *kaddr;
75391 + unsigned long flags;
75392 +
75393 + local_irq_save(flags);
75394 + kaddr = kmap_atomic(page);
75395 + clear_page(kaddr);
75396 + kunmap_atomic(kaddr);
75397 + local_irq_restore(flags);
75398 +}
75399 +
75400 static inline void zero_user_segments(struct page *page,
75401 unsigned start1, unsigned end1,
75402 unsigned start2, unsigned end2)
75403 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
75404 index 1c7b89a..7dda400 100644
75405 --- a/include/linux/hwmon-sysfs.h
75406 +++ b/include/linux/hwmon-sysfs.h
75407 @@ -25,7 +25,8 @@
75408 struct sensor_device_attribute{
75409 struct device_attribute dev_attr;
75410 int index;
75411 -};
75412 +} __do_const;
75413 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
75414 #define to_sensor_dev_attr(_dev_attr) \
75415 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
75416
75417 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
75418 struct device_attribute dev_attr;
75419 u8 index;
75420 u8 nr;
75421 -};
75422 +} __do_const;
75423 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
75424 #define to_sensor_dev_attr_2(_dev_attr) \
75425 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
75426
75427 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
75428 index 2ab11dc..663a3f2 100644
75429 --- a/include/linux/i2c.h
75430 +++ b/include/linux/i2c.h
75431 @@ -366,6 +366,7 @@ struct i2c_algorithm {
75432 /* To determine what the adapter supports */
75433 u32 (*functionality) (struct i2c_adapter *);
75434 };
75435 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
75436
75437 /**
75438 * struct i2c_bus_recovery_info - I2C bus recovery information
75439 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
75440 index d23c3c2..eb63c81 100644
75441 --- a/include/linux/i2o.h
75442 +++ b/include/linux/i2o.h
75443 @@ -565,7 +565,7 @@ struct i2o_controller {
75444 struct i2o_device *exec; /* Executive */
75445 #if BITS_PER_LONG == 64
75446 spinlock_t context_list_lock; /* lock for context_list */
75447 - atomic_t context_list_counter; /* needed for unique contexts */
75448 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
75449 struct list_head context_list; /* list of context id's
75450 and pointers */
75451 #endif
75452 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
75453 index aff7ad8..3942bbd 100644
75454 --- a/include/linux/if_pppox.h
75455 +++ b/include/linux/if_pppox.h
75456 @@ -76,7 +76,7 @@ struct pppox_proto {
75457 int (*ioctl)(struct socket *sock, unsigned int cmd,
75458 unsigned long arg);
75459 struct module *owner;
75460 -};
75461 +} __do_const;
75462
75463 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
75464 extern void unregister_pppox_proto(int proto_num);
75465 diff --git a/include/linux/init.h b/include/linux/init.h
75466 index f1c27a71..7d6010e 100644
75467 --- a/include/linux/init.h
75468 +++ b/include/linux/init.h
75469 @@ -39,9 +39,17 @@
75470 * Also note, that this data cannot be "const".
75471 */
75472
75473 +#define add_init_latent_entropy __latent_entropy
75474 +
75475 +#ifdef CONFIG_MEMORY_HOTPLUG
75476 +#define add_meminit_latent_entropy
75477 +#else
75478 +#define add_meminit_latent_entropy __latent_entropy
75479 +#endif
75480 +
75481 /* These are for everybody (although not all archs will actually
75482 discard it in modules) */
75483 -#define __init __section(.init.text) __cold notrace
75484 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
75485 #define __initdata __section(.init.data)
75486 #define __initconst __constsection(.init.rodata)
75487 #define __exitdata __section(.exit.data)
75488 @@ -102,7 +110,7 @@
75489 #define __cpuexitconst
75490
75491 /* Used for MEMORY_HOTPLUG */
75492 -#define __meminit __section(.meminit.text) __cold notrace
75493 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
75494 #define __meminitdata __section(.meminit.data)
75495 #define __meminitconst __constsection(.meminit.rodata)
75496 #define __memexit __section(.memexit.text) __exitused __cold notrace
75497 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
75498 index 5cd0f09..c9f67cc 100644
75499 --- a/include/linux/init_task.h
75500 +++ b/include/linux/init_task.h
75501 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
75502
75503 #define INIT_TASK_COMM "swapper"
75504
75505 +#ifdef CONFIG_X86
75506 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
75507 +#else
75508 +#define INIT_TASK_THREAD_INFO
75509 +#endif
75510 +
75511 /*
75512 * INIT_TASK is used to set up the first task table, touch at
75513 * your own risk!. Base=0, limit=0x1fffff (=2MB)
75514 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
75515 RCU_POINTER_INITIALIZER(cred, &init_cred), \
75516 .comm = INIT_TASK_COMM, \
75517 .thread = INIT_THREAD, \
75518 + INIT_TASK_THREAD_INFO \
75519 .fs = &init_fs, \
75520 .files = &init_files, \
75521 .signal = &init_signals, \
75522 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
75523 index 5e865b5..71bd258 100644
75524 --- a/include/linux/interrupt.h
75525 +++ b/include/linux/interrupt.h
75526 @@ -361,7 +361,7 @@ enum
75527 /* map softirq index to softirq name. update 'softirq_to_name' in
75528 * kernel/softirq.c when adding a new softirq.
75529 */
75530 -extern char *softirq_to_name[NR_SOFTIRQS];
75531 +extern const char * const softirq_to_name[NR_SOFTIRQS];
75532
75533 /* softirq mask and active fields moved to irq_cpustat_t in
75534 * asm/hardirq.h to get better cache usage. KAO
75535 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
75536
75537 struct softirq_action
75538 {
75539 - void (*action)(struct softirq_action *);
75540 -};
75541 + void (*action)(void);
75542 +} __no_const;
75543
75544 asmlinkage void do_softirq(void);
75545 asmlinkage void __do_softirq(void);
75546 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
75547 +extern void open_softirq(int nr, void (*action)(void));
75548 extern void softirq_init(void);
75549 extern void __raise_softirq_irqoff(unsigned int nr);
75550
75551 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
75552 index 7ea319e..f9e971d 100644
75553 --- a/include/linux/iommu.h
75554 +++ b/include/linux/iommu.h
75555 @@ -129,7 +129,7 @@ struct iommu_ops {
75556 u32 (*domain_get_windows)(struct iommu_domain *domain);
75557
75558 unsigned long pgsize_bitmap;
75559 -};
75560 +} __do_const;
75561
75562 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
75563 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
75564 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
75565 index 89b7c24..382af74 100644
75566 --- a/include/linux/ioport.h
75567 +++ b/include/linux/ioport.h
75568 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
75569 int adjust_resource(struct resource *res, resource_size_t start,
75570 resource_size_t size);
75571 resource_size_t resource_alignment(struct resource *res);
75572 -static inline resource_size_t resource_size(const struct resource *res)
75573 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
75574 {
75575 return res->end - res->start + 1;
75576 }
75577 diff --git a/include/linux/irq.h b/include/linux/irq.h
75578 index 56bb0dc..8ae94d62 100644
75579 --- a/include/linux/irq.h
75580 +++ b/include/linux/irq.h
75581 @@ -333,7 +333,8 @@ struct irq_chip {
75582 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
75583
75584 unsigned long flags;
75585 -};
75586 +} __do_const;
75587 +typedef struct irq_chip __no_const irq_chip_no_const;
75588
75589 /*
75590 * irq_chip specific flags
75591 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
75592 index 0e5d9ec..46acb3a 100644
75593 --- a/include/linux/irqchip/arm-gic.h
75594 +++ b/include/linux/irqchip/arm-gic.h
75595 @@ -59,9 +59,11 @@
75596
75597 #ifndef __ASSEMBLY__
75598
75599 +#include <linux/irq.h>
75600 +
75601 struct device_node;
75602
75603 -extern struct irq_chip gic_arch_extn;
75604 +extern irq_chip_no_const gic_arch_extn;
75605
75606 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
75607 u32 offset, struct device_node *);
75608 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
75609 index d235e88..8ccbe74 100644
75610 --- a/include/linux/jiffies.h
75611 +++ b/include/linux/jiffies.h
75612 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
75613 /*
75614 * Convert various time units to each other:
75615 */
75616 -extern unsigned int jiffies_to_msecs(const unsigned long j);
75617 -extern unsigned int jiffies_to_usecs(const unsigned long j);
75618 -extern unsigned long msecs_to_jiffies(const unsigned int m);
75619 -extern unsigned long usecs_to_jiffies(const unsigned int u);
75620 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
75621 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
75622 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
75623 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
75624 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
75625 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
75626 extern void jiffies_to_timespec(const unsigned long jiffies,
75627 struct timespec *value);
75628 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
75629 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
75630 extern void jiffies_to_timeval(const unsigned long jiffies,
75631 struct timeval *value);
75632
75633 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
75634 index 6883e19..e854fcb 100644
75635 --- a/include/linux/kallsyms.h
75636 +++ b/include/linux/kallsyms.h
75637 @@ -15,7 +15,8 @@
75638
75639 struct module;
75640
75641 -#ifdef CONFIG_KALLSYMS
75642 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
75643 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75644 /* Lookup the address for a symbol. Returns 0 if not found. */
75645 unsigned long kallsyms_lookup_name(const char *name);
75646
75647 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
75648 /* Stupid that this does nothing, but I didn't create this mess. */
75649 #define __print_symbol(fmt, addr)
75650 #endif /*CONFIG_KALLSYMS*/
75651 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
75652 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
75653 +extern unsigned long kallsyms_lookup_name(const char *name);
75654 +extern void __print_symbol(const char *fmt, unsigned long address);
75655 +extern int sprint_backtrace(char *buffer, unsigned long address);
75656 +extern int sprint_symbol(char *buffer, unsigned long address);
75657 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
75658 +const char *kallsyms_lookup(unsigned long addr,
75659 + unsigned long *symbolsize,
75660 + unsigned long *offset,
75661 + char **modname, char *namebuf);
75662 +extern int kallsyms_lookup_size_offset(unsigned long addr,
75663 + unsigned long *symbolsize,
75664 + unsigned long *offset);
75665 +#endif
75666
75667 /* This macro allows us to keep printk typechecking */
75668 static __printf(1, 2)
75669 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
75670 index 518a53a..5e28358 100644
75671 --- a/include/linux/key-type.h
75672 +++ b/include/linux/key-type.h
75673 @@ -125,7 +125,7 @@ struct key_type {
75674 /* internal fields */
75675 struct list_head link; /* link in types list */
75676 struct lock_class_key lock_class; /* key->sem lock class */
75677 -};
75678 +} __do_const;
75679
75680 extern struct key_type key_type_keyring;
75681
75682 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
75683 index c6e091b..a940adf 100644
75684 --- a/include/linux/kgdb.h
75685 +++ b/include/linux/kgdb.h
75686 @@ -52,7 +52,7 @@ extern int kgdb_connected;
75687 extern int kgdb_io_module_registered;
75688
75689 extern atomic_t kgdb_setting_breakpoint;
75690 -extern atomic_t kgdb_cpu_doing_single_step;
75691 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
75692
75693 extern struct task_struct *kgdb_usethread;
75694 extern struct task_struct *kgdb_contthread;
75695 @@ -254,7 +254,7 @@ struct kgdb_arch {
75696 void (*correct_hw_break)(void);
75697
75698 void (*enable_nmi)(bool on);
75699 -};
75700 +} __do_const;
75701
75702 /**
75703 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
75704 @@ -279,7 +279,7 @@ struct kgdb_io {
75705 void (*pre_exception) (void);
75706 void (*post_exception) (void);
75707 int is_console;
75708 -};
75709 +} __do_const;
75710
75711 extern struct kgdb_arch arch_kgdb_ops;
75712
75713 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
75714 index 0555cc6..40116ce 100644
75715 --- a/include/linux/kmod.h
75716 +++ b/include/linux/kmod.h
75717 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
75718 * usually useless though. */
75719 extern __printf(2, 3)
75720 int __request_module(bool wait, const char *name, ...);
75721 +extern __printf(3, 4)
75722 +int ___request_module(bool wait, char *param_name, const char *name, ...);
75723 #define request_module(mod...) __request_module(true, mod)
75724 #define request_module_nowait(mod...) __request_module(false, mod)
75725 #define try_then_request_module(x, mod...) \
75726 @@ -57,6 +59,9 @@ struct subprocess_info {
75727 struct work_struct work;
75728 struct completion *complete;
75729 char *path;
75730 +#ifdef CONFIG_GRKERNSEC
75731 + char *origpath;
75732 +#endif
75733 char **argv;
75734 char **envp;
75735 int wait;
75736 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
75737 index de6dcbcc..4735f88 100644
75738 --- a/include/linux/kobject.h
75739 +++ b/include/linux/kobject.h
75740 @@ -115,7 +115,7 @@ struct kobj_type {
75741 struct attribute **default_attrs;
75742 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
75743 const void *(*namespace)(struct kobject *kobj);
75744 -};
75745 +} __do_const;
75746
75747 struct kobj_uevent_env {
75748 char *envp[UEVENT_NUM_ENVP];
75749 @@ -138,6 +138,7 @@ struct kobj_attribute {
75750 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
75751 const char *buf, size_t count);
75752 };
75753 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
75754
75755 extern const struct sysfs_ops kobj_sysfs_ops;
75756
75757 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
75758 index df32d25..fb52e27 100644
75759 --- a/include/linux/kobject_ns.h
75760 +++ b/include/linux/kobject_ns.h
75761 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
75762 const void *(*netlink_ns)(struct sock *sk);
75763 const void *(*initial_ns)(void);
75764 void (*drop_ns)(void *);
75765 -};
75766 +} __do_const;
75767
75768 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
75769 int kobj_ns_type_registered(enum kobj_ns_type type);
75770 diff --git a/include/linux/kref.h b/include/linux/kref.h
75771 index 484604d..0f6c5b6 100644
75772 --- a/include/linux/kref.h
75773 +++ b/include/linux/kref.h
75774 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
75775 static inline int kref_sub(struct kref *kref, unsigned int count,
75776 void (*release)(struct kref *kref))
75777 {
75778 - WARN_ON(release == NULL);
75779 + BUG_ON(release == NULL);
75780
75781 if (atomic_sub_and_test((int) count, &kref->refcount)) {
75782 release(kref);
75783 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
75784 index 0fbbc7a..db081e3 100644
75785 --- a/include/linux/kvm_host.h
75786 +++ b/include/linux/kvm_host.h
75787 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
75788 {
75789 }
75790 #endif
75791 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75792 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75793 struct module *module);
75794 void kvm_exit(void);
75795
75796 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
75797 struct kvm_guest_debug *dbg);
75798 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
75799
75800 -int kvm_arch_init(void *opaque);
75801 +int kvm_arch_init(const void *opaque);
75802 void kvm_arch_exit(void);
75803
75804 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
75805 diff --git a/include/linux/libata.h b/include/linux/libata.h
75806 index 0e23c26..6ad8c33 100644
75807 --- a/include/linux/libata.h
75808 +++ b/include/linux/libata.h
75809 @@ -972,7 +972,7 @@ struct ata_port_operations {
75810 * fields must be pointers.
75811 */
75812 const struct ata_port_operations *inherits;
75813 -};
75814 +} __do_const;
75815
75816 struct ata_port_info {
75817 unsigned long flags;
75818 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
75819 index d3e8ad2..a949f68 100644
75820 --- a/include/linux/linkage.h
75821 +++ b/include/linux/linkage.h
75822 @@ -31,6 +31,7 @@
75823 #endif
75824
75825 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
75826 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
75827 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
75828
75829 /*
75830 diff --git a/include/linux/list.h b/include/linux/list.h
75831 index f4d8a2f..38e6e46 100644
75832 --- a/include/linux/list.h
75833 +++ b/include/linux/list.h
75834 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
75835 extern void list_del(struct list_head *entry);
75836 #endif
75837
75838 +extern void __pax_list_add(struct list_head *new,
75839 + struct list_head *prev,
75840 + struct list_head *next);
75841 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
75842 +{
75843 + __pax_list_add(new, head, head->next);
75844 +}
75845 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
75846 +{
75847 + __pax_list_add(new, head->prev, head);
75848 +}
75849 +extern void pax_list_del(struct list_head *entry);
75850 +
75851 /**
75852 * list_replace - replace old entry by new one
75853 * @old : the element to be replaced
75854 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
75855 INIT_LIST_HEAD(entry);
75856 }
75857
75858 +extern void pax_list_del_init(struct list_head *entry);
75859 +
75860 /**
75861 * list_move - delete from one list and add as another's head
75862 * @list: the entry to move
75863 diff --git a/include/linux/math64.h b/include/linux/math64.h
75864 index 69ed5f5..243ed51 100644
75865 --- a/include/linux/math64.h
75866 +++ b/include/linux/math64.h
75867 @@ -15,7 +15,7 @@
75868 * This is commonly provided by 32bit archs to provide an optimized 64bit
75869 * divide.
75870 */
75871 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75872 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75873 {
75874 *remainder = dividend % divisor;
75875 return dividend / divisor;
75876 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
75877 /**
75878 * div64_u64 - unsigned 64bit divide with 64bit divisor
75879 */
75880 -static inline u64 div64_u64(u64 dividend, u64 divisor)
75881 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
75882 {
75883 return dividend / divisor;
75884 }
75885 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
75886 #define div64_ul(x, y) div_u64((x), (y))
75887
75888 #ifndef div_u64_rem
75889 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75890 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75891 {
75892 *remainder = do_div(dividend, divisor);
75893 return dividend;
75894 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
75895 #endif
75896
75897 #ifndef div64_u64
75898 -extern u64 div64_u64(u64 dividend, u64 divisor);
75899 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
75900 #endif
75901
75902 #ifndef div64_s64
75903 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75904 * divide.
75905 */
75906 #ifndef div_u64
75907 -static inline u64 div_u64(u64 dividend, u32 divisor)
75908 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75909 {
75910 u32 remainder;
75911 return div_u64_rem(dividend, divisor, &remainder);
75912 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
75913 index da6716b..2e31db3 100644
75914 --- a/include/linux/mempolicy.h
75915 +++ b/include/linux/mempolicy.h
75916 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
75917 }
75918
75919 #define vma_policy(vma) ((vma)->vm_policy)
75920 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
75921 +{
75922 + vma->vm_policy = pol;
75923 +}
75924
75925 static inline void mpol_get(struct mempolicy *pol)
75926 {
75927 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
75928 }
75929
75930 #define vma_policy(vma) NULL
75931 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
75932 +{
75933 +}
75934
75935 static inline int
75936 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
75937 diff --git a/include/linux/mm.h b/include/linux/mm.h
75938 index 8b6e55e..c4edf39 100644
75939 --- a/include/linux/mm.h
75940 +++ b/include/linux/mm.h
75941 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75942 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75943 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75944 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75945 +
75946 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75947 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75948 +#endif
75949 +
75950 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75951
75952 #ifdef CONFIG_MEM_SOFT_DIRTY
75953 @@ -215,8 +220,8 @@ struct vm_operations_struct {
75954 /* called by access_process_vm when get_user_pages() fails, typically
75955 * for use by special VMAs that can switch between memory and hardware
75956 */
75957 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75958 - void *buf, int len, int write);
75959 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75960 + void *buf, size_t len, int write);
75961 #ifdef CONFIG_NUMA
75962 /*
75963 * set_policy() op must add a reference to any non-NULL @new mempolicy
75964 @@ -246,6 +251,7 @@ struct vm_operations_struct {
75965 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75966 unsigned long size, pgoff_t pgoff);
75967 };
75968 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75969
75970 struct mmu_gather;
75971 struct inode;
75972 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75973 unsigned long *pfn);
75974 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75975 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75976 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75977 - void *buf, int len, int write);
75978 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75979 + void *buf, size_t len, int write);
75980
75981 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75982 loff_t const holebegin, loff_t const holelen)
75983 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75984 }
75985 #endif
75986
75987 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75988 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75989 - void *buf, int len, int write);
75990 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75991 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75992 + void *buf, size_t len, int write);
75993
75994 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75995 unsigned long start, unsigned long nr_pages,
75996 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
75997 int set_page_dirty_lock(struct page *page);
75998 int clear_page_dirty_for_io(struct page *page);
75999
76000 -/* Is the vma a continuation of the stack vma above it? */
76001 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
76002 -{
76003 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
76004 -}
76005 -
76006 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
76007 - unsigned long addr)
76008 -{
76009 - return (vma->vm_flags & VM_GROWSDOWN) &&
76010 - (vma->vm_start == addr) &&
76011 - !vma_growsdown(vma->vm_prev, addr);
76012 -}
76013 -
76014 -/* Is the vma a continuation of the stack vma below it? */
76015 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
76016 -{
76017 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
76018 -}
76019 -
76020 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
76021 - unsigned long addr)
76022 -{
76023 - return (vma->vm_flags & VM_GROWSUP) &&
76024 - (vma->vm_end == addr) &&
76025 - !vma_growsup(vma->vm_next, addr);
76026 -}
76027 -
76028 extern pid_t
76029 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
76030
76031 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
76032 }
76033 #endif
76034
76035 +#ifdef CONFIG_MMU
76036 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
76037 +#else
76038 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
76039 +{
76040 + return __pgprot(0);
76041 +}
76042 +#endif
76043 +
76044 int vma_wants_writenotify(struct vm_area_struct *vma);
76045
76046 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
76047 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
76048 {
76049 return 0;
76050 }
76051 +
76052 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
76053 + unsigned long address)
76054 +{
76055 + return 0;
76056 +}
76057 #else
76058 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76059 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76060 #endif
76061
76062 #ifdef __PAGETABLE_PMD_FOLDED
76063 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
76064 {
76065 return 0;
76066 }
76067 +
76068 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
76069 + unsigned long address)
76070 +{
76071 + return 0;
76072 +}
76073 #else
76074 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
76075 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
76076 #endif
76077
76078 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
76079 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
76080 NULL: pud_offset(pgd, address);
76081 }
76082
76083 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
76084 +{
76085 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
76086 + NULL: pud_offset(pgd, address);
76087 +}
76088 +
76089 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
76090 {
76091 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
76092 NULL: pmd_offset(pud, address);
76093 }
76094 +
76095 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
76096 +{
76097 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
76098 + NULL: pmd_offset(pud, address);
76099 +}
76100 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
76101
76102 #if USE_SPLIT_PTLOCKS
76103 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
76104 unsigned long addr, unsigned long len,
76105 unsigned long flags, struct page **pages);
76106
76107 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
76108 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
76109
76110 extern unsigned long mmap_region(struct file *file, unsigned long addr,
76111 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
76112 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
76113 unsigned long len, unsigned long prot, unsigned long flags,
76114 unsigned long pgoff, unsigned long *populate);
76115 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
76116 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
76117
76118 #ifdef CONFIG_MMU
76119 extern int __mm_populate(unsigned long addr, unsigned long len,
76120 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
76121 unsigned long high_limit;
76122 unsigned long align_mask;
76123 unsigned long align_offset;
76124 + unsigned long threadstack_offset;
76125 };
76126
76127 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
76128 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76129 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
76130 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
76131
76132 /*
76133 * Search for an unmapped address range.
76134 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76135 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
76136 */
76137 static inline unsigned long
76138 -vm_unmapped_area(struct vm_unmapped_area_info *info)
76139 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
76140 {
76141 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
76142 return unmapped_area(info);
76143 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
76144 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
76145 struct vm_area_struct **pprev);
76146
76147 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
76148 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
76149 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
76150 +
76151 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
76152 NULL if none. Assume start_addr < end_addr. */
76153 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
76154 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
76155 return vma;
76156 }
76157
76158 -#ifdef CONFIG_MMU
76159 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
76160 -#else
76161 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
76162 -{
76163 - return __pgprot(0);
76164 -}
76165 -#endif
76166 -
76167 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
76168 unsigned long change_prot_numa(struct vm_area_struct *vma,
76169 unsigned long start, unsigned long end);
76170 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
76171 static inline void vm_stat_account(struct mm_struct *mm,
76172 unsigned long flags, struct file *file, long pages)
76173 {
76174 +
76175 +#ifdef CONFIG_PAX_RANDMMAP
76176 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
76177 +#endif
76178 +
76179 mm->total_vm += pages;
76180 }
76181 #endif /* CONFIG_PROC_FS */
76182 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
76183 extern int sysctl_memory_failure_early_kill;
76184 extern int sysctl_memory_failure_recovery;
76185 extern void shake_page(struct page *p, int access);
76186 -extern atomic_long_t num_poisoned_pages;
76187 +extern atomic_long_unchecked_t num_poisoned_pages;
76188 extern int soft_offline_page(struct page *page, int flags);
76189
76190 extern void dump_page(struct page *page);
76191 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
76192 static inline void setup_nr_node_ids(void) {}
76193 #endif
76194
76195 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
76196 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
76197 +#else
76198 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
76199 +#endif
76200 +
76201 #endif /* __KERNEL__ */
76202 #endif /* _LINUX_MM_H */
76203 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
76204 index d9851ee..619492d 100644
76205 --- a/include/linux/mm_types.h
76206 +++ b/include/linux/mm_types.h
76207 @@ -289,6 +289,8 @@ struct vm_area_struct {
76208 #ifdef CONFIG_NUMA
76209 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
76210 #endif
76211 +
76212 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
76213 };
76214
76215 struct core_thread {
76216 @@ -436,6 +438,24 @@ struct mm_struct {
76217 int first_nid;
76218 #endif
76219 struct uprobes_state uprobes_state;
76220 +
76221 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76222 + unsigned long pax_flags;
76223 +#endif
76224 +
76225 +#ifdef CONFIG_PAX_DLRESOLVE
76226 + unsigned long call_dl_resolve;
76227 +#endif
76228 +
76229 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
76230 + unsigned long call_syscall;
76231 +#endif
76232 +
76233 +#ifdef CONFIG_PAX_ASLR
76234 + unsigned long delta_mmap; /* randomized offset */
76235 + unsigned long delta_stack; /* randomized offset */
76236 +#endif
76237 +
76238 };
76239
76240 /* first nid will either be a valid NID or one of these values */
76241 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
76242 index c5d5278..f0b68c8 100644
76243 --- a/include/linux/mmiotrace.h
76244 +++ b/include/linux/mmiotrace.h
76245 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
76246 /* Called from ioremap.c */
76247 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
76248 void __iomem *addr);
76249 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
76250 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
76251
76252 /* For anyone to insert markers. Remember trailing newline. */
76253 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
76254 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
76255 {
76256 }
76257
76258 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
76259 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
76260 {
76261 }
76262
76263 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
76264 index bd791e4..8617c34f 100644
76265 --- a/include/linux/mmzone.h
76266 +++ b/include/linux/mmzone.h
76267 @@ -396,7 +396,7 @@ struct zone {
76268 unsigned long flags; /* zone flags, see below */
76269
76270 /* Zone statistics */
76271 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76272 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76273
76274 /*
76275 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
76276 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
76277 index 45e9214..a7227d6 100644
76278 --- a/include/linux/mod_devicetable.h
76279 +++ b/include/linux/mod_devicetable.h
76280 @@ -13,7 +13,7 @@
76281 typedef unsigned long kernel_ulong_t;
76282 #endif
76283
76284 -#define PCI_ANY_ID (~0)
76285 +#define PCI_ANY_ID ((__u16)~0)
76286
76287 struct pci_device_id {
76288 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
76289 @@ -139,7 +139,7 @@ struct usb_device_id {
76290 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
76291 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
76292
76293 -#define HID_ANY_ID (~0)
76294 +#define HID_ANY_ID (~0U)
76295 #define HID_BUS_ANY 0xffff
76296 #define HID_GROUP_ANY 0x0000
76297
76298 @@ -467,7 +467,7 @@ struct dmi_system_id {
76299 const char *ident;
76300 struct dmi_strmatch matches[4];
76301 void *driver_data;
76302 -};
76303 +} __do_const;
76304 /*
76305 * struct dmi_device_id appears during expansion of
76306 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
76307 diff --git a/include/linux/module.h b/include/linux/module.h
76308 index 05f2447..2aee07c 100644
76309 --- a/include/linux/module.h
76310 +++ b/include/linux/module.h
76311 @@ -17,9 +17,11 @@
76312 #include <linux/moduleparam.h>
76313 #include <linux/tracepoint.h>
76314 #include <linux/export.h>
76315 +#include <linux/fs.h>
76316
76317 #include <linux/percpu.h>
76318 #include <asm/module.h>
76319 +#include <asm/pgtable.h>
76320
76321 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
76322 #define MODULE_SIG_STRING "~Module signature appended~\n"
76323 @@ -55,12 +57,13 @@ struct module_attribute {
76324 int (*test)(struct module *);
76325 void (*free)(struct module *);
76326 };
76327 +typedef struct module_attribute __no_const module_attribute_no_const;
76328
76329 struct module_version_attribute {
76330 struct module_attribute mattr;
76331 const char *module_name;
76332 const char *version;
76333 -} __attribute__ ((__aligned__(sizeof(void *))));
76334 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
76335
76336 extern ssize_t __modver_version_show(struct module_attribute *,
76337 struct module_kobject *, char *);
76338 @@ -238,7 +241,7 @@ struct module
76339
76340 /* Sysfs stuff. */
76341 struct module_kobject mkobj;
76342 - struct module_attribute *modinfo_attrs;
76343 + module_attribute_no_const *modinfo_attrs;
76344 const char *version;
76345 const char *srcversion;
76346 struct kobject *holders_dir;
76347 @@ -287,19 +290,16 @@ struct module
76348 int (*init)(void);
76349
76350 /* If this is non-NULL, vfree after init() returns */
76351 - void *module_init;
76352 + void *module_init_rx, *module_init_rw;
76353
76354 /* Here is the actual code + data, vfree'd on unload. */
76355 - void *module_core;
76356 + void *module_core_rx, *module_core_rw;
76357
76358 /* Here are the sizes of the init and core sections */
76359 - unsigned int init_size, core_size;
76360 + unsigned int init_size_rw, core_size_rw;
76361
76362 /* The size of the executable code in each section. */
76363 - unsigned int init_text_size, core_text_size;
76364 -
76365 - /* Size of RO sections of the module (text+rodata) */
76366 - unsigned int init_ro_size, core_ro_size;
76367 + unsigned int init_size_rx, core_size_rx;
76368
76369 /* Arch-specific module values */
76370 struct mod_arch_specific arch;
76371 @@ -355,6 +355,10 @@ struct module
76372 #ifdef CONFIG_EVENT_TRACING
76373 struct ftrace_event_call **trace_events;
76374 unsigned int num_trace_events;
76375 + struct file_operations trace_id;
76376 + struct file_operations trace_enable;
76377 + struct file_operations trace_format;
76378 + struct file_operations trace_filter;
76379 #endif
76380 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
76381 unsigned int num_ftrace_callsites;
76382 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
76383 bool is_module_percpu_address(unsigned long addr);
76384 bool is_module_text_address(unsigned long addr);
76385
76386 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
76387 +{
76388 +
76389 +#ifdef CONFIG_PAX_KERNEXEC
76390 + if (ktla_ktva(addr) >= (unsigned long)start &&
76391 + ktla_ktva(addr) < (unsigned long)start + size)
76392 + return 1;
76393 +#endif
76394 +
76395 + return ((void *)addr >= start && (void *)addr < start + size);
76396 +}
76397 +
76398 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
76399 +{
76400 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
76401 +}
76402 +
76403 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
76404 +{
76405 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
76406 +}
76407 +
76408 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
76409 +{
76410 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
76411 +}
76412 +
76413 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
76414 +{
76415 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
76416 +}
76417 +
76418 static inline int within_module_core(unsigned long addr, const struct module *mod)
76419 {
76420 - return (unsigned long)mod->module_core <= addr &&
76421 - addr < (unsigned long)mod->module_core + mod->core_size;
76422 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
76423 }
76424
76425 static inline int within_module_init(unsigned long addr, const struct module *mod)
76426 {
76427 - return (unsigned long)mod->module_init <= addr &&
76428 - addr < (unsigned long)mod->module_init + mod->init_size;
76429 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
76430 }
76431
76432 /* Search for module by name: must hold module_mutex. */
76433 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
76434 index 560ca53..ef621ef 100644
76435 --- a/include/linux/moduleloader.h
76436 +++ b/include/linux/moduleloader.h
76437 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
76438 sections. Returns NULL on failure. */
76439 void *module_alloc(unsigned long size);
76440
76441 +#ifdef CONFIG_PAX_KERNEXEC
76442 +void *module_alloc_exec(unsigned long size);
76443 +#else
76444 +#define module_alloc_exec(x) module_alloc(x)
76445 +#endif
76446 +
76447 /* Free memory returned from module_alloc. */
76448 void module_free(struct module *mod, void *module_region);
76449
76450 +#ifdef CONFIG_PAX_KERNEXEC
76451 +void module_free_exec(struct module *mod, void *module_region);
76452 +#else
76453 +#define module_free_exec(x, y) module_free((x), (y))
76454 +#endif
76455 +
76456 /*
76457 * Apply the given relocation to the (simplified) ELF. Return -error
76458 * or 0.
76459 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
76460 unsigned int relsec,
76461 struct module *me)
76462 {
76463 +#ifdef CONFIG_MODULES
76464 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76465 +#endif
76466 return -ENOEXEC;
76467 }
76468 #endif
76469 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
76470 unsigned int relsec,
76471 struct module *me)
76472 {
76473 +#ifdef CONFIG_MODULES
76474 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76475 +#endif
76476 return -ENOEXEC;
76477 }
76478 #endif
76479 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
76480 index c3eb102..073c4a6 100644
76481 --- a/include/linux/moduleparam.h
76482 +++ b/include/linux/moduleparam.h
76483 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
76484 * @len is usually just sizeof(string).
76485 */
76486 #define module_param_string(name, string, len, perm) \
76487 - static const struct kparam_string __param_string_##name \
76488 + static const struct kparam_string __param_string_##name __used \
76489 = { len, string }; \
76490 __module_param_call(MODULE_PARAM_PREFIX, name, \
76491 &param_ops_string, \
76492 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
76493 */
76494 #define module_param_array_named(name, array, type, nump, perm) \
76495 param_check_##type(name, &(array)[0]); \
76496 - static const struct kparam_array __param_arr_##name \
76497 + static const struct kparam_array __param_arr_##name __used \
76498 = { .max = ARRAY_SIZE(array), .num = nump, \
76499 .ops = &param_ops_##type, \
76500 .elemsize = sizeof(array[0]), .elem = array }; \
76501 diff --git a/include/linux/namei.h b/include/linux/namei.h
76502 index 8e47bc7..c70fd73 100644
76503 --- a/include/linux/namei.h
76504 +++ b/include/linux/namei.h
76505 @@ -19,7 +19,7 @@ struct nameidata {
76506 unsigned seq;
76507 int last_type;
76508 unsigned depth;
76509 - char *saved_names[MAX_NESTED_LINKS + 1];
76510 + const char *saved_names[MAX_NESTED_LINKS + 1];
76511 };
76512
76513 /*
76514 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
76515
76516 extern void nd_jump_link(struct nameidata *nd, struct path *path);
76517
76518 -static inline void nd_set_link(struct nameidata *nd, char *path)
76519 +static inline void nd_set_link(struct nameidata *nd, const char *path)
76520 {
76521 nd->saved_names[nd->depth] = path;
76522 }
76523
76524 -static inline char *nd_get_link(struct nameidata *nd)
76525 +static inline const char *nd_get_link(const struct nameidata *nd)
76526 {
76527 return nd->saved_names[nd->depth];
76528 }
76529 diff --git a/include/linux/net.h b/include/linux/net.h
76530 index 4f27575..fc8a65f 100644
76531 --- a/include/linux/net.h
76532 +++ b/include/linux/net.h
76533 @@ -183,7 +183,7 @@ struct net_proto_family {
76534 int (*create)(struct net *net, struct socket *sock,
76535 int protocol, int kern);
76536 struct module *owner;
76537 -};
76538 +} __do_const;
76539
76540 struct iovec;
76541 struct kvec;
76542 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
76543 index 25f5d2d1..5cf2120 100644
76544 --- a/include/linux/netdevice.h
76545 +++ b/include/linux/netdevice.h
76546 @@ -1098,6 +1098,7 @@ struct net_device_ops {
76547 sa_family_t sa_family,
76548 __be16 port);
76549 };
76550 +typedef struct net_device_ops __no_const net_device_ops_no_const;
76551
76552 /*
76553 * The DEVICE structure.
76554 @@ -1169,7 +1170,7 @@ struct net_device {
76555 int iflink;
76556
76557 struct net_device_stats stats;
76558 - atomic_long_t rx_dropped; /* dropped packets by core network
76559 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
76560 * Do not use this in drivers.
76561 */
76562
76563 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
76564 index 708fe72ab9..77084a3 100644
76565 --- a/include/linux/netfilter.h
76566 +++ b/include/linux/netfilter.h
76567 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
76568 #endif
76569 /* Use the module struct to lock set/get code in place */
76570 struct module *owner;
76571 -};
76572 +} __do_const;
76573
76574 /* Function to register/unregister hook points. */
76575 int nf_register_hook(struct nf_hook_ops *reg);
76576 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
76577 index 9ac9fbd..f92edb4 100644
76578 --- a/include/linux/netfilter/ipset/ip_set.h
76579 +++ b/include/linux/netfilter/ipset/ip_set.h
76580 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
76581 /* Return true if "b" set is the same as "a"
76582 * according to the create set parameters */
76583 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
76584 -};
76585 +} __do_const;
76586
76587 /* The core set type structure */
76588 struct ip_set_type {
76589 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
76590 index cadb740..d7c37c0 100644
76591 --- a/include/linux/netfilter/nfnetlink.h
76592 +++ b/include/linux/netfilter/nfnetlink.h
76593 @@ -16,7 +16,7 @@ struct nfnl_callback {
76594 const struct nlattr * const cda[]);
76595 const struct nla_policy *policy; /* netlink attribute policy */
76596 const u_int16_t attr_count; /* number of nlattr's */
76597 -};
76598 +} __do_const;
76599
76600 struct nfnetlink_subsystem {
76601 const char *name;
76602 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
76603 new file mode 100644
76604 index 0000000..33f4af8
76605 --- /dev/null
76606 +++ b/include/linux/netfilter/xt_gradm.h
76607 @@ -0,0 +1,9 @@
76608 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
76609 +#define _LINUX_NETFILTER_XT_GRADM_H 1
76610 +
76611 +struct xt_gradm_mtinfo {
76612 + __u16 flags;
76613 + __u16 invflags;
76614 +};
76615 +
76616 +#endif
76617 diff --git a/include/linux/nls.h b/include/linux/nls.h
76618 index 5dc635f..35f5e11 100644
76619 --- a/include/linux/nls.h
76620 +++ b/include/linux/nls.h
76621 @@ -31,7 +31,7 @@ struct nls_table {
76622 const unsigned char *charset2upper;
76623 struct module *owner;
76624 struct nls_table *next;
76625 -};
76626 +} __do_const;
76627
76628 /* this value hold the maximum octet of charset */
76629 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
76630 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
76631 index d14a4c3..a078786 100644
76632 --- a/include/linux/notifier.h
76633 +++ b/include/linux/notifier.h
76634 @@ -54,7 +54,8 @@ struct notifier_block {
76635 notifier_fn_t notifier_call;
76636 struct notifier_block __rcu *next;
76637 int priority;
76638 -};
76639 +} __do_const;
76640 +typedef struct notifier_block __no_const notifier_block_no_const;
76641
76642 struct atomic_notifier_head {
76643 spinlock_t lock;
76644 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
76645 index b2a0f15..4d7da32 100644
76646 --- a/include/linux/oprofile.h
76647 +++ b/include/linux/oprofile.h
76648 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
76649 int oprofilefs_create_ro_ulong(struct dentry * root,
76650 char const * name, ulong * val);
76651
76652 -/** Create a file for read-only access to an atomic_t. */
76653 +/** Create a file for read-only access to an atomic_unchecked_t. */
76654 int oprofilefs_create_ro_atomic(struct dentry * root,
76655 - char const * name, atomic_t * val);
76656 + char const * name, atomic_unchecked_t * val);
76657
76658 /** create a directory */
76659 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
76660 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
76661 index 430dd96..544e26e 100644
76662 --- a/include/linux/pci_hotplug.h
76663 +++ b/include/linux/pci_hotplug.h
76664 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
76665 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
76666 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
76667 int (*reset_slot) (struct hotplug_slot *slot, int probe);
76668 -};
76669 +} __do_const;
76670 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
76671
76672 /**
76673 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
76674 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
76675 index c8ba627..24bdfa8 100644
76676 --- a/include/linux/perf_event.h
76677 +++ b/include/linux/perf_event.h
76678 @@ -327,8 +327,8 @@ struct perf_event {
76679
76680 enum perf_event_active_state state;
76681 unsigned int attach_state;
76682 - local64_t count;
76683 - atomic64_t child_count;
76684 + local64_t count; /* PaX: fix it one day */
76685 + atomic64_unchecked_t child_count;
76686
76687 /*
76688 * These are the total time in nanoseconds that the event
76689 @@ -379,8 +379,8 @@ struct perf_event {
76690 * These accumulate total time (in nanoseconds) that children
76691 * events have been enabled and running, respectively.
76692 */
76693 - atomic64_t child_total_time_enabled;
76694 - atomic64_t child_total_time_running;
76695 + atomic64_unchecked_t child_total_time_enabled;
76696 + atomic64_unchecked_t child_total_time_running;
76697
76698 /*
76699 * Protect attach/detach and child_list:
76700 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
76701 entry->ip[entry->nr++] = ip;
76702 }
76703
76704 -extern int sysctl_perf_event_paranoid;
76705 +extern int sysctl_perf_event_legitimately_concerned;
76706 extern int sysctl_perf_event_mlock;
76707 extern int sysctl_perf_event_sample_rate;
76708 extern int sysctl_perf_cpu_time_max_percent;
76709 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
76710 loff_t *ppos);
76711
76712
76713 +static inline bool perf_paranoid_any(void)
76714 +{
76715 + return sysctl_perf_event_legitimately_concerned > 2;
76716 +}
76717 +
76718 static inline bool perf_paranoid_tracepoint_raw(void)
76719 {
76720 - return sysctl_perf_event_paranoid > -1;
76721 + return sysctl_perf_event_legitimately_concerned > -1;
76722 }
76723
76724 static inline bool perf_paranoid_cpu(void)
76725 {
76726 - return sysctl_perf_event_paranoid > 0;
76727 + return sysctl_perf_event_legitimately_concerned > 0;
76728 }
76729
76730 static inline bool perf_paranoid_kernel(void)
76731 {
76732 - return sysctl_perf_event_paranoid > 1;
76733 + return sysctl_perf_event_legitimately_concerned > 1;
76734 }
76735
76736 extern void perf_event_init(void);
76737 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
76738 struct device_attribute attr;
76739 u64 id;
76740 const char *event_str;
76741 -};
76742 +} __do_const;
76743
76744 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
76745 static struct perf_pmu_events_attr _var = { \
76746 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
76747 index b8809fe..ae4ccd0 100644
76748 --- a/include/linux/pipe_fs_i.h
76749 +++ b/include/linux/pipe_fs_i.h
76750 @@ -47,10 +47,10 @@ struct pipe_inode_info {
76751 struct mutex mutex;
76752 wait_queue_head_t wait;
76753 unsigned int nrbufs, curbuf, buffers;
76754 - unsigned int readers;
76755 - unsigned int writers;
76756 - unsigned int files;
76757 - unsigned int waiting_writers;
76758 + atomic_t readers;
76759 + atomic_t writers;
76760 + atomic_t files;
76761 + atomic_t waiting_writers;
76762 unsigned int r_counter;
76763 unsigned int w_counter;
76764 struct page *tmp_page;
76765 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
76766 index 5f28cae..3d23723 100644
76767 --- a/include/linux/platform_data/usb-ehci-s5p.h
76768 +++ b/include/linux/platform_data/usb-ehci-s5p.h
76769 @@ -14,7 +14,7 @@
76770 struct s5p_ehci_platdata {
76771 int (*phy_init)(struct platform_device *pdev, int type);
76772 int (*phy_exit)(struct platform_device *pdev, int type);
76773 -};
76774 +} __no_const;
76775
76776 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
76777
76778 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
76779 index c256c59..8ea94c7 100644
76780 --- a/include/linux/platform_data/usb-ohci-exynos.h
76781 +++ b/include/linux/platform_data/usb-ohci-exynos.h
76782 @@ -14,7 +14,7 @@
76783 struct exynos4_ohci_platdata {
76784 int (*phy_init)(struct platform_device *pdev, int type);
76785 int (*phy_exit)(struct platform_device *pdev, int type);
76786 -};
76787 +} __no_const;
76788
76789 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
76790
76791 diff --git a/include/linux/pm.h b/include/linux/pm.h
76792 index a224c7f..92d8a97 100644
76793 --- a/include/linux/pm.h
76794 +++ b/include/linux/pm.h
76795 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
76796 struct dev_pm_domain {
76797 struct dev_pm_ops ops;
76798 };
76799 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
76800
76801 /*
76802 * The PM_EVENT_ messages are also used by drivers implementing the legacy
76803 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
76804 index 7c1d252..c5c773e 100644
76805 --- a/include/linux/pm_domain.h
76806 +++ b/include/linux/pm_domain.h
76807 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
76808
76809 struct gpd_cpu_data {
76810 unsigned int saved_exit_latency;
76811 - struct cpuidle_state *idle_state;
76812 + cpuidle_state_no_const *idle_state;
76813 };
76814
76815 struct generic_pm_domain {
76816 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
76817 index 6fa7cea..7bf6415 100644
76818 --- a/include/linux/pm_runtime.h
76819 +++ b/include/linux/pm_runtime.h
76820 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
76821
76822 static inline void pm_runtime_mark_last_busy(struct device *dev)
76823 {
76824 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
76825 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
76826 }
76827
76828 #else /* !CONFIG_PM_RUNTIME */
76829 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
76830 index 195aafc..49a7bc2 100644
76831 --- a/include/linux/pnp.h
76832 +++ b/include/linux/pnp.h
76833 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
76834 struct pnp_fixup {
76835 char id[7];
76836 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
76837 -};
76838 +} __do_const;
76839
76840 /* config parameters */
76841 #define PNP_CONFIG_NORMAL 0x0001
76842 diff --git a/include/linux/poison.h b/include/linux/poison.h
76843 index 2110a81..13a11bb 100644
76844 --- a/include/linux/poison.h
76845 +++ b/include/linux/poison.h
76846 @@ -19,8 +19,8 @@
76847 * under normal circumstances, used to verify that nobody uses
76848 * non-initialized list entries.
76849 */
76850 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
76851 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
76852 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
76853 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
76854
76855 /********** include/linux/timer.h **********/
76856 /*
76857 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
76858 index d8b187c3..9a9257a 100644
76859 --- a/include/linux/power/smartreflex.h
76860 +++ b/include/linux/power/smartreflex.h
76861 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
76862 int (*notify)(struct omap_sr *sr, u32 status);
76863 u8 notify_flags;
76864 u8 class_type;
76865 -};
76866 +} __do_const;
76867
76868 /**
76869 * struct omap_sr_nvalue_table - Smartreflex n-target value info
76870 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
76871 index 4ea1d37..80f4b33 100644
76872 --- a/include/linux/ppp-comp.h
76873 +++ b/include/linux/ppp-comp.h
76874 @@ -84,7 +84,7 @@ struct compressor {
76875 struct module *owner;
76876 /* Extra skb space needed by the compressor algorithm */
76877 unsigned int comp_extra;
76878 -};
76879 +} __do_const;
76880
76881 /*
76882 * The return value from decompress routine is the length of the
76883 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
76884 index f5d4723..a6ea2fa 100644
76885 --- a/include/linux/preempt.h
76886 +++ b/include/linux/preempt.h
76887 @@ -18,8 +18,13 @@
76888 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76889 #endif
76890
76891 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
76892 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76893 +
76894 #define inc_preempt_count() add_preempt_count(1)
76895 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
76896 #define dec_preempt_count() sub_preempt_count(1)
76897 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
76898
76899 #define preempt_count() (current_thread_info()->preempt_count)
76900
76901 @@ -64,6 +69,12 @@ do { \
76902 barrier(); \
76903 } while (0)
76904
76905 +#define raw_preempt_disable() \
76906 +do { \
76907 + raw_inc_preempt_count(); \
76908 + barrier(); \
76909 +} while (0)
76910 +
76911 #define sched_preempt_enable_no_resched() \
76912 do { \
76913 barrier(); \
76914 @@ -72,6 +83,12 @@ do { \
76915
76916 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
76917
76918 +#define raw_preempt_enable_no_resched() \
76919 +do { \
76920 + barrier(); \
76921 + raw_dec_preempt_count(); \
76922 +} while (0)
76923 +
76924 #define preempt_enable() \
76925 do { \
76926 preempt_enable_no_resched(); \
76927 @@ -116,8 +133,10 @@ do { \
76928 * region.
76929 */
76930 #define preempt_disable() barrier()
76931 +#define raw_preempt_disable() barrier()
76932 #define sched_preempt_enable_no_resched() barrier()
76933 #define preempt_enable_no_resched() barrier()
76934 +#define raw_preempt_enable_no_resched() barrier()
76935 #define preempt_enable() barrier()
76936
76937 #define preempt_disable_notrace() barrier()
76938 diff --git a/include/linux/printk.h b/include/linux/printk.h
76939 index e6131a78..8e9fb61 100644
76940 --- a/include/linux/printk.h
76941 +++ b/include/linux/printk.h
76942 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
76943 void early_printk(const char *s, ...) { }
76944 #endif
76945
76946 +extern int kptr_restrict;
76947 +
76948 #ifdef CONFIG_PRINTK
76949 asmlinkage __printf(5, 0)
76950 int vprintk_emit(int facility, int level,
76951 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76952
76953 extern int printk_delay_msec;
76954 extern int dmesg_restrict;
76955 -extern int kptr_restrict;
76956
76957 extern void wake_up_klogd(void);
76958
76959 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76960 index 608e60a..c26f864 100644
76961 --- a/include/linux/proc_fs.h
76962 +++ b/include/linux/proc_fs.h
76963 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76964 return proc_create_data(name, mode, parent, proc_fops, NULL);
76965 }
76966
76967 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76968 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76969 +{
76970 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76971 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76972 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76973 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76974 +#else
76975 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76976 +#endif
76977 +}
76978 +
76979 +
76980 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76981 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76982 extern void *PDE_DATA(const struct inode *);
76983 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76984 index 34a1e10..03a6d03 100644
76985 --- a/include/linux/proc_ns.h
76986 +++ b/include/linux/proc_ns.h
76987 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76988 void (*put)(void *ns);
76989 int (*install)(struct nsproxy *nsproxy, void *ns);
76990 unsigned int (*inum)(void *ns);
76991 -};
76992 +} __do_const;
76993
76994 struct proc_ns {
76995 void *ns;
76996 diff --git a/include/linux/quota.h b/include/linux/quota.h
76997 index cc7494a..1e27036 100644
76998 --- a/include/linux/quota.h
76999 +++ b/include/linux/quota.h
77000 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
77001
77002 extern bool qid_eq(struct kqid left, struct kqid right);
77003 extern bool qid_lt(struct kqid left, struct kqid right);
77004 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
77005 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
77006 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
77007 extern bool qid_valid(struct kqid qid);
77008
77009 diff --git a/include/linux/random.h b/include/linux/random.h
77010 index 6312dd9..2561947 100644
77011 --- a/include/linux/random.h
77012 +++ b/include/linux/random.h
77013 @@ -10,9 +10,19 @@
77014
77015
77016 extern void add_device_randomness(const void *, unsigned int);
77017 +
77018 +static inline void add_latent_entropy(void)
77019 +{
77020 +
77021 +#ifdef LATENT_ENTROPY_PLUGIN
77022 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77023 +#endif
77024 +
77025 +}
77026 +
77027 extern void add_input_randomness(unsigned int type, unsigned int code,
77028 - unsigned int value);
77029 -extern void add_interrupt_randomness(int irq, int irq_flags);
77030 + unsigned int value) __latent_entropy;
77031 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
77032
77033 extern void get_random_bytes(void *buf, int nbytes);
77034 extern void get_random_bytes_arch(void *buf, int nbytes);
77035 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
77036 u32 prandom_u32_state(struct rnd_state *);
77037 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
77038
77039 +static inline unsigned long pax_get_random_long(void)
77040 +{
77041 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
77042 +}
77043 +
77044 /*
77045 * Handle minimum values for seeds
77046 */
77047 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
77048 index 4106721..132d42c 100644
77049 --- a/include/linux/rculist.h
77050 +++ b/include/linux/rculist.h
77051 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
77052 struct list_head *prev, struct list_head *next);
77053 #endif
77054
77055 +extern void __pax_list_add_rcu(struct list_head *new,
77056 + struct list_head *prev, struct list_head *next);
77057 +
77058 /**
77059 * list_add_rcu - add a new entry to rcu-protected list
77060 * @new: new entry to be added
77061 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
77062 __list_add_rcu(new, head, head->next);
77063 }
77064
77065 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
77066 +{
77067 + __pax_list_add_rcu(new, head, head->next);
77068 +}
77069 +
77070 /**
77071 * list_add_tail_rcu - add a new entry to rcu-protected list
77072 * @new: new entry to be added
77073 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
77074 __list_add_rcu(new, head->prev, head);
77075 }
77076
77077 +static inline void pax_list_add_tail_rcu(struct list_head *new,
77078 + struct list_head *head)
77079 +{
77080 + __pax_list_add_rcu(new, head->prev, head);
77081 +}
77082 +
77083 /**
77084 * list_del_rcu - deletes entry from list without re-initialization
77085 * @entry: the element to delete from the list.
77086 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
77087 entry->prev = LIST_POISON2;
77088 }
77089
77090 +extern void pax_list_del_rcu(struct list_head *entry);
77091 +
77092 /**
77093 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
77094 * @n: the element to delete from the hash list.
77095 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
77096 index 8e00f9f..9449b55 100644
77097 --- a/include/linux/reboot.h
77098 +++ b/include/linux/reboot.h
77099 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
77100 * Architecture-specific implementations of sys_reboot commands.
77101 */
77102
77103 -extern void machine_restart(char *cmd);
77104 -extern void machine_halt(void);
77105 -extern void machine_power_off(void);
77106 +extern void machine_restart(char *cmd) __noreturn;
77107 +extern void machine_halt(void) __noreturn;
77108 +extern void machine_power_off(void) __noreturn;
77109
77110 extern void machine_shutdown(void);
77111 struct pt_regs;
77112 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
77113 */
77114
77115 extern void kernel_restart_prepare(char *cmd);
77116 -extern void kernel_restart(char *cmd);
77117 -extern void kernel_halt(void);
77118 -extern void kernel_power_off(void);
77119 +extern void kernel_restart(char *cmd) __noreturn;
77120 +extern void kernel_halt(void) __noreturn;
77121 +extern void kernel_power_off(void) __noreturn;
77122
77123 extern int C_A_D; /* for sysctl */
77124 void ctrl_alt_del(void);
77125 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
77126 * Emergency restart, callable from an interrupt handler.
77127 */
77128
77129 -extern void emergency_restart(void);
77130 +extern void emergency_restart(void) __noreturn;
77131 #include <asm/emergency-restart.h>
77132
77133 #endif /* _LINUX_REBOOT_H */
77134 diff --git a/include/linux/regset.h b/include/linux/regset.h
77135 index 8e0c9fe..ac4d221 100644
77136 --- a/include/linux/regset.h
77137 +++ b/include/linux/regset.h
77138 @@ -161,7 +161,8 @@ struct user_regset {
77139 unsigned int align;
77140 unsigned int bias;
77141 unsigned int core_note_type;
77142 -};
77143 +} __do_const;
77144 +typedef struct user_regset __no_const user_regset_no_const;
77145
77146 /**
77147 * struct user_regset_view - available regsets
77148 diff --git a/include/linux/relay.h b/include/linux/relay.h
77149 index d7c8359..818daf5 100644
77150 --- a/include/linux/relay.h
77151 +++ b/include/linux/relay.h
77152 @@ -157,7 +157,7 @@ struct rchan_callbacks
77153 * The callback should return 0 if successful, negative if not.
77154 */
77155 int (*remove_buf_file)(struct dentry *dentry);
77156 -};
77157 +} __no_const;
77158
77159 /*
77160 * CONFIG_RELAY kernel API, kernel/relay.c
77161 diff --git a/include/linux/rio.h b/include/linux/rio.h
77162 index b71d573..2f940bd 100644
77163 --- a/include/linux/rio.h
77164 +++ b/include/linux/rio.h
77165 @@ -355,7 +355,7 @@ struct rio_ops {
77166 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
77167 u64 rstart, u32 size, u32 flags);
77168 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
77169 -};
77170 +} __no_const;
77171
77172 #define RIO_RESOURCE_MEM 0x00000100
77173 #define RIO_RESOURCE_DOORBELL 0x00000200
77174 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
77175 index 6dacb93..6174423 100644
77176 --- a/include/linux/rmap.h
77177 +++ b/include/linux/rmap.h
77178 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
77179 void anon_vma_init(void); /* create anon_vma_cachep */
77180 int anon_vma_prepare(struct vm_area_struct *);
77181 void unlink_anon_vmas(struct vm_area_struct *);
77182 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
77183 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
77184 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
77185 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
77186
77187 static inline void anon_vma_merge(struct vm_area_struct *vma,
77188 struct vm_area_struct *next)
77189 diff --git a/include/linux/sched.h b/include/linux/sched.h
77190 index e27baee..aaef421 100644
77191 --- a/include/linux/sched.h
77192 +++ b/include/linux/sched.h
77193 @@ -62,6 +62,7 @@ struct bio_list;
77194 struct fs_struct;
77195 struct perf_event_context;
77196 struct blk_plug;
77197 +struct linux_binprm;
77198
77199 /*
77200 * List of flags we want to share for kernel threads,
77201 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
77202 extern int in_sched_functions(unsigned long addr);
77203
77204 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
77205 -extern signed long schedule_timeout(signed long timeout);
77206 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
77207 extern signed long schedule_timeout_interruptible(signed long timeout);
77208 extern signed long schedule_timeout_killable(signed long timeout);
77209 extern signed long schedule_timeout_uninterruptible(signed long timeout);
77210 @@ -306,6 +307,19 @@ struct nsproxy;
77211 struct user_namespace;
77212
77213 #ifdef CONFIG_MMU
77214 +
77215 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
77216 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
77217 +#else
77218 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
77219 +{
77220 + return 0;
77221 +}
77222 +#endif
77223 +
77224 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
77225 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
77226 +
77227 extern void arch_pick_mmap_layout(struct mm_struct *mm);
77228 extern unsigned long
77229 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
77230 @@ -581,6 +595,17 @@ struct signal_struct {
77231 #ifdef CONFIG_TASKSTATS
77232 struct taskstats *stats;
77233 #endif
77234 +
77235 +#ifdef CONFIG_GRKERNSEC
77236 + u32 curr_ip;
77237 + u32 saved_ip;
77238 + u32 gr_saddr;
77239 + u32 gr_daddr;
77240 + u16 gr_sport;
77241 + u16 gr_dport;
77242 + u8 used_accept:1;
77243 +#endif
77244 +
77245 #ifdef CONFIG_AUDIT
77246 unsigned audit_tty;
77247 unsigned audit_tty_log_passwd;
77248 @@ -661,6 +686,14 @@ struct user_struct {
77249 struct key *session_keyring; /* UID's default session keyring */
77250 #endif
77251
77252 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
77253 + unsigned char kernel_banned;
77254 +#endif
77255 +#ifdef CONFIG_GRKERNSEC_BRUTE
77256 + unsigned char suid_banned;
77257 + unsigned long suid_ban_expires;
77258 +#endif
77259 +
77260 /* Hash table maintenance information */
77261 struct hlist_node uidhash_node;
77262 kuid_t uid;
77263 @@ -1146,8 +1179,8 @@ struct task_struct {
77264 struct list_head thread_group;
77265
77266 struct completion *vfork_done; /* for vfork() */
77267 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
77268 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77269 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
77270 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77271
77272 cputime_t utime, stime, utimescaled, stimescaled;
77273 cputime_t gtime;
77274 @@ -1172,11 +1205,6 @@ struct task_struct {
77275 struct task_cputime cputime_expires;
77276 struct list_head cpu_timers[3];
77277
77278 -/* process credentials */
77279 - const struct cred __rcu *real_cred; /* objective and real subjective task
77280 - * credentials (COW) */
77281 - const struct cred __rcu *cred; /* effective (overridable) subjective task
77282 - * credentials (COW) */
77283 char comm[TASK_COMM_LEN]; /* executable name excluding path
77284 - access with [gs]et_task_comm (which lock
77285 it with task_lock())
77286 @@ -1193,6 +1221,10 @@ struct task_struct {
77287 #endif
77288 /* CPU-specific state of this task */
77289 struct thread_struct thread;
77290 +/* thread_info moved to task_struct */
77291 +#ifdef CONFIG_X86
77292 + struct thread_info tinfo;
77293 +#endif
77294 /* filesystem information */
77295 struct fs_struct *fs;
77296 /* open file information */
77297 @@ -1266,6 +1298,10 @@ struct task_struct {
77298 gfp_t lockdep_reclaim_gfp;
77299 #endif
77300
77301 +/* process credentials */
77302 + const struct cred __rcu *real_cred; /* objective and real subjective task
77303 + * credentials (COW) */
77304 +
77305 /* journalling filesystem info */
77306 void *journal_info;
77307
77308 @@ -1304,6 +1340,10 @@ struct task_struct {
77309 /* cg_list protected by css_set_lock and tsk->alloc_lock */
77310 struct list_head cg_list;
77311 #endif
77312 +
77313 + const struct cred __rcu *cred; /* effective (overridable) subjective task
77314 + * credentials (COW) */
77315 +
77316 #ifdef CONFIG_FUTEX
77317 struct robust_list_head __user *robust_list;
77318 #ifdef CONFIG_COMPAT
77319 @@ -1407,8 +1447,78 @@ struct task_struct {
77320 unsigned int sequential_io;
77321 unsigned int sequential_io_avg;
77322 #endif
77323 +
77324 +#ifdef CONFIG_GRKERNSEC
77325 + /* grsecurity */
77326 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77327 + u64 exec_id;
77328 +#endif
77329 +#ifdef CONFIG_GRKERNSEC_SETXID
77330 + const struct cred *delayed_cred;
77331 +#endif
77332 + struct dentry *gr_chroot_dentry;
77333 + struct acl_subject_label *acl;
77334 + struct acl_subject_label *tmpacl;
77335 + struct acl_role_label *role;
77336 + struct file *exec_file;
77337 + unsigned long brute_expires;
77338 + u16 acl_role_id;
77339 + u8 inherited;
77340 + /* is this the task that authenticated to the special role */
77341 + u8 acl_sp_role;
77342 + u8 is_writable;
77343 + u8 brute;
77344 + u8 gr_is_chrooted;
77345 +#endif
77346 +
77347 };
77348
77349 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
77350 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
77351 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
77352 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
77353 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
77354 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
77355 +
77356 +#ifdef CONFIG_PAX_SOFTMODE
77357 +extern int pax_softmode;
77358 +#endif
77359 +
77360 +extern int pax_check_flags(unsigned long *);
77361 +
77362 +/* if tsk != current then task_lock must be held on it */
77363 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77364 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
77365 +{
77366 + if (likely(tsk->mm))
77367 + return tsk->mm->pax_flags;
77368 + else
77369 + return 0UL;
77370 +}
77371 +
77372 +/* if tsk != current then task_lock must be held on it */
77373 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
77374 +{
77375 + if (likely(tsk->mm)) {
77376 + tsk->mm->pax_flags = flags;
77377 + return 0;
77378 + }
77379 + return -EINVAL;
77380 +}
77381 +#endif
77382 +
77383 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
77384 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
77385 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
77386 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
77387 +#endif
77388 +
77389 +struct path;
77390 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
77391 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
77392 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
77393 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
77394 +
77395 /* Future-safe accessor for struct task_struct's cpus_allowed. */
77396 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
77397
77398 @@ -1467,7 +1577,7 @@ struct pid_namespace;
77399 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
77400 struct pid_namespace *ns);
77401
77402 -static inline pid_t task_pid_nr(struct task_struct *tsk)
77403 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
77404 {
77405 return tsk->pid;
77406 }
77407 @@ -1917,7 +2027,9 @@ void yield(void);
77408 extern struct exec_domain default_exec_domain;
77409
77410 union thread_union {
77411 +#ifndef CONFIG_X86
77412 struct thread_info thread_info;
77413 +#endif
77414 unsigned long stack[THREAD_SIZE/sizeof(long)];
77415 };
77416
77417 @@ -1950,6 +2062,7 @@ extern struct pid_namespace init_pid_ns;
77418 */
77419
77420 extern struct task_struct *find_task_by_vpid(pid_t nr);
77421 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
77422 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
77423 struct pid_namespace *ns);
77424
77425 @@ -2114,7 +2227,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
77426 extern void exit_itimers(struct signal_struct *);
77427 extern void flush_itimer_signals(void);
77428
77429 -extern void do_group_exit(int);
77430 +extern __noreturn void do_group_exit(int);
77431
77432 extern int allow_signal(int);
77433 extern int disallow_signal(int);
77434 @@ -2305,9 +2418,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
77435
77436 #endif
77437
77438 -static inline int object_is_on_stack(void *obj)
77439 +static inline int object_starts_on_stack(void *obj)
77440 {
77441 - void *stack = task_stack_page(current);
77442 + const void *stack = task_stack_page(current);
77443
77444 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
77445 }
77446 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
77447 index bf8086b..962b035 100644
77448 --- a/include/linux/sched/sysctl.h
77449 +++ b/include/linux/sched/sysctl.h
77450 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
77451 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
77452
77453 extern int sysctl_max_map_count;
77454 +extern unsigned long sysctl_heap_stack_gap;
77455
77456 extern unsigned int sysctl_sched_latency;
77457 extern unsigned int sysctl_sched_min_granularity;
77458 diff --git a/include/linux/security.h b/include/linux/security.h
77459 index 9d37e2b..43368e4 100644
77460 --- a/include/linux/security.h
77461 +++ b/include/linux/security.h
77462 @@ -27,6 +27,7 @@
77463 #include <linux/slab.h>
77464 #include <linux/err.h>
77465 #include <linux/string.h>
77466 +#include <linux/grsecurity.h>
77467
77468 struct linux_binprm;
77469 struct cred;
77470 @@ -116,8 +117,6 @@ struct seq_file;
77471
77472 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
77473
77474 -void reset_security_ops(void);
77475 -
77476 #ifdef CONFIG_MMU
77477 extern unsigned long mmap_min_addr;
77478 extern unsigned long dac_mmap_min_addr;
77479 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
77480 index dc368b8..e895209 100644
77481 --- a/include/linux/semaphore.h
77482 +++ b/include/linux/semaphore.h
77483 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
77484 }
77485
77486 extern void down(struct semaphore *sem);
77487 -extern int __must_check down_interruptible(struct semaphore *sem);
77488 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
77489 extern int __must_check down_killable(struct semaphore *sem);
77490 extern int __must_check down_trylock(struct semaphore *sem);
77491 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
77492 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
77493 index 4e32edc..f8f2d18 100644
77494 --- a/include/linux/seq_file.h
77495 +++ b/include/linux/seq_file.h
77496 @@ -26,6 +26,9 @@ struct seq_file {
77497 struct mutex lock;
77498 const struct seq_operations *op;
77499 int poll_event;
77500 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77501 + u64 exec_id;
77502 +#endif
77503 #ifdef CONFIG_USER_NS
77504 struct user_namespace *user_ns;
77505 #endif
77506 @@ -38,6 +41,7 @@ struct seq_operations {
77507 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
77508 int (*show) (struct seq_file *m, void *v);
77509 };
77510 +typedef struct seq_operations __no_const seq_operations_no_const;
77511
77512 #define SEQ_SKIP 1
77513
77514 diff --git a/include/linux/shm.h b/include/linux/shm.h
77515 index 429c199..4d42e38 100644
77516 --- a/include/linux/shm.h
77517 +++ b/include/linux/shm.h
77518 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
77519
77520 /* The task created the shm object. NULL if the task is dead. */
77521 struct task_struct *shm_creator;
77522 +#ifdef CONFIG_GRKERNSEC
77523 + time_t shm_createtime;
77524 + pid_t shm_lapid;
77525 +#endif
77526 };
77527
77528 /* shm_mode upper byte flags */
77529 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
77530 index c2d8933..b2b4ed6 100644
77531 --- a/include/linux/skbuff.h
77532 +++ b/include/linux/skbuff.h
77533 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
77534 extern struct sk_buff *__alloc_skb(unsigned int size,
77535 gfp_t priority, int flags, int node);
77536 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
77537 -static inline struct sk_buff *alloc_skb(unsigned int size,
77538 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
77539 gfp_t priority)
77540 {
77541 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
77542 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
77543 */
77544 static inline int skb_queue_empty(const struct sk_buff_head *list)
77545 {
77546 - return list->next == (struct sk_buff *)list;
77547 + return list->next == (const struct sk_buff *)list;
77548 }
77549
77550 /**
77551 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
77552 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77553 const struct sk_buff *skb)
77554 {
77555 - return skb->next == (struct sk_buff *)list;
77556 + return skb->next == (const struct sk_buff *)list;
77557 }
77558
77559 /**
77560 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77561 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
77562 const struct sk_buff *skb)
77563 {
77564 - return skb->prev == (struct sk_buff *)list;
77565 + return skb->prev == (const struct sk_buff *)list;
77566 }
77567
77568 /**
77569 @@ -1750,7 +1750,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
77570 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
77571 */
77572 #ifndef NET_SKB_PAD
77573 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
77574 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
77575 #endif
77576
77577 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
77578 @@ -2348,7 +2348,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
77579 int noblock, int *err);
77580 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
77581 struct poll_table_struct *wait);
77582 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
77583 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
77584 int offset, struct iovec *to,
77585 int size);
77586 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
77587 @@ -2643,6 +2643,9 @@ static inline void nf_reset(struct sk_buff *skb)
77588 nf_bridge_put(skb->nf_bridge);
77589 skb->nf_bridge = NULL;
77590 #endif
77591 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
77592 + skb->nf_trace = 0;
77593 +#endif
77594 }
77595
77596 static inline void nf_reset_trace(struct sk_buff *skb)
77597 diff --git a/include/linux/slab.h b/include/linux/slab.h
77598 index 74f1058..914b7da 100644
77599 --- a/include/linux/slab.h
77600 +++ b/include/linux/slab.h
77601 @@ -14,15 +14,29 @@
77602 #include <linux/gfp.h>
77603 #include <linux/types.h>
77604 #include <linux/workqueue.h>
77605 -
77606 +#include <linux/err.h>
77607
77608 /*
77609 * Flags to pass to kmem_cache_create().
77610 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
77611 */
77612 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
77613 +
77614 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77615 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
77616 +#else
77617 +#define SLAB_USERCOPY 0x00000000UL
77618 +#endif
77619 +
77620 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
77621 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
77622 +
77623 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77624 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
77625 +#else
77626 +#define SLAB_NO_SANITIZE 0x00000000UL
77627 +#endif
77628 +
77629 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
77630 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
77631 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
77632 @@ -91,10 +105,13 @@
77633 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
77634 * Both make kfree a no-op.
77635 */
77636 -#define ZERO_SIZE_PTR ((void *)16)
77637 +#define ZERO_SIZE_PTR \
77638 +({ \
77639 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
77640 + (void *)(-MAX_ERRNO-1L); \
77641 +})
77642
77643 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
77644 - (unsigned long)ZERO_SIZE_PTR)
77645 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
77646
77647 #include <linux/kmemleak.h>
77648
77649 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
77650 void kfree(const void *);
77651 void kzfree(const void *);
77652 size_t ksize(const void *);
77653 +const char *check_heap_object(const void *ptr, unsigned long n);
77654 +bool is_usercopy_object(const void *ptr);
77655
77656 /*
77657 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
77658 @@ -167,7 +186,7 @@ struct kmem_cache {
77659 unsigned int align; /* Alignment as calculated */
77660 unsigned long flags; /* Active flags on the slab */
77661 const char *name; /* Slab name for sysfs */
77662 - int refcount; /* Use counter */
77663 + atomic_t refcount; /* Use counter */
77664 void (*ctor)(void *); /* Called on object slot creation */
77665 struct list_head list; /* List of all slab caches on the system */
77666 };
77667 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
77668 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77669 #endif
77670
77671 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77672 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
77673 +#endif
77674 +
77675 /*
77676 * Figure out which kmalloc slab an allocation of a certain size
77677 * belongs to.
77678 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77679 * 2 = 120 .. 192 bytes
77680 * n = 2^(n-1) .. 2^n -1
77681 */
77682 -static __always_inline int kmalloc_index(size_t size)
77683 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
77684 {
77685 if (!size)
77686 return 0;
77687 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
77688 }
77689 #endif /* !CONFIG_SLOB */
77690
77691 -void *__kmalloc(size_t size, gfp_t flags);
77692 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
77693 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
77694
77695 #ifdef CONFIG_NUMA
77696 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
77697 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
77698 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
77699 #else
77700 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
77701 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
77702 index e9346b4..1494959 100644
77703 --- a/include/linux/slab_def.h
77704 +++ b/include/linux/slab_def.h
77705 @@ -36,7 +36,7 @@ struct kmem_cache {
77706 /* 4) cache creation/removal */
77707 const char *name;
77708 struct list_head list;
77709 - int refcount;
77710 + atomic_t refcount;
77711 int object_size;
77712 int align;
77713
77714 @@ -52,10 +52,14 @@ struct kmem_cache {
77715 unsigned long node_allocs;
77716 unsigned long node_frees;
77717 unsigned long node_overflow;
77718 - atomic_t allochit;
77719 - atomic_t allocmiss;
77720 - atomic_t freehit;
77721 - atomic_t freemiss;
77722 + atomic_unchecked_t allochit;
77723 + atomic_unchecked_t allocmiss;
77724 + atomic_unchecked_t freehit;
77725 + atomic_unchecked_t freemiss;
77726 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77727 + atomic_unchecked_t sanitized;
77728 + atomic_unchecked_t not_sanitized;
77729 +#endif
77730
77731 /*
77732 * If debugging is enabled, then the allocator can add additional
77733 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
77734 index cc0b67e..a0329b1 100644
77735 --- a/include/linux/slub_def.h
77736 +++ b/include/linux/slub_def.h
77737 @@ -74,7 +74,7 @@ struct kmem_cache {
77738 struct kmem_cache_order_objects max;
77739 struct kmem_cache_order_objects min;
77740 gfp_t allocflags; /* gfp flags to use on each alloc */
77741 - int refcount; /* Refcount for slab cache destroy */
77742 + atomic_t refcount; /* Refcount for slab cache destroy */
77743 void (*ctor)(void *);
77744 int inuse; /* Offset to metadata */
77745 int align; /* Alignment */
77746 diff --git a/include/linux/smp.h b/include/linux/smp.h
77747 index 731f523..3340268 100644
77748 --- a/include/linux/smp.h
77749 +++ b/include/linux/smp.h
77750 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
77751 #endif
77752
77753 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
77754 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
77755 #define put_cpu() preempt_enable()
77756 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
77757
77758 /*
77759 * Callback to arch code if there's nosmp or maxcpus=0 on the
77760 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
77761 index 54f91d3..be2c379 100644
77762 --- a/include/linux/sock_diag.h
77763 +++ b/include/linux/sock_diag.h
77764 @@ -11,7 +11,7 @@ struct sock;
77765 struct sock_diag_handler {
77766 __u8 family;
77767 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
77768 -};
77769 +} __do_const;
77770
77771 int sock_diag_register(const struct sock_diag_handler *h);
77772 void sock_diag_unregister(const struct sock_diag_handler *h);
77773 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
77774 index 680f9a3..f13aeb0 100644
77775 --- a/include/linux/sonet.h
77776 +++ b/include/linux/sonet.h
77777 @@ -7,7 +7,7 @@
77778 #include <uapi/linux/sonet.h>
77779
77780 struct k_sonet_stats {
77781 -#define __HANDLE_ITEM(i) atomic_t i
77782 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
77783 __SONET_ITEMS
77784 #undef __HANDLE_ITEM
77785 };
77786 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
77787 index 07d8e53..dc934c9 100644
77788 --- a/include/linux/sunrpc/addr.h
77789 +++ b/include/linux/sunrpc/addr.h
77790 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
77791 {
77792 switch (sap->sa_family) {
77793 case AF_INET:
77794 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
77795 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
77796 case AF_INET6:
77797 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
77798 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
77799 }
77800 return 0;
77801 }
77802 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
77803 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
77804 const struct sockaddr *src)
77805 {
77806 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
77807 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
77808 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
77809
77810 dsin->sin_family = ssin->sin_family;
77811 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
77812 if (sa->sa_family != AF_INET6)
77813 return 0;
77814
77815 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
77816 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
77817 }
77818
77819 #endif /* _LINUX_SUNRPC_ADDR_H */
77820 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
77821 index 6740801..c535f27 100644
77822 --- a/include/linux/sunrpc/clnt.h
77823 +++ b/include/linux/sunrpc/clnt.h
77824 @@ -96,7 +96,7 @@ struct rpc_procinfo {
77825 unsigned int p_timer; /* Which RTT timer to use */
77826 u32 p_statidx; /* Which procedure to account */
77827 const char * p_name; /* name of procedure */
77828 -};
77829 +} __do_const;
77830
77831 #ifdef __KERNEL__
77832
77833 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
77834 index 6eecfc2..7ada79d 100644
77835 --- a/include/linux/sunrpc/svc.h
77836 +++ b/include/linux/sunrpc/svc.h
77837 @@ -410,7 +410,7 @@ struct svc_procedure {
77838 unsigned int pc_count; /* call count */
77839 unsigned int pc_cachetype; /* cache info (NFS) */
77840 unsigned int pc_xdrressize; /* maximum size of XDR reply */
77841 -};
77842 +} __do_const;
77843
77844 /*
77845 * Function prototypes.
77846 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
77847 index 0b8e3e6..33e0a01 100644
77848 --- a/include/linux/sunrpc/svc_rdma.h
77849 +++ b/include/linux/sunrpc/svc_rdma.h
77850 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
77851 extern unsigned int svcrdma_max_requests;
77852 extern unsigned int svcrdma_max_req_size;
77853
77854 -extern atomic_t rdma_stat_recv;
77855 -extern atomic_t rdma_stat_read;
77856 -extern atomic_t rdma_stat_write;
77857 -extern atomic_t rdma_stat_sq_starve;
77858 -extern atomic_t rdma_stat_rq_starve;
77859 -extern atomic_t rdma_stat_rq_poll;
77860 -extern atomic_t rdma_stat_rq_prod;
77861 -extern atomic_t rdma_stat_sq_poll;
77862 -extern atomic_t rdma_stat_sq_prod;
77863 +extern atomic_unchecked_t rdma_stat_recv;
77864 +extern atomic_unchecked_t rdma_stat_read;
77865 +extern atomic_unchecked_t rdma_stat_write;
77866 +extern atomic_unchecked_t rdma_stat_sq_starve;
77867 +extern atomic_unchecked_t rdma_stat_rq_starve;
77868 +extern atomic_unchecked_t rdma_stat_rq_poll;
77869 +extern atomic_unchecked_t rdma_stat_rq_prod;
77870 +extern atomic_unchecked_t rdma_stat_sq_poll;
77871 +extern atomic_unchecked_t rdma_stat_sq_prod;
77872
77873 #define RPCRDMA_VERSION 1
77874
77875 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77876 index 8d71d65..f79586e 100644
77877 --- a/include/linux/sunrpc/svcauth.h
77878 +++ b/include/linux/sunrpc/svcauth.h
77879 @@ -120,7 +120,7 @@ struct auth_ops {
77880 int (*release)(struct svc_rqst *rq);
77881 void (*domain_release)(struct auth_domain *);
77882 int (*set_client)(struct svc_rqst *rq);
77883 -};
77884 +} __do_const;
77885
77886 #define SVC_GARBAGE 1
77887 #define SVC_SYSERR 2
77888 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77889 index a5ffd32..0935dea 100644
77890 --- a/include/linux/swiotlb.h
77891 +++ b/include/linux/swiotlb.h
77892 @@ -60,7 +60,8 @@ extern void
77893
77894 extern void
77895 swiotlb_free_coherent(struct device *hwdev, size_t size,
77896 - void *vaddr, dma_addr_t dma_handle);
77897 + void *vaddr, dma_addr_t dma_handle,
77898 + struct dma_attrs *attrs);
77899
77900 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77901 unsigned long offset, size_t size,
77902 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77903 index 7fac04e..de57300 100644
77904 --- a/include/linux/syscalls.h
77905 +++ b/include/linux/syscalls.h
77906 @@ -97,8 +97,14 @@ struct sigaltstack;
77907 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77908
77909 #define __SC_DECL(t, a) t a
77910 +#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))
77911 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77912 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77913 +#define __SC_LONG(t, a) __typeof( \
77914 + __builtin_choose_expr( \
77915 + sizeof(t) > sizeof(int), \
77916 + (t) 0, \
77917 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77918 + )) a
77919 #define __SC_CAST(t, a) (t) a
77920 #define __SC_ARGS(t, a) a
77921 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77922 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
77923 asmlinkage long sys_fsync(unsigned int fd);
77924 asmlinkage long sys_fdatasync(unsigned int fd);
77925 asmlinkage long sys_bdflush(int func, long data);
77926 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77927 - char __user *type, unsigned long flags,
77928 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77929 + const char __user *type, unsigned long flags,
77930 void __user *data);
77931 -asmlinkage long sys_umount(char __user *name, int flags);
77932 -asmlinkage long sys_oldumount(char __user *name);
77933 +asmlinkage long sys_umount(const char __user *name, int flags);
77934 +asmlinkage long sys_oldumount(const char __user *name);
77935 asmlinkage long sys_truncate(const char __user *path, long length);
77936 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77937 asmlinkage long sys_stat(const char __user *filename,
77938 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77939 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77940 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77941 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77942 - struct sockaddr __user *, int);
77943 + struct sockaddr __user *, int) __intentional_overflow(0);
77944 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77945 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77946 unsigned int vlen, unsigned flags);
77947 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77948 index 27b3b0b..e093dd9 100644
77949 --- a/include/linux/syscore_ops.h
77950 +++ b/include/linux/syscore_ops.h
77951 @@ -16,7 +16,7 @@ struct syscore_ops {
77952 int (*suspend)(void);
77953 void (*resume)(void);
77954 void (*shutdown)(void);
77955 -};
77956 +} __do_const;
77957
77958 extern void register_syscore_ops(struct syscore_ops *ops);
77959 extern void unregister_syscore_ops(struct syscore_ops *ops);
77960 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77961 index 14a8ff2..af52bad 100644
77962 --- a/include/linux/sysctl.h
77963 +++ b/include/linux/sysctl.h
77964 @@ -34,13 +34,13 @@ struct ctl_table_root;
77965 struct ctl_table_header;
77966 struct ctl_dir;
77967
77968 -typedef struct ctl_table ctl_table;
77969 -
77970 typedef int proc_handler (struct ctl_table *ctl, int write,
77971 void __user *buffer, size_t *lenp, loff_t *ppos);
77972
77973 extern int proc_dostring(struct ctl_table *, int,
77974 void __user *, size_t *, loff_t *);
77975 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77976 + void __user *, size_t *, loff_t *);
77977 extern int proc_dointvec(struct ctl_table *, int,
77978 void __user *, size_t *, loff_t *);
77979 extern int proc_dointvec_minmax(struct ctl_table *, int,
77980 @@ -115,7 +115,9 @@ struct ctl_table
77981 struct ctl_table_poll *poll;
77982 void *extra1;
77983 void *extra2;
77984 -};
77985 +} __do_const;
77986 +typedef struct ctl_table __no_const ctl_table_no_const;
77987 +typedef struct ctl_table ctl_table;
77988
77989 struct ctl_node {
77990 struct rb_node node;
77991 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77992 index 11baec7..706f99f 100644
77993 --- a/include/linux/sysfs.h
77994 +++ b/include/linux/sysfs.h
77995 @@ -33,7 +33,8 @@ struct attribute {
77996 struct lock_class_key *key;
77997 struct lock_class_key skey;
77998 #endif
77999 -};
78000 +} __do_const;
78001 +typedef struct attribute __no_const attribute_no_const;
78002
78003 /**
78004 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
78005 @@ -62,7 +63,8 @@ struct attribute_group {
78006 struct attribute *, int);
78007 struct attribute **attrs;
78008 struct bin_attribute **bin_attrs;
78009 -};
78010 +} __do_const;
78011 +typedef struct attribute_group __no_const attribute_group_no_const;
78012
78013 /**
78014 * Use these macros to make defining attributes easier. See include/linux/device.h
78015 @@ -126,7 +128,8 @@ struct bin_attribute {
78016 char *, loff_t, size_t);
78017 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
78018 struct vm_area_struct *vma);
78019 -};
78020 +} __do_const;
78021 +typedef struct bin_attribute __no_const bin_attribute_no_const;
78022
78023 /**
78024 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
78025 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
78026 index 7faf933..9b85a0c 100644
78027 --- a/include/linux/sysrq.h
78028 +++ b/include/linux/sysrq.h
78029 @@ -16,6 +16,7 @@
78030
78031 #include <linux/errno.h>
78032 #include <linux/types.h>
78033 +#include <linux/compiler.h>
78034
78035 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
78036 #define SYSRQ_DEFAULT_ENABLE 1
78037 @@ -36,7 +37,7 @@ struct sysrq_key_op {
78038 char *help_msg;
78039 char *action_msg;
78040 int enable_mask;
78041 -};
78042 +} __do_const;
78043
78044 #ifdef CONFIG_MAGIC_SYSRQ
78045
78046 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
78047 index e7e0473..7989295 100644
78048 --- a/include/linux/thread_info.h
78049 +++ b/include/linux/thread_info.h
78050 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
78051 #error "no set_restore_sigmask() provided and default one won't work"
78052 #endif
78053
78054 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
78055 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
78056 +{
78057 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
78058 + if (!__builtin_constant_p(n))
78059 +#endif
78060 + __check_object_size(ptr, n, to_user);
78061 +}
78062 +
78063 #endif /* __KERNEL__ */
78064
78065 #endif /* _LINUX_THREAD_INFO_H */
78066 diff --git a/include/linux/tty.h b/include/linux/tty.h
78067 index 64f8646..1515fc7 100644
78068 --- a/include/linux/tty.h
78069 +++ b/include/linux/tty.h
78070 @@ -197,7 +197,7 @@ struct tty_port {
78071 const struct tty_port_operations *ops; /* Port operations */
78072 spinlock_t lock; /* Lock protecting tty field */
78073 int blocked_open; /* Waiting to open */
78074 - int count; /* Usage count */
78075 + atomic_t count; /* Usage count */
78076 wait_queue_head_t open_wait; /* Open waiters */
78077 wait_queue_head_t close_wait; /* Close waiters */
78078 wait_queue_head_t delta_msr_wait; /* Modem status change */
78079 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
78080 struct tty_struct *tty, struct file *filp);
78081 static inline int tty_port_users(struct tty_port *port)
78082 {
78083 - return port->count + port->blocked_open;
78084 + return atomic_read(&port->count) + port->blocked_open;
78085 }
78086
78087 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
78088 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
78089 index 756a609..b302dd6 100644
78090 --- a/include/linux/tty_driver.h
78091 +++ b/include/linux/tty_driver.h
78092 @@ -285,7 +285,7 @@ struct tty_operations {
78093 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
78094 #endif
78095 const struct file_operations *proc_fops;
78096 -};
78097 +} __do_const;
78098
78099 struct tty_driver {
78100 int magic; /* magic number for this structure */
78101 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
78102 index f15c898..207b7d1 100644
78103 --- a/include/linux/tty_ldisc.h
78104 +++ b/include/linux/tty_ldisc.h
78105 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
78106
78107 struct module *owner;
78108
78109 - int refcount;
78110 + atomic_t refcount;
78111 };
78112
78113 struct tty_ldisc {
78114 diff --git a/include/linux/types.h b/include/linux/types.h
78115 index 4d118ba..c3ee9bf 100644
78116 --- a/include/linux/types.h
78117 +++ b/include/linux/types.h
78118 @@ -176,10 +176,26 @@ typedef struct {
78119 int counter;
78120 } atomic_t;
78121
78122 +#ifdef CONFIG_PAX_REFCOUNT
78123 +typedef struct {
78124 + int counter;
78125 +} atomic_unchecked_t;
78126 +#else
78127 +typedef atomic_t atomic_unchecked_t;
78128 +#endif
78129 +
78130 #ifdef CONFIG_64BIT
78131 typedef struct {
78132 long counter;
78133 } atomic64_t;
78134 +
78135 +#ifdef CONFIG_PAX_REFCOUNT
78136 +typedef struct {
78137 + long counter;
78138 +} atomic64_unchecked_t;
78139 +#else
78140 +typedef atomic64_t atomic64_unchecked_t;
78141 +#endif
78142 #endif
78143
78144 struct list_head {
78145 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
78146 index 5ca0951..ab496a5 100644
78147 --- a/include/linux/uaccess.h
78148 +++ b/include/linux/uaccess.h
78149 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78150 long ret; \
78151 mm_segment_t old_fs = get_fs(); \
78152 \
78153 - set_fs(KERNEL_DS); \
78154 pagefault_disable(); \
78155 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
78156 - pagefault_enable(); \
78157 + set_fs(KERNEL_DS); \
78158 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
78159 set_fs(old_fs); \
78160 + pagefault_enable(); \
78161 ret; \
78162 })
78163
78164 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
78165 index 8e522cbc..aa8572d 100644
78166 --- a/include/linux/uidgid.h
78167 +++ b/include/linux/uidgid.h
78168 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
78169
78170 #endif /* CONFIG_USER_NS */
78171
78172 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
78173 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
78174 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
78175 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
78176 +
78177 #endif /* _LINUX_UIDGID_H */
78178 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
78179 index 99c1b4d..562e6f3 100644
78180 --- a/include/linux/unaligned/access_ok.h
78181 +++ b/include/linux/unaligned/access_ok.h
78182 @@ -4,34 +4,34 @@
78183 #include <linux/kernel.h>
78184 #include <asm/byteorder.h>
78185
78186 -static inline u16 get_unaligned_le16(const void *p)
78187 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
78188 {
78189 - return le16_to_cpup((__le16 *)p);
78190 + return le16_to_cpup((const __le16 *)p);
78191 }
78192
78193 -static inline u32 get_unaligned_le32(const void *p)
78194 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
78195 {
78196 - return le32_to_cpup((__le32 *)p);
78197 + return le32_to_cpup((const __le32 *)p);
78198 }
78199
78200 -static inline u64 get_unaligned_le64(const void *p)
78201 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
78202 {
78203 - return le64_to_cpup((__le64 *)p);
78204 + return le64_to_cpup((const __le64 *)p);
78205 }
78206
78207 -static inline u16 get_unaligned_be16(const void *p)
78208 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
78209 {
78210 - return be16_to_cpup((__be16 *)p);
78211 + return be16_to_cpup((const __be16 *)p);
78212 }
78213
78214 -static inline u32 get_unaligned_be32(const void *p)
78215 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
78216 {
78217 - return be32_to_cpup((__be32 *)p);
78218 + return be32_to_cpup((const __be32 *)p);
78219 }
78220
78221 -static inline u64 get_unaligned_be64(const void *p)
78222 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
78223 {
78224 - return be64_to_cpup((__be64 *)p);
78225 + return be64_to_cpup((const __be64 *)p);
78226 }
78227
78228 static inline void put_unaligned_le16(u16 val, void *p)
78229 diff --git a/include/linux/usb.h b/include/linux/usb.h
78230 index 001629c..7c1cc9b 100644
78231 --- a/include/linux/usb.h
78232 +++ b/include/linux/usb.h
78233 @@ -561,7 +561,7 @@ struct usb_device {
78234 int maxchild;
78235
78236 u32 quirks;
78237 - atomic_t urbnum;
78238 + atomic_unchecked_t urbnum;
78239
78240 unsigned long active_duration;
78241
78242 @@ -1635,7 +1635,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
78243
78244 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
78245 __u8 request, __u8 requesttype, __u16 value, __u16 index,
78246 - void *data, __u16 size, int timeout);
78247 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
78248 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
78249 void *data, int len, int *actual_length, int timeout);
78250 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
78251 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
78252 index e452ba6..78f8e80 100644
78253 --- a/include/linux/usb/renesas_usbhs.h
78254 +++ b/include/linux/usb/renesas_usbhs.h
78255 @@ -39,7 +39,7 @@ enum {
78256 */
78257 struct renesas_usbhs_driver_callback {
78258 int (*notify_hotplug)(struct platform_device *pdev);
78259 -};
78260 +} __no_const;
78261
78262 /*
78263 * callback functions for platform
78264 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
78265 index 6f8fbcf..8259001 100644
78266 --- a/include/linux/vermagic.h
78267 +++ b/include/linux/vermagic.h
78268 @@ -25,9 +25,35 @@
78269 #define MODULE_ARCH_VERMAGIC ""
78270 #endif
78271
78272 +#ifdef CONFIG_PAX_REFCOUNT
78273 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
78274 +#else
78275 +#define MODULE_PAX_REFCOUNT ""
78276 +#endif
78277 +
78278 +#ifdef CONSTIFY_PLUGIN
78279 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
78280 +#else
78281 +#define MODULE_CONSTIFY_PLUGIN ""
78282 +#endif
78283 +
78284 +#ifdef STACKLEAK_PLUGIN
78285 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
78286 +#else
78287 +#define MODULE_STACKLEAK_PLUGIN ""
78288 +#endif
78289 +
78290 +#ifdef CONFIG_GRKERNSEC
78291 +#define MODULE_GRSEC "GRSEC "
78292 +#else
78293 +#define MODULE_GRSEC ""
78294 +#endif
78295 +
78296 #define VERMAGIC_STRING \
78297 UTS_RELEASE " " \
78298 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
78299 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
78300 - MODULE_ARCH_VERMAGIC
78301 + MODULE_ARCH_VERMAGIC \
78302 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
78303 + MODULE_GRSEC
78304
78305 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
78306 index 502073a..a7de024 100644
78307 --- a/include/linux/vga_switcheroo.h
78308 +++ b/include/linux/vga_switcheroo.h
78309 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
78310
78311 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
78312
78313 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
78314 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
78315 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
78316 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
78317 #else
78318
78319 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
78320 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
78321
78322 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
78323
78324 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78325 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78326 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78327 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78328
78329 #endif
78330 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
78331 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
78332 index 4b8a891..cc929b4 100644
78333 --- a/include/linux/vmalloc.h
78334 +++ b/include/linux/vmalloc.h
78335 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
78336 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
78337 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
78338 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
78339 +
78340 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
78341 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
78342 +#endif
78343 +
78344 /* bits [20..32] reserved for arch specific ioremap internals */
78345
78346 /*
78347 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
78348 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
78349 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
78350 unsigned long start, unsigned long end, gfp_t gfp_mask,
78351 - pgprot_t prot, int node, const void *caller);
78352 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
78353 extern void vfree(const void *addr);
78354
78355 extern void *vmap(struct page **pages, unsigned int count,
78356 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
78357
78358 /* for /dev/kmem */
78359 extern long vread(char *buf, char *addr, unsigned long count);
78360 -extern long vwrite(char *buf, char *addr, unsigned long count);
78361 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
78362
78363 /*
78364 * Internals. Dont't use..
78365 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
78366 index e4b9480..b96d5ab 100644
78367 --- a/include/linux/vmstat.h
78368 +++ b/include/linux/vmstat.h
78369 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
78370 /*
78371 * Zone based page accounting with per cpu differentials.
78372 */
78373 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78374 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78375
78376 static inline void zone_page_state_add(long x, struct zone *zone,
78377 enum zone_stat_item item)
78378 {
78379 - atomic_long_add(x, &zone->vm_stat[item]);
78380 - atomic_long_add(x, &vm_stat[item]);
78381 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
78382 + atomic_long_add_unchecked(x, &vm_stat[item]);
78383 }
78384
78385 static inline unsigned long global_page_state(enum zone_stat_item item)
78386 {
78387 - long x = atomic_long_read(&vm_stat[item]);
78388 + long x = atomic_long_read_unchecked(&vm_stat[item]);
78389 #ifdef CONFIG_SMP
78390 if (x < 0)
78391 x = 0;
78392 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
78393 static inline unsigned long zone_page_state(struct zone *zone,
78394 enum zone_stat_item item)
78395 {
78396 - long x = atomic_long_read(&zone->vm_stat[item]);
78397 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78398 #ifdef CONFIG_SMP
78399 if (x < 0)
78400 x = 0;
78401 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
78402 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
78403 enum zone_stat_item item)
78404 {
78405 - long x = atomic_long_read(&zone->vm_stat[item]);
78406 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78407
78408 #ifdef CONFIG_SMP
78409 int cpu;
78410 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
78411
78412 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
78413 {
78414 - atomic_long_inc(&zone->vm_stat[item]);
78415 - atomic_long_inc(&vm_stat[item]);
78416 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
78417 + atomic_long_inc_unchecked(&vm_stat[item]);
78418 }
78419
78420 static inline void __inc_zone_page_state(struct page *page,
78421 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
78422
78423 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
78424 {
78425 - atomic_long_dec(&zone->vm_stat[item]);
78426 - atomic_long_dec(&vm_stat[item]);
78427 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
78428 + atomic_long_dec_unchecked(&vm_stat[item]);
78429 }
78430
78431 static inline void __dec_zone_page_state(struct page *page,
78432 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
78433 index 91b0a68..0e9adf6 100644
78434 --- a/include/linux/xattr.h
78435 +++ b/include/linux/xattr.h
78436 @@ -28,7 +28,7 @@ struct xattr_handler {
78437 size_t size, int handler_flags);
78438 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
78439 size_t size, int flags, int handler_flags);
78440 -};
78441 +} __do_const;
78442
78443 struct xattr {
78444 const char *name;
78445 @@ -37,6 +37,9 @@ struct xattr {
78446 };
78447
78448 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
78449 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
78450 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
78451 +#endif
78452 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
78453 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
78454 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
78455 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
78456 index 9c5a6b4..09c9438 100644
78457 --- a/include/linux/zlib.h
78458 +++ b/include/linux/zlib.h
78459 @@ -31,6 +31,7 @@
78460 #define _ZLIB_H
78461
78462 #include <linux/zconf.h>
78463 +#include <linux/compiler.h>
78464
78465 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
78466 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
78467 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
78468
78469 /* basic functions */
78470
78471 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
78472 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
78473 /*
78474 Returns the number of bytes that needs to be allocated for a per-
78475 stream workspace with the specified parameters. A pointer to this
78476 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
78477 index c768c9f..bdcaa5a 100644
78478 --- a/include/media/v4l2-dev.h
78479 +++ b/include/media/v4l2-dev.h
78480 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
78481 int (*mmap) (struct file *, struct vm_area_struct *);
78482 int (*open) (struct file *);
78483 int (*release) (struct file *);
78484 -};
78485 +} __do_const;
78486
78487 /*
78488 * Newer version of video_device, handled by videodev2.c
78489 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
78490 index c9b1593..a572459 100644
78491 --- a/include/media/v4l2-device.h
78492 +++ b/include/media/v4l2-device.h
78493 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
78494 this function returns 0. If the name ends with a digit (e.g. cx18),
78495 then the name will be set to cx18-0 since cx180 looks really odd. */
78496 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
78497 - atomic_t *instance);
78498 + atomic_unchecked_t *instance);
78499
78500 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
78501 Since the parent disappears this ensures that v4l2_dev doesn't have an
78502 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
78503 index 9a36d92..0aafe2a 100644
78504 --- a/include/net/9p/transport.h
78505 +++ b/include/net/9p/transport.h
78506 @@ -60,7 +60,7 @@ struct p9_trans_module {
78507 int (*cancel) (struct p9_client *, struct p9_req_t *req);
78508 int (*zc_request)(struct p9_client *, struct p9_req_t *,
78509 char *, char *, int , int, int, int);
78510 -};
78511 +} __do_const;
78512
78513 void v9fs_register_trans(struct p9_trans_module *m);
78514 void v9fs_unregister_trans(struct p9_trans_module *m);
78515 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
78516 index 1a966af..2767cf6 100644
78517 --- a/include/net/bluetooth/l2cap.h
78518 +++ b/include/net/bluetooth/l2cap.h
78519 @@ -551,7 +551,7 @@ struct l2cap_ops {
78520 void (*defer) (struct l2cap_chan *chan);
78521 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
78522 unsigned long len, int nb);
78523 -};
78524 +} __do_const;
78525
78526 struct l2cap_conn {
78527 struct hci_conn *hcon;
78528 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
78529 index f2ae33d..c457cf0 100644
78530 --- a/include/net/caif/cfctrl.h
78531 +++ b/include/net/caif/cfctrl.h
78532 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
78533 void (*radioset_rsp)(void);
78534 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
78535 struct cflayer *client_layer);
78536 -};
78537 +} __no_const;
78538
78539 /* Link Setup Parameters for CAIF-Links. */
78540 struct cfctrl_link_param {
78541 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
78542 struct cfctrl {
78543 struct cfsrvl serv;
78544 struct cfctrl_rsp res;
78545 - atomic_t req_seq_no;
78546 - atomic_t rsp_seq_no;
78547 + atomic_unchecked_t req_seq_no;
78548 + atomic_unchecked_t rsp_seq_no;
78549 struct list_head list;
78550 /* Protects from simultaneous access to first_req list */
78551 spinlock_t info_list_lock;
78552 diff --git a/include/net/flow.h b/include/net/flow.h
78553 index 628e11b..4c475df 100644
78554 --- a/include/net/flow.h
78555 +++ b/include/net/flow.h
78556 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
78557
78558 extern void flow_cache_flush(void);
78559 extern void flow_cache_flush_deferred(void);
78560 -extern atomic_t flow_cache_genid;
78561 +extern atomic_unchecked_t flow_cache_genid;
78562
78563 #endif
78564 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
78565 index 8e0b6c8..73cf605 100644
78566 --- a/include/net/genetlink.h
78567 +++ b/include/net/genetlink.h
78568 @@ -120,7 +120,7 @@ struct genl_ops {
78569 struct netlink_callback *cb);
78570 int (*done)(struct netlink_callback *cb);
78571 struct list_head ops_list;
78572 -};
78573 +} __do_const;
78574
78575 extern int __genl_register_family(struct genl_family *family);
78576
78577 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
78578 index 734d9b5..48a9a4b 100644
78579 --- a/include/net/gro_cells.h
78580 +++ b/include/net/gro_cells.h
78581 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
78582 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
78583
78584 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
78585 - atomic_long_inc(&dev->rx_dropped);
78586 + atomic_long_inc_unchecked(&dev->rx_dropped);
78587 kfree_skb(skb);
78588 return;
78589 }
78590 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
78591 index de2c785..0588a6b 100644
78592 --- a/include/net/inet_connection_sock.h
78593 +++ b/include/net/inet_connection_sock.h
78594 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
78595 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
78596 int (*bind_conflict)(const struct sock *sk,
78597 const struct inet_bind_bucket *tb, bool relax);
78598 -};
78599 +} __do_const;
78600
78601 /** inet_connection_sock - INET connection oriented sock
78602 *
78603 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
78604 index 53f464d..0bd0b49 100644
78605 --- a/include/net/inetpeer.h
78606 +++ b/include/net/inetpeer.h
78607 @@ -47,8 +47,8 @@ struct inet_peer {
78608 */
78609 union {
78610 struct {
78611 - atomic_t rid; /* Frag reception counter */
78612 - atomic_t ip_id_count; /* IP ID for the next packet */
78613 + atomic_unchecked_t rid; /* Frag reception counter */
78614 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
78615 };
78616 struct rcu_head rcu;
78617 struct inet_peer *gc_next;
78618 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
78619 /* can be called with or without local BH being disabled */
78620 static inline int inet_getid(struct inet_peer *p, int more)
78621 {
78622 - int old, new;
78623 + int id;
78624 more++;
78625 inet_peer_refcheck(p);
78626 - do {
78627 - old = atomic_read(&p->ip_id_count);
78628 - new = old + more;
78629 - if (!new)
78630 - new = 1;
78631 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
78632 - return new;
78633 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
78634 + if (!id)
78635 + id = atomic_inc_return_unchecked(&p->ip_id_count);
78636 + return id;
78637 }
78638
78639 #endif /* _NET_INETPEER_H */
78640 diff --git a/include/net/ip.h b/include/net/ip.h
78641 index 5e52688..f181e95 100644
78642 --- a/include/net/ip.h
78643 +++ b/include/net/ip.h
78644 @@ -212,7 +212,7 @@ extern struct local_ports {
78645 } sysctl_local_ports;
78646 extern void inet_get_local_port_range(int *low, int *high);
78647
78648 -extern unsigned long *sysctl_local_reserved_ports;
78649 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
78650 static inline int inet_is_reserved_local_port(int port)
78651 {
78652 return test_bit(port, sysctl_local_reserved_ports);
78653 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
78654 index cbf2be3..3683f6d 100644
78655 --- a/include/net/ip_fib.h
78656 +++ b/include/net/ip_fib.h
78657 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
78658
78659 #define FIB_RES_SADDR(net, res) \
78660 ((FIB_RES_NH(res).nh_saddr_genid == \
78661 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
78662 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
78663 FIB_RES_NH(res).nh_saddr : \
78664 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
78665 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
78666 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
78667 index 9c4d37e..eed6d41 100644
78668 --- a/include/net/ip_vs.h
78669 +++ b/include/net/ip_vs.h
78670 @@ -588,7 +588,7 @@ struct ip_vs_conn {
78671 struct ip_vs_conn *control; /* Master control connection */
78672 atomic_t n_control; /* Number of controlled ones */
78673 struct ip_vs_dest *dest; /* real server */
78674 - atomic_t in_pkts; /* incoming packet counter */
78675 + atomic_unchecked_t in_pkts; /* incoming packet counter */
78676
78677 /* packet transmitter for different forwarding methods. If it
78678 mangles the packet, it must return NF_DROP or better NF_STOLEN,
78679 @@ -735,7 +735,7 @@ struct ip_vs_dest {
78680 __be16 port; /* port number of the server */
78681 union nf_inet_addr addr; /* IP address of the server */
78682 volatile unsigned int flags; /* dest status flags */
78683 - atomic_t conn_flags; /* flags to copy to conn */
78684 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
78685 atomic_t weight; /* server weight */
78686
78687 atomic_t refcnt; /* reference counter */
78688 @@ -990,11 +990,11 @@ struct netns_ipvs {
78689 /* ip_vs_lblc */
78690 int sysctl_lblc_expiration;
78691 struct ctl_table_header *lblc_ctl_header;
78692 - struct ctl_table *lblc_ctl_table;
78693 + ctl_table_no_const *lblc_ctl_table;
78694 /* ip_vs_lblcr */
78695 int sysctl_lblcr_expiration;
78696 struct ctl_table_header *lblcr_ctl_header;
78697 - struct ctl_table *lblcr_ctl_table;
78698 + ctl_table_no_const *lblcr_ctl_table;
78699 /* ip_vs_est */
78700 struct list_head est_list; /* estimator list */
78701 spinlock_t est_lock;
78702 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
78703 index 80ffde3..968b0f4 100644
78704 --- a/include/net/irda/ircomm_tty.h
78705 +++ b/include/net/irda/ircomm_tty.h
78706 @@ -35,6 +35,7 @@
78707 #include <linux/termios.h>
78708 #include <linux/timer.h>
78709 #include <linux/tty.h> /* struct tty_struct */
78710 +#include <asm/local.h>
78711
78712 #include <net/irda/irias_object.h>
78713 #include <net/irda/ircomm_core.h>
78714 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
78715 index 714cc9a..ea05f3e 100644
78716 --- a/include/net/iucv/af_iucv.h
78717 +++ b/include/net/iucv/af_iucv.h
78718 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
78719 struct iucv_sock_list {
78720 struct hlist_head head;
78721 rwlock_t lock;
78722 - atomic_t autobind_name;
78723 + atomic_unchecked_t autobind_name;
78724 };
78725
78726 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
78727 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
78728 index df83f69..9b640b8 100644
78729 --- a/include/net/llc_c_ac.h
78730 +++ b/include/net/llc_c_ac.h
78731 @@ -87,7 +87,7 @@
78732 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
78733 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
78734
78735 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78736 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78737
78738 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
78739 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
78740 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
78741 index 6ca3113..f8026dd 100644
78742 --- a/include/net/llc_c_ev.h
78743 +++ b/include/net/llc_c_ev.h
78744 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
78745 return (struct llc_conn_state_ev *)skb->cb;
78746 }
78747
78748 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78749 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78750 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78751 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78752
78753 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
78754 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
78755 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
78756 index 0e79cfb..f46db31 100644
78757 --- a/include/net/llc_c_st.h
78758 +++ b/include/net/llc_c_st.h
78759 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
78760 u8 next_state;
78761 llc_conn_ev_qfyr_t *ev_qualifiers;
78762 llc_conn_action_t *ev_actions;
78763 -};
78764 +} __do_const;
78765
78766 struct llc_conn_state {
78767 u8 current_state;
78768 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
78769 index 37a3bbd..55a4241 100644
78770 --- a/include/net/llc_s_ac.h
78771 +++ b/include/net/llc_s_ac.h
78772 @@ -23,7 +23,7 @@
78773 #define SAP_ACT_TEST_IND 9
78774
78775 /* All action functions must look like this */
78776 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78777 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78778
78779 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
78780 struct sk_buff *skb);
78781 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
78782 index 567c681..cd73ac0 100644
78783 --- a/include/net/llc_s_st.h
78784 +++ b/include/net/llc_s_st.h
78785 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
78786 llc_sap_ev_t ev;
78787 u8 next_state;
78788 llc_sap_action_t *ev_actions;
78789 -};
78790 +} __do_const;
78791
78792 struct llc_sap_state {
78793 u8 curr_state;
78794 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
78795 index cc6035f..a8406fc 100644
78796 --- a/include/net/mac80211.h
78797 +++ b/include/net/mac80211.h
78798 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
78799 void (*add_sta_debugfs)(void *priv, void *priv_sta,
78800 struct dentry *dir);
78801 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
78802 -};
78803 +} __do_const;
78804
78805 static inline int rate_supported(struct ieee80211_sta *sta,
78806 enum ieee80211_band band,
78807 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
78808 index 536501a..7c6193c 100644
78809 --- a/include/net/neighbour.h
78810 +++ b/include/net/neighbour.h
78811 @@ -123,7 +123,7 @@ struct neigh_ops {
78812 void (*error_report)(struct neighbour *, struct sk_buff *);
78813 int (*output)(struct neighbour *, struct sk_buff *);
78814 int (*connected_output)(struct neighbour *, struct sk_buff *);
78815 -};
78816 +} __do_const;
78817
78818 struct pneigh_entry {
78819 struct pneigh_entry *next;
78820 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
78821 index 9d22f08..980fbf8 100644
78822 --- a/include/net/net_namespace.h
78823 +++ b/include/net/net_namespace.h
78824 @@ -120,7 +120,7 @@ struct net {
78825 struct netns_ipvs *ipvs;
78826 #endif
78827 struct sock *diag_nlsk;
78828 - atomic_t fnhe_genid;
78829 + atomic_unchecked_t fnhe_genid;
78830 };
78831
78832 /*
78833 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
78834 #define __net_init __init
78835 #define __net_exit __exit_refok
78836 #define __net_initdata __initdata
78837 +#ifdef CONSTIFY_PLUGIN
78838 #define __net_initconst __initconst
78839 +#else
78840 +#define __net_initconst __initdata
78841 +#endif
78842 #endif
78843
78844 struct pernet_operations {
78845 @@ -287,7 +291,7 @@ struct pernet_operations {
78846 void (*exit_batch)(struct list_head *net_exit_list);
78847 int *id;
78848 size_t size;
78849 -};
78850 +} __do_const;
78851
78852 /*
78853 * Use these carefully. If you implement a network device and it
78854 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
78855
78856 static inline int rt_genid_ipv4(struct net *net)
78857 {
78858 - return atomic_read(&net->ipv4.rt_genid);
78859 + return atomic_read_unchecked(&net->ipv4.rt_genid);
78860 }
78861
78862 static inline void rt_genid_bump_ipv4(struct net *net)
78863 {
78864 - atomic_inc(&net->ipv4.rt_genid);
78865 + atomic_inc_unchecked(&net->ipv4.rt_genid);
78866 }
78867
78868 #if IS_ENABLED(CONFIG_IPV6)
78869 static inline int rt_genid_ipv6(struct net *net)
78870 {
78871 - return atomic_read(&net->ipv6.rt_genid);
78872 + return atomic_read_unchecked(&net->ipv6.rt_genid);
78873 }
78874
78875 static inline void rt_genid_bump_ipv6(struct net *net)
78876 {
78877 - atomic_inc(&net->ipv6.rt_genid);
78878 + atomic_inc_unchecked(&net->ipv6.rt_genid);
78879 }
78880 #else
78881 static inline int rt_genid_ipv6(struct net *net)
78882 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
78883
78884 static inline int fnhe_genid(struct net *net)
78885 {
78886 - return atomic_read(&net->fnhe_genid);
78887 + return atomic_read_unchecked(&net->fnhe_genid);
78888 }
78889
78890 static inline void fnhe_genid_bump(struct net *net)
78891 {
78892 - atomic_inc(&net->fnhe_genid);
78893 + atomic_inc_unchecked(&net->fnhe_genid);
78894 }
78895
78896 #endif /* __NET_NET_NAMESPACE_H */
78897 diff --git a/include/net/netdma.h b/include/net/netdma.h
78898 index 8ba8ce2..99b7fff 100644
78899 --- a/include/net/netdma.h
78900 +++ b/include/net/netdma.h
78901 @@ -24,7 +24,7 @@
78902 #include <linux/dmaengine.h>
78903 #include <linux/skbuff.h>
78904
78905 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78906 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78907 struct sk_buff *skb, int offset, struct iovec *to,
78908 size_t len, struct dma_pinned_list *pinned_list);
78909
78910 diff --git a/include/net/netlink.h b/include/net/netlink.h
78911 index 9690b0f..87aded7 100644
78912 --- a/include/net/netlink.h
78913 +++ b/include/net/netlink.h
78914 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78915 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78916 {
78917 if (mark)
78918 - skb_trim(skb, (unsigned char *) mark - skb->data);
78919 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78920 }
78921
78922 /**
78923 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78924 index c9c0c53..53f24c3 100644
78925 --- a/include/net/netns/conntrack.h
78926 +++ b/include/net/netns/conntrack.h
78927 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78928 struct nf_proto_net {
78929 #ifdef CONFIG_SYSCTL
78930 struct ctl_table_header *ctl_table_header;
78931 - struct ctl_table *ctl_table;
78932 + ctl_table_no_const *ctl_table;
78933 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78934 struct ctl_table_header *ctl_compat_header;
78935 - struct ctl_table *ctl_compat_table;
78936 + ctl_table_no_const *ctl_compat_table;
78937 #endif
78938 #endif
78939 unsigned int users;
78940 @@ -58,7 +58,7 @@ struct nf_ip_net {
78941 struct nf_icmp_net icmpv6;
78942 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78943 struct ctl_table_header *ctl_table_header;
78944 - struct ctl_table *ctl_table;
78945 + ctl_table_no_const *ctl_table;
78946 #endif
78947 };
78948
78949 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78950 index bf2ec22..5e7f9d9 100644
78951 --- a/include/net/netns/ipv4.h
78952 +++ b/include/net/netns/ipv4.h
78953 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78954 kgid_t sysctl_ping_group_range[2];
78955 long sysctl_tcp_mem[3];
78956
78957 - atomic_t dev_addr_genid;
78958 + atomic_unchecked_t dev_addr_genid;
78959
78960 #ifdef CONFIG_IP_MROUTE
78961 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78962 @@ -77,6 +77,6 @@ struct netns_ipv4 {
78963 struct fib_rules_ops *mr_rules_ops;
78964 #endif
78965 #endif
78966 - atomic_t rt_genid;
78967 + atomic_unchecked_t rt_genid;
78968 };
78969 #endif
78970 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78971 index 0fb2401..477d81c 100644
78972 --- a/include/net/netns/ipv6.h
78973 +++ b/include/net/netns/ipv6.h
78974 @@ -71,8 +71,8 @@ struct netns_ipv6 {
78975 struct fib_rules_ops *mr6_rules_ops;
78976 #endif
78977 #endif
78978 - atomic_t dev_addr_genid;
78979 - atomic_t rt_genid;
78980 + atomic_unchecked_t dev_addr_genid;
78981 + atomic_unchecked_t rt_genid;
78982 };
78983
78984 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78985 diff --git a/include/net/ping.h b/include/net/ping.h
78986 index 5db0224..0d65365 100644
78987 --- a/include/net/ping.h
78988 +++ b/include/net/ping.h
78989 @@ -55,7 +55,7 @@ struct ping_iter_state {
78990 extern struct proto ping_prot;
78991 extern struct ping_table ping_table;
78992 #if IS_ENABLED(CONFIG_IPV6)
78993 -extern struct pingv6_ops pingv6_ops;
78994 +extern struct pingv6_ops *pingv6_ops;
78995 #endif
78996
78997 struct pingfakehdr {
78998 diff --git a/include/net/protocol.h b/include/net/protocol.h
78999 index 047c047..b9dad15 100644
79000 --- a/include/net/protocol.h
79001 +++ b/include/net/protocol.h
79002 @@ -44,7 +44,7 @@ struct net_protocol {
79003 void (*err_handler)(struct sk_buff *skb, u32 info);
79004 unsigned int no_policy:1,
79005 netns_ok:1;
79006 -};
79007 +} __do_const;
79008
79009 #if IS_ENABLED(CONFIG_IPV6)
79010 struct inet6_protocol {
79011 @@ -57,7 +57,7 @@ struct inet6_protocol {
79012 u8 type, u8 code, int offset,
79013 __be32 info);
79014 unsigned int flags; /* INET6_PROTO_xxx */
79015 -};
79016 +} __do_const;
79017
79018 #define INET6_PROTO_NOPOLICY 0x1
79019 #define INET6_PROTO_FINAL 0x2
79020 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
79021 index 7026648..584cc8c 100644
79022 --- a/include/net/rtnetlink.h
79023 +++ b/include/net/rtnetlink.h
79024 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
79025 const struct net_device *dev);
79026 unsigned int (*get_num_tx_queues)(void);
79027 unsigned int (*get_num_rx_queues)(void);
79028 -};
79029 +} __do_const;
79030
79031 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
79032 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
79033 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
79034 index 4ef75af..5aa073a 100644
79035 --- a/include/net/sctp/sm.h
79036 +++ b/include/net/sctp/sm.h
79037 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
79038 typedef struct {
79039 sctp_state_fn_t *fn;
79040 const char *name;
79041 -} sctp_sm_table_entry_t;
79042 +} __do_const sctp_sm_table_entry_t;
79043
79044 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
79045 * currently in use.
79046 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
79047 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
79048
79049 /* Extern declarations for major data structures. */
79050 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79051 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79052
79053
79054 /* Get the size of a DATA chunk payload. */
79055 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
79056 index 2174d8d..71d5257 100644
79057 --- a/include/net/sctp/structs.h
79058 +++ b/include/net/sctp/structs.h
79059 @@ -508,7 +508,7 @@ struct sctp_pf {
79060 struct sctp_association *asoc);
79061 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
79062 struct sctp_af *af;
79063 -};
79064 +} __do_const;
79065
79066
79067 /* Structure to track chunk fragments that have been acked, but peer
79068 diff --git a/include/net/sock.h b/include/net/sock.h
79069 index 808cbc2..f6f6ac3 100644
79070 --- a/include/net/sock.h
79071 +++ b/include/net/sock.h
79072 @@ -332,7 +332,7 @@ struct sock {
79073 unsigned int sk_napi_id;
79074 unsigned int sk_ll_usec;
79075 #endif
79076 - atomic_t sk_drops;
79077 + atomic_unchecked_t sk_drops;
79078 int sk_rcvbuf;
79079
79080 struct sk_filter __rcu *sk_filter;
79081 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
79082 }
79083
79084 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
79085 - char __user *from, char *to,
79086 + char __user *from, unsigned char *to,
79087 int copy, int offset)
79088 {
79089 if (skb->ip_summed == CHECKSUM_NONE) {
79090 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
79091 }
79092 }
79093
79094 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79095 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79096
79097 /**
79098 * sk_page_frag - return an appropriate page_frag
79099 diff --git a/include/net/tcp.h b/include/net/tcp.h
79100 index b1aa324..b8530ea 100644
79101 --- a/include/net/tcp.h
79102 +++ b/include/net/tcp.h
79103 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
79104 extern void tcp_xmit_retransmit_queue(struct sock *);
79105 extern void tcp_simple_retransmit(struct sock *);
79106 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
79107 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79108 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79109
79110 extern void tcp_send_probe0(struct sock *);
79111 extern void tcp_send_partial(struct sock *);
79112 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
79113 struct inet6_skb_parm h6;
79114 #endif
79115 } header; /* For incoming frames */
79116 - __u32 seq; /* Starting sequence number */
79117 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
79118 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
79119 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
79120 __u32 when; /* used to compute rtt's */
79121 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
79122
79123 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
79124
79125 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
79126 /* 1 byte hole */
79127 - __u32 ack_seq; /* Sequence number ACK'd */
79128 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
79129 };
79130
79131 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
79132 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
79133 index e253bf0..2278b4b 100644
79134 --- a/include/net/xfrm.h
79135 +++ b/include/net/xfrm.h
79136 @@ -287,7 +287,6 @@ struct xfrm_dst;
79137 struct xfrm_policy_afinfo {
79138 unsigned short family;
79139 struct dst_ops *dst_ops;
79140 - void (*garbage_collect)(struct net *net);
79141 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
79142 const xfrm_address_t *saddr,
79143 const xfrm_address_t *daddr);
79144 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
79145 struct net_device *dev,
79146 const struct flowi *fl);
79147 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
79148 -};
79149 +} __do_const;
79150
79151 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
79152 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
79153 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
79154 int (*transport_finish)(struct sk_buff *skb,
79155 int async);
79156 void (*local_error)(struct sk_buff *skb, u32 mtu);
79157 -};
79158 +} __do_const;
79159
79160 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
79161 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
79162 @@ -427,7 +426,7 @@ struct xfrm_mode {
79163 struct module *owner;
79164 unsigned int encap;
79165 int flags;
79166 -};
79167 +} __do_const;
79168
79169 /* Flags for xfrm_mode. */
79170 enum {
79171 @@ -524,7 +523,7 @@ struct xfrm_policy {
79172 struct timer_list timer;
79173
79174 struct flow_cache_object flo;
79175 - atomic_t genid;
79176 + atomic_unchecked_t genid;
79177 u32 priority;
79178 u32 index;
79179 struct xfrm_mark mark;
79180 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
79181 }
79182
79183 extern void xfrm_garbage_collect(struct net *net);
79184 +extern void xfrm_garbage_collect_deferred(struct net *net);
79185
79186 #else
79187
79188 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
79189 static inline void xfrm_garbage_collect(struct net *net)
79190 {
79191 }
79192 +static inline void xfrm_garbage_collect_deferred(struct net *net)
79193 +{
79194 +}
79195 #endif
79196
79197 static __inline__
79198 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
79199 index 1017e0b..227aa4d 100644
79200 --- a/include/rdma/iw_cm.h
79201 +++ b/include/rdma/iw_cm.h
79202 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
79203 int backlog);
79204
79205 int (*destroy_listen)(struct iw_cm_id *cm_id);
79206 -};
79207 +} __no_const;
79208
79209 /**
79210 * iw_create_cm_id - Create an IW CM identifier.
79211 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
79212 index e1379b4..67eafbe 100644
79213 --- a/include/scsi/libfc.h
79214 +++ b/include/scsi/libfc.h
79215 @@ -762,6 +762,7 @@ struct libfc_function_template {
79216 */
79217 void (*disc_stop_final) (struct fc_lport *);
79218 };
79219 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
79220
79221 /**
79222 * struct fc_disc - Discovery context
79223 @@ -866,7 +867,7 @@ struct fc_lport {
79224 struct fc_vport *vport;
79225
79226 /* Operational Information */
79227 - struct libfc_function_template tt;
79228 + libfc_function_template_no_const tt;
79229 u8 link_up;
79230 u8 qfull;
79231 enum fc_lport_state state;
79232 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
79233 index d65fbec..f80fef2 100644
79234 --- a/include/scsi/scsi_device.h
79235 +++ b/include/scsi/scsi_device.h
79236 @@ -180,9 +180,9 @@ struct scsi_device {
79237 unsigned int max_device_blocked; /* what device_blocked counts down from */
79238 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
79239
79240 - atomic_t iorequest_cnt;
79241 - atomic_t iodone_cnt;
79242 - atomic_t ioerr_cnt;
79243 + atomic_unchecked_t iorequest_cnt;
79244 + atomic_unchecked_t iodone_cnt;
79245 + atomic_unchecked_t ioerr_cnt;
79246
79247 struct device sdev_gendev,
79248 sdev_dev;
79249 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
79250 index b797e8f..8e2c3aa 100644
79251 --- a/include/scsi/scsi_transport_fc.h
79252 +++ b/include/scsi/scsi_transport_fc.h
79253 @@ -751,7 +751,8 @@ struct fc_function_template {
79254 unsigned long show_host_system_hostname:1;
79255
79256 unsigned long disable_target_scan:1;
79257 -};
79258 +} __do_const;
79259 +typedef struct fc_function_template __no_const fc_function_template_no_const;
79260
79261
79262 /**
79263 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
79264 index 9031a26..750d592 100644
79265 --- a/include/sound/compress_driver.h
79266 +++ b/include/sound/compress_driver.h
79267 @@ -128,7 +128,7 @@ struct snd_compr_ops {
79268 struct snd_compr_caps *caps);
79269 int (*get_codec_caps) (struct snd_compr_stream *stream,
79270 struct snd_compr_codec_caps *codec);
79271 -};
79272 +} __no_const;
79273
79274 /**
79275 * struct snd_compr: Compressed device
79276 diff --git a/include/sound/soc.h b/include/sound/soc.h
79277 index d22cb0a..c6ba150 100644
79278 --- a/include/sound/soc.h
79279 +++ b/include/sound/soc.h
79280 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
79281 /* probe ordering - for components with runtime dependencies */
79282 int probe_order;
79283 int remove_order;
79284 -};
79285 +} __do_const;
79286
79287 /* SoC platform interface */
79288 struct snd_soc_platform_driver {
79289 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
79290 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
79291 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
79292 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
79293 -};
79294 +} __do_const;
79295
79296 struct snd_soc_platform {
79297 const char *name;
79298 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
79299 index 5bdb8b7..bb1096c 100644
79300 --- a/include/target/target_core_base.h
79301 +++ b/include/target/target_core_base.h
79302 @@ -663,7 +663,7 @@ struct se_device {
79303 spinlock_t stats_lock;
79304 /* Active commands on this virtual SE device */
79305 atomic_t simple_cmds;
79306 - atomic_t dev_ordered_id;
79307 + atomic_unchecked_t dev_ordered_id;
79308 atomic_t dev_ordered_sync;
79309 atomic_t dev_qf_count;
79310 int export_count;
79311 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
79312 new file mode 100644
79313 index 0000000..fb634b7
79314 --- /dev/null
79315 +++ b/include/trace/events/fs.h
79316 @@ -0,0 +1,53 @@
79317 +#undef TRACE_SYSTEM
79318 +#define TRACE_SYSTEM fs
79319 +
79320 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
79321 +#define _TRACE_FS_H
79322 +
79323 +#include <linux/fs.h>
79324 +#include <linux/tracepoint.h>
79325 +
79326 +TRACE_EVENT(do_sys_open,
79327 +
79328 + TP_PROTO(const char *filename, int flags, int mode),
79329 +
79330 + TP_ARGS(filename, flags, mode),
79331 +
79332 + TP_STRUCT__entry(
79333 + __string( filename, filename )
79334 + __field( int, flags )
79335 + __field( int, mode )
79336 + ),
79337 +
79338 + TP_fast_assign(
79339 + __assign_str(filename, filename);
79340 + __entry->flags = flags;
79341 + __entry->mode = mode;
79342 + ),
79343 +
79344 + TP_printk("\"%s\" %x %o",
79345 + __get_str(filename), __entry->flags, __entry->mode)
79346 +);
79347 +
79348 +TRACE_EVENT(open_exec,
79349 +
79350 + TP_PROTO(const char *filename),
79351 +
79352 + TP_ARGS(filename),
79353 +
79354 + TP_STRUCT__entry(
79355 + __string( filename, filename )
79356 + ),
79357 +
79358 + TP_fast_assign(
79359 + __assign_str(filename, filename);
79360 + ),
79361 +
79362 + TP_printk("\"%s\"",
79363 + __get_str(filename))
79364 +);
79365 +
79366 +#endif /* _TRACE_FS_H */
79367 +
79368 +/* This part must be outside protection */
79369 +#include <trace/define_trace.h>
79370 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
79371 index 1c09820..7f5ec79 100644
79372 --- a/include/trace/events/irq.h
79373 +++ b/include/trace/events/irq.h
79374 @@ -36,7 +36,7 @@ struct softirq_action;
79375 */
79376 TRACE_EVENT(irq_handler_entry,
79377
79378 - TP_PROTO(int irq, struct irqaction *action),
79379 + TP_PROTO(int irq, const struct irqaction *action),
79380
79381 TP_ARGS(irq, action),
79382
79383 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
79384 */
79385 TRACE_EVENT(irq_handler_exit,
79386
79387 - TP_PROTO(int irq, struct irqaction *action, int ret),
79388 + TP_PROTO(int irq, const struct irqaction *action, int ret),
79389
79390 TP_ARGS(irq, action, ret),
79391
79392 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
79393 index 7caf44c..23c6f27 100644
79394 --- a/include/uapi/linux/a.out.h
79395 +++ b/include/uapi/linux/a.out.h
79396 @@ -39,6 +39,14 @@ enum machine_type {
79397 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
79398 };
79399
79400 +/* Constants for the N_FLAGS field */
79401 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79402 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
79403 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
79404 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
79405 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79406 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79407 +
79408 #if !defined (N_MAGIC)
79409 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
79410 #endif
79411 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
79412 index d876736..ccce5c0 100644
79413 --- a/include/uapi/linux/byteorder/little_endian.h
79414 +++ b/include/uapi/linux/byteorder/little_endian.h
79415 @@ -42,51 +42,51 @@
79416
79417 static inline __le64 __cpu_to_le64p(const __u64 *p)
79418 {
79419 - return (__force __le64)*p;
79420 + return (__force const __le64)*p;
79421 }
79422 -static inline __u64 __le64_to_cpup(const __le64 *p)
79423 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
79424 {
79425 - return (__force __u64)*p;
79426 + return (__force const __u64)*p;
79427 }
79428 static inline __le32 __cpu_to_le32p(const __u32 *p)
79429 {
79430 - return (__force __le32)*p;
79431 + return (__force const __le32)*p;
79432 }
79433 static inline __u32 __le32_to_cpup(const __le32 *p)
79434 {
79435 - return (__force __u32)*p;
79436 + return (__force const __u32)*p;
79437 }
79438 static inline __le16 __cpu_to_le16p(const __u16 *p)
79439 {
79440 - return (__force __le16)*p;
79441 + return (__force const __le16)*p;
79442 }
79443 static inline __u16 __le16_to_cpup(const __le16 *p)
79444 {
79445 - return (__force __u16)*p;
79446 + return (__force const __u16)*p;
79447 }
79448 static inline __be64 __cpu_to_be64p(const __u64 *p)
79449 {
79450 - return (__force __be64)__swab64p(p);
79451 + return (__force const __be64)__swab64p(p);
79452 }
79453 static inline __u64 __be64_to_cpup(const __be64 *p)
79454 {
79455 - return __swab64p((__u64 *)p);
79456 + return __swab64p((const __u64 *)p);
79457 }
79458 static inline __be32 __cpu_to_be32p(const __u32 *p)
79459 {
79460 - return (__force __be32)__swab32p(p);
79461 + return (__force const __be32)__swab32p(p);
79462 }
79463 -static inline __u32 __be32_to_cpup(const __be32 *p)
79464 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
79465 {
79466 - return __swab32p((__u32 *)p);
79467 + return __swab32p((const __u32 *)p);
79468 }
79469 static inline __be16 __cpu_to_be16p(const __u16 *p)
79470 {
79471 - return (__force __be16)__swab16p(p);
79472 + return (__force const __be16)__swab16p(p);
79473 }
79474 static inline __u16 __be16_to_cpup(const __be16 *p)
79475 {
79476 - return __swab16p((__u16 *)p);
79477 + return __swab16p((const __u16 *)p);
79478 }
79479 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
79480 #define __le64_to_cpus(x) do { (void)(x); } while (0)
79481 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
79482 index ef6103b..d4e65dd 100644
79483 --- a/include/uapi/linux/elf.h
79484 +++ b/include/uapi/linux/elf.h
79485 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
79486 #define PT_GNU_EH_FRAME 0x6474e550
79487
79488 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
79489 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
79490 +
79491 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
79492 +
79493 +/* Constants for the e_flags field */
79494 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79495 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
79496 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
79497 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
79498 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79499 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79500
79501 /*
79502 * Extended Numbering
79503 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
79504 #define DT_DEBUG 21
79505 #define DT_TEXTREL 22
79506 #define DT_JMPREL 23
79507 +#define DT_FLAGS 30
79508 + #define DF_TEXTREL 0x00000004
79509 #define DT_ENCODING 32
79510 #define OLD_DT_LOOS 0x60000000
79511 #define DT_LOOS 0x6000000d
79512 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
79513 #define PF_W 0x2
79514 #define PF_X 0x1
79515
79516 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
79517 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
79518 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
79519 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
79520 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
79521 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
79522 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
79523 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
79524 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
79525 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
79526 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
79527 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
79528 +
79529 typedef struct elf32_phdr{
79530 Elf32_Word p_type;
79531 Elf32_Off p_offset;
79532 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
79533 #define EI_OSABI 7
79534 #define EI_PAD 8
79535
79536 +#define EI_PAX 14
79537 +
79538 #define ELFMAG0 0x7f /* EI_MAG */
79539 #define ELFMAG1 'E'
79540 #define ELFMAG2 'L'
79541 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
79542 index aa169c4..6a2771d 100644
79543 --- a/include/uapi/linux/personality.h
79544 +++ b/include/uapi/linux/personality.h
79545 @@ -30,6 +30,7 @@ enum {
79546 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
79547 ADDR_NO_RANDOMIZE | \
79548 ADDR_COMPAT_LAYOUT | \
79549 + ADDR_LIMIT_3GB | \
79550 MMAP_PAGE_ZERO)
79551
79552 /*
79553 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
79554 index 7530e74..e714828 100644
79555 --- a/include/uapi/linux/screen_info.h
79556 +++ b/include/uapi/linux/screen_info.h
79557 @@ -43,7 +43,8 @@ struct screen_info {
79558 __u16 pages; /* 0x32 */
79559 __u16 vesa_attributes; /* 0x34 */
79560 __u32 capabilities; /* 0x36 */
79561 - __u8 _reserved[6]; /* 0x3a */
79562 + __u16 vesapm_size; /* 0x3a */
79563 + __u8 _reserved[4]; /* 0x3c */
79564 } __attribute__((packed));
79565
79566 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
79567 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
79568 index 0e011eb..82681b1 100644
79569 --- a/include/uapi/linux/swab.h
79570 +++ b/include/uapi/linux/swab.h
79571 @@ -43,7 +43,7 @@
79572 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
79573 */
79574
79575 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
79576 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
79577 {
79578 #ifdef __HAVE_BUILTIN_BSWAP16__
79579 return __builtin_bswap16(val);
79580 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
79581 #endif
79582 }
79583
79584 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
79585 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
79586 {
79587 #ifdef __HAVE_BUILTIN_BSWAP32__
79588 return __builtin_bswap32(val);
79589 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
79590 #endif
79591 }
79592
79593 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
79594 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
79595 {
79596 #ifdef __HAVE_BUILTIN_BSWAP64__
79597 return __builtin_bswap64(val);
79598 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
79599 index 6d67213..8dab561 100644
79600 --- a/include/uapi/linux/sysctl.h
79601 +++ b/include/uapi/linux/sysctl.h
79602 @@ -155,7 +155,11 @@ enum
79603 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
79604 };
79605
79606 -
79607 +#ifdef CONFIG_PAX_SOFTMODE
79608 +enum {
79609 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
79610 +};
79611 +#endif
79612
79613 /* CTL_VM names: */
79614 enum
79615 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
79616 index e4629b9..6958086 100644
79617 --- a/include/uapi/linux/xattr.h
79618 +++ b/include/uapi/linux/xattr.h
79619 @@ -63,5 +63,9 @@
79620 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
79621 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
79622
79623 +/* User namespace */
79624 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
79625 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
79626 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
79627
79628 #endif /* _UAPI_LINUX_XATTR_H */
79629 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
79630 index f9466fa..f4e2b81 100644
79631 --- a/include/video/udlfb.h
79632 +++ b/include/video/udlfb.h
79633 @@ -53,10 +53,10 @@ struct dlfb_data {
79634 u32 pseudo_palette[256];
79635 int blank_mode; /*one of FB_BLANK_ */
79636 /* blit-only rendering path metrics, exposed through sysfs */
79637 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79638 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
79639 - atomic_t bytes_sent; /* to usb, after compression including overhead */
79640 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
79641 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79642 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
79643 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
79644 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
79645 };
79646
79647 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
79648 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
79649 index 30f5362..8ed8ac9 100644
79650 --- a/include/video/uvesafb.h
79651 +++ b/include/video/uvesafb.h
79652 @@ -122,6 +122,7 @@ struct uvesafb_par {
79653 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
79654 u8 pmi_setpal; /* PMI for palette changes */
79655 u16 *pmi_base; /* protected mode interface location */
79656 + u8 *pmi_code; /* protected mode code location */
79657 void *pmi_start;
79658 void *pmi_pal;
79659 u8 *vbe_state_orig; /*
79660 diff --git a/init/Kconfig b/init/Kconfig
79661 index 3ecd8a1..627843f 100644
79662 --- a/init/Kconfig
79663 +++ b/init/Kconfig
79664 @@ -1086,6 +1086,7 @@ endif # CGROUPS
79665
79666 config CHECKPOINT_RESTORE
79667 bool "Checkpoint/restore support" if EXPERT
79668 + depends on !GRKERNSEC
79669 default n
79670 help
79671 Enables additional kernel features in a sake of checkpoint/restore.
79672 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
79673
79674 config COMPAT_BRK
79675 bool "Disable heap randomization"
79676 - default y
79677 + default n
79678 help
79679 Randomizing heap placement makes heap exploits harder, but it
79680 also breaks ancient binaries (including anything libc5 based).
79681 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
79682 config STOP_MACHINE
79683 bool
79684 default y
79685 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
79686 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
79687 help
79688 Need stop_machine() primitive.
79689
79690 diff --git a/init/Makefile b/init/Makefile
79691 index 7bc47ee..6da2dc7 100644
79692 --- a/init/Makefile
79693 +++ b/init/Makefile
79694 @@ -2,6 +2,9 @@
79695 # Makefile for the linux kernel.
79696 #
79697
79698 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
79699 +asflags-y := $(GCC_PLUGINS_AFLAGS)
79700 +
79701 obj-y := main.o version.o mounts.o
79702 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
79703 obj-y += noinitramfs.o
79704 diff --git a/init/do_mounts.c b/init/do_mounts.c
79705 index a51cddc..25c2768 100644
79706 --- a/init/do_mounts.c
79707 +++ b/init/do_mounts.c
79708 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
79709 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
79710 {
79711 struct super_block *s;
79712 - int err = sys_mount(name, "/root", fs, flags, data);
79713 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
79714 if (err)
79715 return err;
79716
79717 - sys_chdir("/root");
79718 + sys_chdir((const char __force_user *)"/root");
79719 s = current->fs->pwd.dentry->d_sb;
79720 ROOT_DEV = s->s_dev;
79721 printk(KERN_INFO
79722 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
79723 va_start(args, fmt);
79724 vsprintf(buf, fmt, args);
79725 va_end(args);
79726 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
79727 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
79728 if (fd >= 0) {
79729 sys_ioctl(fd, FDEJECT, 0);
79730 sys_close(fd);
79731 }
79732 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
79733 - fd = sys_open("/dev/console", O_RDWR, 0);
79734 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
79735 if (fd >= 0) {
79736 sys_ioctl(fd, TCGETS, (long)&termios);
79737 termios.c_lflag &= ~ICANON;
79738 sys_ioctl(fd, TCSETSF, (long)&termios);
79739 - sys_read(fd, &c, 1);
79740 + sys_read(fd, (char __user *)&c, 1);
79741 termios.c_lflag |= ICANON;
79742 sys_ioctl(fd, TCSETSF, (long)&termios);
79743 sys_close(fd);
79744 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
79745 mount_root();
79746 out:
79747 devtmpfs_mount("dev");
79748 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79749 - sys_chroot(".");
79750 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79751 + sys_chroot((const char __force_user *)".");
79752 }
79753
79754 static bool is_tmpfs;
79755 diff --git a/init/do_mounts.h b/init/do_mounts.h
79756 index f5b978a..69dbfe8 100644
79757 --- a/init/do_mounts.h
79758 +++ b/init/do_mounts.h
79759 @@ -15,15 +15,15 @@ extern int root_mountflags;
79760
79761 static inline int create_dev(char *name, dev_t dev)
79762 {
79763 - sys_unlink(name);
79764 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
79765 + sys_unlink((char __force_user *)name);
79766 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
79767 }
79768
79769 #if BITS_PER_LONG == 32
79770 static inline u32 bstat(char *name)
79771 {
79772 struct stat64 stat;
79773 - if (sys_stat64(name, &stat) != 0)
79774 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
79775 return 0;
79776 if (!S_ISBLK(stat.st_mode))
79777 return 0;
79778 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
79779 static inline u32 bstat(char *name)
79780 {
79781 struct stat stat;
79782 - if (sys_newstat(name, &stat) != 0)
79783 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
79784 return 0;
79785 if (!S_ISBLK(stat.st_mode))
79786 return 0;
79787 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
79788 index 3e0878e..8a9d7a0 100644
79789 --- a/init/do_mounts_initrd.c
79790 +++ b/init/do_mounts_initrd.c
79791 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
79792 {
79793 sys_unshare(CLONE_FS | CLONE_FILES);
79794 /* stdin/stdout/stderr for /linuxrc */
79795 - sys_open("/dev/console", O_RDWR, 0);
79796 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
79797 sys_dup(0);
79798 sys_dup(0);
79799 /* move initrd over / and chdir/chroot in initrd root */
79800 - sys_chdir("/root");
79801 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79802 - sys_chroot(".");
79803 + sys_chdir((const char __force_user *)"/root");
79804 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79805 + sys_chroot((const char __force_user *)".");
79806 sys_setsid();
79807 return 0;
79808 }
79809 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
79810 create_dev("/dev/root.old", Root_RAM0);
79811 /* mount initrd on rootfs' /root */
79812 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
79813 - sys_mkdir("/old", 0700);
79814 - sys_chdir("/old");
79815 + sys_mkdir((const char __force_user *)"/old", 0700);
79816 + sys_chdir((const char __force_user *)"/old");
79817
79818 /* try loading default modules from initrd */
79819 load_default_modules();
79820 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
79821 current->flags &= ~PF_FREEZER_SKIP;
79822
79823 /* move initrd to rootfs' /old */
79824 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
79825 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
79826 /* switch root and cwd back to / of rootfs */
79827 - sys_chroot("..");
79828 + sys_chroot((const char __force_user *)"..");
79829
79830 if (new_decode_dev(real_root_dev) == Root_RAM0) {
79831 - sys_chdir("/old");
79832 + sys_chdir((const char __force_user *)"/old");
79833 return;
79834 }
79835
79836 - sys_chdir("/");
79837 + sys_chdir((const char __force_user *)"/");
79838 ROOT_DEV = new_decode_dev(real_root_dev);
79839 mount_root();
79840
79841 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
79842 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
79843 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
79844 if (!error)
79845 printk("okay\n");
79846 else {
79847 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
79848 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
79849 if (error == -ENOENT)
79850 printk("/initrd does not exist. Ignored.\n");
79851 else
79852 printk("failed\n");
79853 printk(KERN_NOTICE "Unmounting old root\n");
79854 - sys_umount("/old", MNT_DETACH);
79855 + sys_umount((char __force_user *)"/old", MNT_DETACH);
79856 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
79857 if (fd < 0) {
79858 error = fd;
79859 @@ -127,11 +127,11 @@ int __init initrd_load(void)
79860 * mounted in the normal path.
79861 */
79862 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
79863 - sys_unlink("/initrd.image");
79864 + sys_unlink((const char __force_user *)"/initrd.image");
79865 handle_initrd();
79866 return 1;
79867 }
79868 }
79869 - sys_unlink("/initrd.image");
79870 + sys_unlink((const char __force_user *)"/initrd.image");
79871 return 0;
79872 }
79873 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
79874 index 8cb6db5..d729f50 100644
79875 --- a/init/do_mounts_md.c
79876 +++ b/init/do_mounts_md.c
79877 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
79878 partitioned ? "_d" : "", minor,
79879 md_setup_args[ent].device_names);
79880
79881 - fd = sys_open(name, 0, 0);
79882 + fd = sys_open((char __force_user *)name, 0, 0);
79883 if (fd < 0) {
79884 printk(KERN_ERR "md: open failed - cannot start "
79885 "array %s\n", name);
79886 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
79887 * array without it
79888 */
79889 sys_close(fd);
79890 - fd = sys_open(name, 0, 0);
79891 + fd = sys_open((char __force_user *)name, 0, 0);
79892 sys_ioctl(fd, BLKRRPART, 0);
79893 }
79894 sys_close(fd);
79895 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
79896
79897 wait_for_device_probe();
79898
79899 - fd = sys_open("/dev/md0", 0, 0);
79900 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
79901 if (fd >= 0) {
79902 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
79903 sys_close(fd);
79904 diff --git a/init/init_task.c b/init/init_task.c
79905 index ba0a7f36..2bcf1d5 100644
79906 --- a/init/init_task.c
79907 +++ b/init/init_task.c
79908 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
79909 * Initial thread structure. Alignment of this is handled by a special
79910 * linker map entry.
79911 */
79912 +#ifdef CONFIG_X86
79913 +union thread_union init_thread_union __init_task_data;
79914 +#else
79915 union thread_union init_thread_union __init_task_data =
79916 { INIT_THREAD_INFO(init_task) };
79917 +#endif
79918 diff --git a/init/initramfs.c b/init/initramfs.c
79919 index a67ef9d..2d17ed9 100644
79920 --- a/init/initramfs.c
79921 +++ b/init/initramfs.c
79922 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79923 }
79924 }
79925
79926 -static long __init do_utime(char *filename, time_t mtime)
79927 +static long __init do_utime(char __force_user *filename, time_t mtime)
79928 {
79929 struct timespec t[2];
79930
79931 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79932 struct dir_entry *de, *tmp;
79933 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79934 list_del(&de->list);
79935 - do_utime(de->name, de->mtime);
79936 + do_utime((char __force_user *)de->name, de->mtime);
79937 kfree(de->name);
79938 kfree(de);
79939 }
79940 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79941 if (nlink >= 2) {
79942 char *old = find_link(major, minor, ino, mode, collected);
79943 if (old)
79944 - return (sys_link(old, collected) < 0) ? -1 : 1;
79945 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79946 }
79947 return 0;
79948 }
79949 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79950 {
79951 struct stat st;
79952
79953 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79954 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79955 if (S_ISDIR(st.st_mode))
79956 - sys_rmdir(path);
79957 + sys_rmdir((char __force_user *)path);
79958 else
79959 - sys_unlink(path);
79960 + sys_unlink((char __force_user *)path);
79961 }
79962 }
79963
79964 @@ -315,7 +315,7 @@ static int __init do_name(void)
79965 int openflags = O_WRONLY|O_CREAT;
79966 if (ml != 1)
79967 openflags |= O_TRUNC;
79968 - wfd = sys_open(collected, openflags, mode);
79969 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79970
79971 if (wfd >= 0) {
79972 sys_fchown(wfd, uid, gid);
79973 @@ -327,17 +327,17 @@ static int __init do_name(void)
79974 }
79975 }
79976 } else if (S_ISDIR(mode)) {
79977 - sys_mkdir(collected, mode);
79978 - sys_chown(collected, uid, gid);
79979 - sys_chmod(collected, mode);
79980 + sys_mkdir((char __force_user *)collected, mode);
79981 + sys_chown((char __force_user *)collected, uid, gid);
79982 + sys_chmod((char __force_user *)collected, mode);
79983 dir_add(collected, mtime);
79984 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79985 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79986 if (maybe_link() == 0) {
79987 - sys_mknod(collected, mode, rdev);
79988 - sys_chown(collected, uid, gid);
79989 - sys_chmod(collected, mode);
79990 - do_utime(collected, mtime);
79991 + sys_mknod((char __force_user *)collected, mode, rdev);
79992 + sys_chown((char __force_user *)collected, uid, gid);
79993 + sys_chmod((char __force_user *)collected, mode);
79994 + do_utime((char __force_user *)collected, mtime);
79995 }
79996 }
79997 return 0;
79998 @@ -346,15 +346,15 @@ static int __init do_name(void)
79999 static int __init do_copy(void)
80000 {
80001 if (count >= body_len) {
80002 - sys_write(wfd, victim, body_len);
80003 + sys_write(wfd, (char __force_user *)victim, body_len);
80004 sys_close(wfd);
80005 - do_utime(vcollected, mtime);
80006 + do_utime((char __force_user *)vcollected, mtime);
80007 kfree(vcollected);
80008 eat(body_len);
80009 state = SkipIt;
80010 return 0;
80011 } else {
80012 - sys_write(wfd, victim, count);
80013 + sys_write(wfd, (char __force_user *)victim, count);
80014 body_len -= count;
80015 eat(count);
80016 return 1;
80017 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
80018 {
80019 collected[N_ALIGN(name_len) + body_len] = '\0';
80020 clean_path(collected, 0);
80021 - sys_symlink(collected + N_ALIGN(name_len), collected);
80022 - sys_lchown(collected, uid, gid);
80023 - do_utime(collected, mtime);
80024 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
80025 + sys_lchown((char __force_user *)collected, uid, gid);
80026 + do_utime((char __force_user *)collected, mtime);
80027 state = SkipIt;
80028 next_state = Reset;
80029 return 0;
80030 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
80031 {
80032 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
80033 if (err)
80034 - panic(err); /* Failed to decompress INTERNAL initramfs */
80035 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
80036 if (initrd_start) {
80037 #ifdef CONFIG_BLK_DEV_RAM
80038 int fd;
80039 diff --git a/init/main.c b/init/main.c
80040 index 63d3e8f..291fa8a 100644
80041 --- a/init/main.c
80042 +++ b/init/main.c
80043 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
80044 extern void tc_init(void);
80045 #endif
80046
80047 +extern void grsecurity_init(void);
80048 +
80049 /*
80050 * Debug helper: via this flag we know that we are in 'early bootup code'
80051 * where only the boot processor is running with IRQ disabled. This means
80052 @@ -156,6 +158,74 @@ static int __init set_reset_devices(char *str)
80053
80054 __setup("reset_devices", set_reset_devices);
80055
80056 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80057 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
80058 +static int __init setup_grsec_proc_gid(char *str)
80059 +{
80060 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
80061 + return 1;
80062 +}
80063 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
80064 +#endif
80065 +
80066 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
80067 +unsigned long pax_user_shadow_base __read_only;
80068 +EXPORT_SYMBOL(pax_user_shadow_base);
80069 +extern char pax_enter_kernel_user[];
80070 +extern char pax_exit_kernel_user[];
80071 +#endif
80072 +
80073 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
80074 +static int __init setup_pax_nouderef(char *str)
80075 +{
80076 +#ifdef CONFIG_X86_32
80077 + unsigned int cpu;
80078 + struct desc_struct *gdt;
80079 +
80080 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
80081 + gdt = get_cpu_gdt_table(cpu);
80082 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
80083 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
80084 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
80085 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
80086 + }
80087 + loadsegment(ds, __KERNEL_DS);
80088 + loadsegment(es, __KERNEL_DS);
80089 + loadsegment(ss, __KERNEL_DS);
80090 +#else
80091 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
80092 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
80093 + clone_pgd_mask = ~(pgdval_t)0UL;
80094 + pax_user_shadow_base = 0UL;
80095 + setup_clear_cpu_cap(X86_FEATURE_PCID);
80096 +#endif
80097 +
80098 + return 0;
80099 +}
80100 +early_param("pax_nouderef", setup_pax_nouderef);
80101 +
80102 +#ifdef CONFIG_X86_64
80103 +static int __init setup_pax_weakuderef(char *str)
80104 +{
80105 + if (clone_pgd_mask != ~(pgdval_t)0UL)
80106 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
80107 + return 1;
80108 +}
80109 +__setup("pax_weakuderef", setup_pax_weakuderef);
80110 +#endif
80111 +#endif
80112 +
80113 +#ifdef CONFIG_PAX_SOFTMODE
80114 +int pax_softmode;
80115 +
80116 +static int __init setup_pax_softmode(char *str)
80117 +{
80118 + get_option(&str, &pax_softmode);
80119 + return 1;
80120 +}
80121 +__setup("pax_softmode=", setup_pax_softmode);
80122 +#endif
80123 +
80124 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
80125 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
80126 static const char *panic_later, *panic_param;
80127 @@ -682,25 +752,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
80128 {
80129 int count = preempt_count();
80130 int ret;
80131 - char msgbuf[64];
80132 + const char *msg1 = "", *msg2 = "";
80133
80134 if (initcall_debug)
80135 ret = do_one_initcall_debug(fn);
80136 else
80137 ret = fn();
80138
80139 - msgbuf[0] = 0;
80140 -
80141 if (preempt_count() != count) {
80142 - sprintf(msgbuf, "preemption imbalance ");
80143 + msg1 = " preemption imbalance";
80144 preempt_count() = count;
80145 }
80146 if (irqs_disabled()) {
80147 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
80148 + msg2 = " disabled interrupts";
80149 local_irq_enable();
80150 }
80151 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
80152 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
80153
80154 + add_latent_entropy();
80155 return ret;
80156 }
80157
80158 @@ -807,10 +876,14 @@ static int run_init_process(const char *init_filename)
80159 {
80160 argv_init[0] = init_filename;
80161 return do_execve(init_filename,
80162 - (const char __user *const __user *)argv_init,
80163 - (const char __user *const __user *)envp_init);
80164 + (const char __user *const __force_user *)argv_init,
80165 + (const char __user *const __force_user *)envp_init);
80166 }
80167
80168 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80169 +extern int gr_init_ran;
80170 +#endif
80171 +
80172 static noinline void __init kernel_init_freeable(void);
80173
80174 static int __ref kernel_init(void *unused)
80175 @@ -831,6 +904,11 @@ static int __ref kernel_init(void *unused)
80176 pr_err("Failed to execute %s\n", ramdisk_execute_command);
80177 }
80178
80179 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80180 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
80181 + gr_init_ran = 1;
80182 +#endif
80183 +
80184 /*
80185 * We try each of these until one succeeds.
80186 *
80187 @@ -885,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
80188 do_basic_setup();
80189
80190 /* Open the /dev/console on the rootfs, this should never fail */
80191 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
80192 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
80193 pr_err("Warning: unable to open an initial console.\n");
80194
80195 (void) sys_dup(0);
80196 @@ -898,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
80197 if (!ramdisk_execute_command)
80198 ramdisk_execute_command = "/init";
80199
80200 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
80201 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
80202 ramdisk_execute_command = NULL;
80203 prepare_namespace();
80204 }
80205
80206 + grsecurity_init();
80207 +
80208 /*
80209 * Ok, we have completed the initial bootup, and
80210 * we're essentially up and running. Get rid of the
80211 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
80212 index b0e99de..09f385c 100644
80213 --- a/ipc/ipc_sysctl.c
80214 +++ b/ipc/ipc_sysctl.c
80215 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
80216 static int proc_ipc_dointvec(ctl_table *table, int write,
80217 void __user *buffer, size_t *lenp, loff_t *ppos)
80218 {
80219 - struct ctl_table ipc_table;
80220 + ctl_table_no_const ipc_table;
80221
80222 memcpy(&ipc_table, table, sizeof(ipc_table));
80223 ipc_table.data = get_ipc(table);
80224 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
80225 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
80226 void __user *buffer, size_t *lenp, loff_t *ppos)
80227 {
80228 - struct ctl_table ipc_table;
80229 + ctl_table_no_const ipc_table;
80230
80231 memcpy(&ipc_table, table, sizeof(ipc_table));
80232 ipc_table.data = get_ipc(table);
80233 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
80234 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80235 void __user *buffer, size_t *lenp, loff_t *ppos)
80236 {
80237 - struct ctl_table ipc_table;
80238 + ctl_table_no_const ipc_table;
80239 size_t lenp_bef = *lenp;
80240 int rc;
80241
80242 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80243 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
80244 void __user *buffer, size_t *lenp, loff_t *ppos)
80245 {
80246 - struct ctl_table ipc_table;
80247 + ctl_table_no_const ipc_table;
80248 memcpy(&ipc_table, table, sizeof(ipc_table));
80249 ipc_table.data = get_ipc(table);
80250
80251 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
80252 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
80253 void __user *buffer, size_t *lenp, loff_t *ppos)
80254 {
80255 - struct ctl_table ipc_table;
80256 + ctl_table_no_const ipc_table;
80257 size_t lenp_bef = *lenp;
80258 int oldval;
80259 int rc;
80260 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
80261 index 383d638..943fdbb 100644
80262 --- a/ipc/mq_sysctl.c
80263 +++ b/ipc/mq_sysctl.c
80264 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
80265 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
80266 void __user *buffer, size_t *lenp, loff_t *ppos)
80267 {
80268 - struct ctl_table mq_table;
80269 + ctl_table_no_const mq_table;
80270 memcpy(&mq_table, table, sizeof(mq_table));
80271 mq_table.data = get_mq(table);
80272
80273 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
80274 index ae1996d..a35f2cc 100644
80275 --- a/ipc/mqueue.c
80276 +++ b/ipc/mqueue.c
80277 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
80278 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
80279 info->attr.mq_msgsize);
80280
80281 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
80282 spin_lock(&mq_lock);
80283 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
80284 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
80285 diff --git a/ipc/msg.c b/ipc/msg.c
80286 index 558aa91..359e718 100644
80287 --- a/ipc/msg.c
80288 +++ b/ipc/msg.c
80289 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
80290 return security_msg_queue_associate(msq, msgflg);
80291 }
80292
80293 +static struct ipc_ops msg_ops = {
80294 + .getnew = newque,
80295 + .associate = msg_security,
80296 + .more_checks = NULL
80297 +};
80298 +
80299 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
80300 {
80301 struct ipc_namespace *ns;
80302 - struct ipc_ops msg_ops;
80303 struct ipc_params msg_params;
80304
80305 ns = current->nsproxy->ipc_ns;
80306
80307 - msg_ops.getnew = newque;
80308 - msg_ops.associate = msg_security;
80309 - msg_ops.more_checks = NULL;
80310 -
80311 msg_params.key = key;
80312 msg_params.flg = msgflg;
80313
80314 diff --git a/ipc/sem.c b/ipc/sem.c
80315 index db9d241..bc8427c 100644
80316 --- a/ipc/sem.c
80317 +++ b/ipc/sem.c
80318 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
80319 return 0;
80320 }
80321
80322 +static struct ipc_ops sem_ops = {
80323 + .getnew = newary,
80324 + .associate = sem_security,
80325 + .more_checks = sem_more_checks
80326 +};
80327 +
80328 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80329 {
80330 struct ipc_namespace *ns;
80331 - struct ipc_ops sem_ops;
80332 struct ipc_params sem_params;
80333
80334 ns = current->nsproxy->ipc_ns;
80335 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80336 if (nsems < 0 || nsems > ns->sc_semmsl)
80337 return -EINVAL;
80338
80339 - sem_ops.getnew = newary;
80340 - sem_ops.associate = sem_security;
80341 - sem_ops.more_checks = sem_more_checks;
80342 -
80343 sem_params.key = key;
80344 sem_params.flg = semflg;
80345 sem_params.u.nsems = nsems;
80346 diff --git a/ipc/shm.c b/ipc/shm.c
80347 index d697396..5aadb3f 100644
80348 --- a/ipc/shm.c
80349 +++ b/ipc/shm.c
80350 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
80351 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
80352 #endif
80353
80354 +#ifdef CONFIG_GRKERNSEC
80355 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80356 + const time_t shm_createtime, const kuid_t cuid,
80357 + const int shmid);
80358 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80359 + const time_t shm_createtime);
80360 +#endif
80361 +
80362 void shm_init_ns(struct ipc_namespace *ns)
80363 {
80364 ns->shm_ctlmax = SHMMAX;
80365 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
80366 shp->shm_lprid = 0;
80367 shp->shm_atim = shp->shm_dtim = 0;
80368 shp->shm_ctim = get_seconds();
80369 +#ifdef CONFIG_GRKERNSEC
80370 + {
80371 + struct timespec timeval;
80372 + do_posix_clock_monotonic_gettime(&timeval);
80373 +
80374 + shp->shm_createtime = timeval.tv_sec;
80375 + }
80376 +#endif
80377 shp->shm_segsz = size;
80378 shp->shm_nattch = 0;
80379 shp->shm_file = file;
80380 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
80381 return 0;
80382 }
80383
80384 +static struct ipc_ops shm_ops = {
80385 + .getnew = newseg,
80386 + .associate = shm_security,
80387 + .more_checks = shm_more_checks
80388 +};
80389 +
80390 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
80391 {
80392 struct ipc_namespace *ns;
80393 - struct ipc_ops shm_ops;
80394 struct ipc_params shm_params;
80395
80396 ns = current->nsproxy->ipc_ns;
80397
80398 - shm_ops.getnew = newseg;
80399 - shm_ops.associate = shm_security;
80400 - shm_ops.more_checks = shm_more_checks;
80401 -
80402 shm_params.key = key;
80403 shm_params.flg = shmflg;
80404 shm_params.u.size = size;
80405 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80406 f_mode = FMODE_READ | FMODE_WRITE;
80407 }
80408 if (shmflg & SHM_EXEC) {
80409 +
80410 +#ifdef CONFIG_PAX_MPROTECT
80411 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
80412 + goto out;
80413 +#endif
80414 +
80415 prot |= PROT_EXEC;
80416 acc_mode |= S_IXUGO;
80417 }
80418 @@ -1100,10 +1123,23 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80419 if (err)
80420 goto out_unlock;
80421
80422 +#ifdef CONFIG_GRKERNSEC
80423 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
80424 + shp->shm_perm.cuid, shmid) ||
80425 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
80426 + err = -EACCES;
80427 + goto out_unlock;
80428 + }
80429 +#endif
80430 +
80431 ipc_lock_object(&shp->shm_perm);
80432 +
80433 path = shp->shm_file->f_path;
80434 path_get(&path);
80435 shp->shm_nattch++;
80436 +#ifdef CONFIG_GRKERNSEC
80437 + shp->shm_lapid = current->pid;
80438 +#endif
80439 size = i_size_read(path.dentry->d_inode);
80440 ipc_unlock_object(&shp->shm_perm);
80441 rcu_read_unlock();
80442 diff --git a/ipc/util.c b/ipc/util.c
80443 index 7684f41..f7da711 100644
80444 --- a/ipc/util.c
80445 +++ b/ipc/util.c
80446 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
80447 int (*show)(struct seq_file *, void *);
80448 };
80449
80450 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
80451 +
80452 static void ipc_memory_notifier(struct work_struct *work)
80453 {
80454 ipcns_notify(IPCNS_MEMCHANGED);
80455 @@ -560,6 +562,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
80456 granted_mode >>= 6;
80457 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
80458 granted_mode >>= 3;
80459 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
80460 + return -1;
80461 +
80462 /* is there some bit set in requested_mode but not in granted_mode? */
80463 if ((requested_mode & ~granted_mode & 0007) &&
80464 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
80465 diff --git a/kernel/acct.c b/kernel/acct.c
80466 index 8d6e145..33e0b1e 100644
80467 --- a/kernel/acct.c
80468 +++ b/kernel/acct.c
80469 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
80470 */
80471 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
80472 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
80473 - file->f_op->write(file, (char *)&ac,
80474 + file->f_op->write(file, (char __force_user *)&ac,
80475 sizeof(acct_t), &file->f_pos);
80476 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
80477 set_fs(fs);
80478 diff --git a/kernel/audit.c b/kernel/audit.c
80479 index 7b0e23a..f4d172f 100644
80480 --- a/kernel/audit.c
80481 +++ b/kernel/audit.c
80482 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
80483 3) suppressed due to audit_rate_limit
80484 4) suppressed due to audit_backlog_limit
80485 */
80486 -static atomic_t audit_lost = ATOMIC_INIT(0);
80487 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
80488
80489 /* The netlink socket. */
80490 static struct sock *audit_sock;
80491 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
80492 unsigned long now;
80493 int print;
80494
80495 - atomic_inc(&audit_lost);
80496 + atomic_inc_unchecked(&audit_lost);
80497
80498 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
80499
80500 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
80501 printk(KERN_WARNING
80502 "audit: audit_lost=%d audit_rate_limit=%d "
80503 "audit_backlog_limit=%d\n",
80504 - atomic_read(&audit_lost),
80505 + atomic_read_unchecked(&audit_lost),
80506 audit_rate_limit,
80507 audit_backlog_limit);
80508 audit_panic(message);
80509 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80510
80511 switch (msg_type) {
80512 case AUDIT_GET:
80513 + status_set.mask = 0;
80514 status_set.enabled = audit_enabled;
80515 status_set.failure = audit_failure;
80516 status_set.pid = audit_pid;
80517 status_set.rate_limit = audit_rate_limit;
80518 status_set.backlog_limit = audit_backlog_limit;
80519 - status_set.lost = atomic_read(&audit_lost);
80520 + status_set.lost = atomic_read_unchecked(&audit_lost);
80521 status_set.backlog = skb_queue_len(&audit_skb_queue);
80522 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
80523 &status_set, sizeof(status_set));
80524 break;
80525 case AUDIT_SET:
80526 - if (nlh->nlmsg_len < sizeof(struct audit_status))
80527 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
80528 return -EINVAL;
80529 status_get = (struct audit_status *)data;
80530 if (status_get->mask & AUDIT_STATUS_ENABLED) {
80531 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80532
80533 memset(&s, 0, sizeof(s));
80534 /* guard against past and future API changes */
80535 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
80536 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
80537 if ((s.enabled != 0 && s.enabled != 1) ||
80538 (s.log_passwd != 0 && s.log_passwd != 1))
80539 return -EINVAL;
80540 @@ -1251,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
80541 int i, avail, new_len;
80542 unsigned char *ptr;
80543 struct sk_buff *skb;
80544 - static const unsigned char *hex = "0123456789ABCDEF";
80545 + static const unsigned char hex[] = "0123456789ABCDEF";
80546
80547 if (!ab)
80548 return;
80549 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
80550 index 9845cb3..3ec9369 100644
80551 --- a/kernel/auditsc.c
80552 +++ b/kernel/auditsc.c
80553 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
80554 }
80555
80556 /* global counter which is incremented every time something logs in */
80557 -static atomic_t session_id = ATOMIC_INIT(0);
80558 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
80559
80560 /**
80561 * audit_set_loginuid - set current task's audit_context loginuid
80562 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
80563 return -EPERM;
80564 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
80565
80566 - sessionid = atomic_inc_return(&session_id);
80567 + sessionid = atomic_inc_return_unchecked(&session_id);
80568 if (context && context->in_syscall) {
80569 struct audit_buffer *ab;
80570
80571 diff --git a/kernel/capability.c b/kernel/capability.c
80572 index 4e66bf9..cdccecf 100644
80573 --- a/kernel/capability.c
80574 +++ b/kernel/capability.c
80575 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
80576 * before modification is attempted and the application
80577 * fails.
80578 */
80579 + if (tocopy > ARRAY_SIZE(kdata))
80580 + return -EFAULT;
80581 +
80582 if (copy_to_user(dataptr, kdata, tocopy
80583 * sizeof(struct __user_cap_data_struct))) {
80584 return -EFAULT;
80585 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
80586 int ret;
80587
80588 rcu_read_lock();
80589 - ret = security_capable(__task_cred(t), ns, cap);
80590 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
80591 + gr_task_is_capable(t, __task_cred(t), cap);
80592 rcu_read_unlock();
80593
80594 - return (ret == 0);
80595 + return ret;
80596 }
80597
80598 /**
80599 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
80600 int ret;
80601
80602 rcu_read_lock();
80603 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
80604 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
80605 rcu_read_unlock();
80606
80607 - return (ret == 0);
80608 + return ret;
80609 }
80610
80611 /**
80612 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
80613 BUG();
80614 }
80615
80616 - if (security_capable(current_cred(), ns, cap) == 0) {
80617 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
80618 current->flags |= PF_SUPERPRIV;
80619 return true;
80620 }
80621 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
80622 }
80623 EXPORT_SYMBOL(ns_capable);
80624
80625 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
80626 +{
80627 + if (unlikely(!cap_valid(cap))) {
80628 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
80629 + BUG();
80630 + }
80631 +
80632 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
80633 + current->flags |= PF_SUPERPRIV;
80634 + return true;
80635 + }
80636 + return false;
80637 +}
80638 +EXPORT_SYMBOL(ns_capable_nolog);
80639 +
80640 /**
80641 * file_ns_capable - Determine if the file's opener had a capability in effect
80642 * @file: The file we want to check
80643 @@ -432,6 +451,12 @@ bool capable(int cap)
80644 }
80645 EXPORT_SYMBOL(capable);
80646
80647 +bool capable_nolog(int cap)
80648 +{
80649 + return ns_capable_nolog(&init_user_ns, cap);
80650 +}
80651 +EXPORT_SYMBOL(capable_nolog);
80652 +
80653 /**
80654 * inode_capable - Check superior capability over inode
80655 * @inode: The inode in question
80656 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
80657 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80658 }
80659 EXPORT_SYMBOL(inode_capable);
80660 +
80661 +bool inode_capable_nolog(const struct inode *inode, int cap)
80662 +{
80663 + struct user_namespace *ns = current_user_ns();
80664 +
80665 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80666 +}
80667 +EXPORT_SYMBOL(inode_capable_nolog);
80668 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
80669 index 8bd9cfd..9faf120 100644
80670 --- a/kernel/cgroup.c
80671 +++ b/kernel/cgroup.c
80672 @@ -5817,7 +5817,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
80673 struct css_set *cset = link->cset;
80674 struct task_struct *task;
80675 int count = 0;
80676 - seq_printf(seq, "css_set %p\n", cset);
80677 + seq_printf(seq, "css_set %pK\n", cset);
80678 list_for_each_entry(task, &cset->tasks, cg_list) {
80679 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
80680 seq_puts(seq, " ...\n");
80681 diff --git a/kernel/compat.c b/kernel/compat.c
80682 index 0a09e48..f44f3f0 100644
80683 --- a/kernel/compat.c
80684 +++ b/kernel/compat.c
80685 @@ -13,6 +13,7 @@
80686
80687 #include <linux/linkage.h>
80688 #include <linux/compat.h>
80689 +#include <linux/module.h>
80690 #include <linux/errno.h>
80691 #include <linux/time.h>
80692 #include <linux/signal.h>
80693 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
80694 mm_segment_t oldfs;
80695 long ret;
80696
80697 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
80698 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
80699 oldfs = get_fs();
80700 set_fs(KERNEL_DS);
80701 ret = hrtimer_nanosleep_restart(restart);
80702 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
80703 oldfs = get_fs();
80704 set_fs(KERNEL_DS);
80705 ret = hrtimer_nanosleep(&tu,
80706 - rmtp ? (struct timespec __user *)&rmt : NULL,
80707 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
80708 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
80709 set_fs(oldfs);
80710
80711 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
80712 mm_segment_t old_fs = get_fs();
80713
80714 set_fs(KERNEL_DS);
80715 - ret = sys_sigpending((old_sigset_t __user *) &s);
80716 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
80717 set_fs(old_fs);
80718 if (ret == 0)
80719 ret = put_user(s, set);
80720 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
80721 mm_segment_t old_fs = get_fs();
80722
80723 set_fs(KERNEL_DS);
80724 - ret = sys_old_getrlimit(resource, &r);
80725 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
80726 set_fs(old_fs);
80727
80728 if (!ret) {
80729 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
80730 set_fs (KERNEL_DS);
80731 ret = sys_wait4(pid,
80732 (stat_addr ?
80733 - (unsigned int __user *) &status : NULL),
80734 - options, (struct rusage __user *) &r);
80735 + (unsigned int __force_user *) &status : NULL),
80736 + options, (struct rusage __force_user *) &r);
80737 set_fs (old_fs);
80738
80739 if (ret > 0) {
80740 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
80741 memset(&info, 0, sizeof(info));
80742
80743 set_fs(KERNEL_DS);
80744 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
80745 - uru ? (struct rusage __user *)&ru : NULL);
80746 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
80747 + uru ? (struct rusage __force_user *)&ru : NULL);
80748 set_fs(old_fs);
80749
80750 if ((ret < 0) || (info.si_signo == 0))
80751 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
80752 oldfs = get_fs();
80753 set_fs(KERNEL_DS);
80754 err = sys_timer_settime(timer_id, flags,
80755 - (struct itimerspec __user *) &newts,
80756 - (struct itimerspec __user *) &oldts);
80757 + (struct itimerspec __force_user *) &newts,
80758 + (struct itimerspec __force_user *) &oldts);
80759 set_fs(oldfs);
80760 if (!err && old && put_compat_itimerspec(old, &oldts))
80761 return -EFAULT;
80762 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
80763 oldfs = get_fs();
80764 set_fs(KERNEL_DS);
80765 err = sys_timer_gettime(timer_id,
80766 - (struct itimerspec __user *) &ts);
80767 + (struct itimerspec __force_user *) &ts);
80768 set_fs(oldfs);
80769 if (!err && put_compat_itimerspec(setting, &ts))
80770 return -EFAULT;
80771 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
80772 oldfs = get_fs();
80773 set_fs(KERNEL_DS);
80774 err = sys_clock_settime(which_clock,
80775 - (struct timespec __user *) &ts);
80776 + (struct timespec __force_user *) &ts);
80777 set_fs(oldfs);
80778 return err;
80779 }
80780 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
80781 oldfs = get_fs();
80782 set_fs(KERNEL_DS);
80783 err = sys_clock_gettime(which_clock,
80784 - (struct timespec __user *) &ts);
80785 + (struct timespec __force_user *) &ts);
80786 set_fs(oldfs);
80787 if (!err && put_compat_timespec(&ts, tp))
80788 return -EFAULT;
80789 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
80790
80791 oldfs = get_fs();
80792 set_fs(KERNEL_DS);
80793 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
80794 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
80795 set_fs(oldfs);
80796
80797 err = compat_put_timex(utp, &txc);
80798 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
80799 oldfs = get_fs();
80800 set_fs(KERNEL_DS);
80801 err = sys_clock_getres(which_clock,
80802 - (struct timespec __user *) &ts);
80803 + (struct timespec __force_user *) &ts);
80804 set_fs(oldfs);
80805 if (!err && tp && put_compat_timespec(&ts, tp))
80806 return -EFAULT;
80807 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
80808 long err;
80809 mm_segment_t oldfs;
80810 struct timespec tu;
80811 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
80812 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
80813
80814 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
80815 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
80816 oldfs = get_fs();
80817 set_fs(KERNEL_DS);
80818 err = clock_nanosleep_restart(restart);
80819 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
80820 oldfs = get_fs();
80821 set_fs(KERNEL_DS);
80822 err = sys_clock_nanosleep(which_clock, flags,
80823 - (struct timespec __user *) &in,
80824 - (struct timespec __user *) &out);
80825 + (struct timespec __force_user *) &in,
80826 + (struct timespec __force_user *) &out);
80827 set_fs(oldfs);
80828
80829 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
80830 diff --git a/kernel/configs.c b/kernel/configs.c
80831 index c18b1f1..b9a0132 100644
80832 --- a/kernel/configs.c
80833 +++ b/kernel/configs.c
80834 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
80835 struct proc_dir_entry *entry;
80836
80837 /* create the current config file */
80838 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
80839 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
80840 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
80841 + &ikconfig_file_ops);
80842 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80843 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
80844 + &ikconfig_file_ops);
80845 +#endif
80846 +#else
80847 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
80848 &ikconfig_file_ops);
80849 +#endif
80850 +
80851 if (!entry)
80852 return -ENOMEM;
80853
80854 diff --git a/kernel/cred.c b/kernel/cred.c
80855 index e0573a4..3874e41 100644
80856 --- a/kernel/cred.c
80857 +++ b/kernel/cred.c
80858 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
80859 validate_creds(cred);
80860 alter_cred_subscribers(cred, -1);
80861 put_cred(cred);
80862 +
80863 +#ifdef CONFIG_GRKERNSEC_SETXID
80864 + cred = (struct cred *) tsk->delayed_cred;
80865 + if (cred != NULL) {
80866 + tsk->delayed_cred = NULL;
80867 + validate_creds(cred);
80868 + alter_cred_subscribers(cred, -1);
80869 + put_cred(cred);
80870 + }
80871 +#endif
80872 }
80873
80874 /**
80875 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
80876 * Always returns 0 thus allowing this function to be tail-called at the end
80877 * of, say, sys_setgid().
80878 */
80879 -int commit_creds(struct cred *new)
80880 +static int __commit_creds(struct cred *new)
80881 {
80882 struct task_struct *task = current;
80883 const struct cred *old = task->real_cred;
80884 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
80885
80886 get_cred(new); /* we will require a ref for the subj creds too */
80887
80888 + gr_set_role_label(task, new->uid, new->gid);
80889 +
80890 /* dumpability changes */
80891 if (!uid_eq(old->euid, new->euid) ||
80892 !gid_eq(old->egid, new->egid) ||
80893 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
80894 put_cred(old);
80895 return 0;
80896 }
80897 +#ifdef CONFIG_GRKERNSEC_SETXID
80898 +extern int set_user(struct cred *new);
80899 +
80900 +void gr_delayed_cred_worker(void)
80901 +{
80902 + const struct cred *new = current->delayed_cred;
80903 + struct cred *ncred;
80904 +
80905 + current->delayed_cred = NULL;
80906 +
80907 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
80908 + // from doing get_cred on it when queueing this
80909 + put_cred(new);
80910 + return;
80911 + } else if (new == NULL)
80912 + return;
80913 +
80914 + ncred = prepare_creds();
80915 + if (!ncred)
80916 + goto die;
80917 + // uids
80918 + ncred->uid = new->uid;
80919 + ncred->euid = new->euid;
80920 + ncred->suid = new->suid;
80921 + ncred->fsuid = new->fsuid;
80922 + // gids
80923 + ncred->gid = new->gid;
80924 + ncred->egid = new->egid;
80925 + ncred->sgid = new->sgid;
80926 + ncred->fsgid = new->fsgid;
80927 + // groups
80928 + if (set_groups(ncred, new->group_info) < 0) {
80929 + abort_creds(ncred);
80930 + goto die;
80931 + }
80932 + // caps
80933 + ncred->securebits = new->securebits;
80934 + ncred->cap_inheritable = new->cap_inheritable;
80935 + ncred->cap_permitted = new->cap_permitted;
80936 + ncred->cap_effective = new->cap_effective;
80937 + ncred->cap_bset = new->cap_bset;
80938 +
80939 + if (set_user(ncred)) {
80940 + abort_creds(ncred);
80941 + goto die;
80942 + }
80943 +
80944 + // from doing get_cred on it when queueing this
80945 + put_cred(new);
80946 +
80947 + __commit_creds(ncred);
80948 + return;
80949 +die:
80950 + // from doing get_cred on it when queueing this
80951 + put_cred(new);
80952 + do_group_exit(SIGKILL);
80953 +}
80954 +#endif
80955 +
80956 +int commit_creds(struct cred *new)
80957 +{
80958 +#ifdef CONFIG_GRKERNSEC_SETXID
80959 + int ret;
80960 + int schedule_it = 0;
80961 + struct task_struct *t;
80962 +
80963 + /* we won't get called with tasklist_lock held for writing
80964 + and interrupts disabled as the cred struct in that case is
80965 + init_cred
80966 + */
80967 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80968 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80969 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80970 + schedule_it = 1;
80971 + }
80972 + ret = __commit_creds(new);
80973 + if (schedule_it) {
80974 + rcu_read_lock();
80975 + read_lock(&tasklist_lock);
80976 + for (t = next_thread(current); t != current;
80977 + t = next_thread(t)) {
80978 + if (t->delayed_cred == NULL) {
80979 + t->delayed_cred = get_cred(new);
80980 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80981 + set_tsk_need_resched(t);
80982 + }
80983 + }
80984 + read_unlock(&tasklist_lock);
80985 + rcu_read_unlock();
80986 + }
80987 + return ret;
80988 +#else
80989 + return __commit_creds(new);
80990 +#endif
80991 +}
80992 +
80993 EXPORT_SYMBOL(commit_creds);
80994
80995 /**
80996 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80997 index 0506d44..2c20034 100644
80998 --- a/kernel/debug/debug_core.c
80999 +++ b/kernel/debug/debug_core.c
81000 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
81001 */
81002 static atomic_t masters_in_kgdb;
81003 static atomic_t slaves_in_kgdb;
81004 -static atomic_t kgdb_break_tasklet_var;
81005 +static atomic_unchecked_t kgdb_break_tasklet_var;
81006 atomic_t kgdb_setting_breakpoint;
81007
81008 struct task_struct *kgdb_usethread;
81009 @@ -133,7 +133,7 @@ int kgdb_single_step;
81010 static pid_t kgdb_sstep_pid;
81011
81012 /* to keep track of the CPU which is doing the single stepping*/
81013 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81014 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81015
81016 /*
81017 * If you are debugging a problem where roundup (the collection of
81018 @@ -541,7 +541,7 @@ return_normal:
81019 * kernel will only try for the value of sstep_tries before
81020 * giving up and continuing on.
81021 */
81022 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
81023 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
81024 (kgdb_info[cpu].task &&
81025 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
81026 atomic_set(&kgdb_active, -1);
81027 @@ -635,8 +635,8 @@ cpu_master_loop:
81028 }
81029
81030 kgdb_restore:
81031 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
81032 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
81033 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
81034 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
81035 if (kgdb_info[sstep_cpu].task)
81036 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
81037 else
81038 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
81039 static void kgdb_tasklet_bpt(unsigned long ing)
81040 {
81041 kgdb_breakpoint();
81042 - atomic_set(&kgdb_break_tasklet_var, 0);
81043 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
81044 }
81045
81046 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
81047
81048 void kgdb_schedule_breakpoint(void)
81049 {
81050 - if (atomic_read(&kgdb_break_tasklet_var) ||
81051 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
81052 atomic_read(&kgdb_active) != -1 ||
81053 atomic_read(&kgdb_setting_breakpoint))
81054 return;
81055 - atomic_inc(&kgdb_break_tasklet_var);
81056 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
81057 tasklet_schedule(&kgdb_tasklet_breakpoint);
81058 }
81059 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
81060 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
81061 index 00eb8f7..d7e3244 100644
81062 --- a/kernel/debug/kdb/kdb_main.c
81063 +++ b/kernel/debug/kdb/kdb_main.c
81064 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
81065 continue;
81066
81067 kdb_printf("%-20s%8u 0x%p ", mod->name,
81068 - mod->core_size, (void *)mod);
81069 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
81070 #ifdef CONFIG_MODULE_UNLOAD
81071 kdb_printf("%4ld ", module_refcount(mod));
81072 #endif
81073 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
81074 kdb_printf(" (Loading)");
81075 else
81076 kdb_printf(" (Live)");
81077 - kdb_printf(" 0x%p", mod->module_core);
81078 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
81079
81080 #ifdef CONFIG_MODULE_UNLOAD
81081 {
81082 diff --git a/kernel/events/core.c b/kernel/events/core.c
81083 index 953c143..5646bb1 100644
81084 --- a/kernel/events/core.c
81085 +++ b/kernel/events/core.c
81086 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
81087 * 0 - disallow raw tracepoint access for unpriv
81088 * 1 - disallow cpu events for unpriv
81089 * 2 - disallow kernel profiling for unpriv
81090 + * 3 - disallow all unpriv perf event use
81091 */
81092 -int sysctl_perf_event_paranoid __read_mostly = 1;
81093 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81094 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
81095 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
81096 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
81097 +#else
81098 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
81099 +#endif
81100
81101 /* Minimum for 512 kiB + 1 user control page */
81102 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
81103 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
81104 update_perf_cpu_limits();
81105 }
81106
81107 -static atomic64_t perf_event_id;
81108 +static atomic64_unchecked_t perf_event_id;
81109
81110 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
81111 enum event_type_t event_type);
81112 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
81113
81114 static inline u64 perf_event_count(struct perf_event *event)
81115 {
81116 - return local64_read(&event->count) + atomic64_read(&event->child_count);
81117 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
81118 }
81119
81120 static u64 perf_event_read(struct perf_event *event)
81121 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
81122 mutex_lock(&event->child_mutex);
81123 total += perf_event_read(event);
81124 *enabled += event->total_time_enabled +
81125 - atomic64_read(&event->child_total_time_enabled);
81126 + atomic64_read_unchecked(&event->child_total_time_enabled);
81127 *running += event->total_time_running +
81128 - atomic64_read(&event->child_total_time_running);
81129 + atomic64_read_unchecked(&event->child_total_time_running);
81130
81131 list_for_each_entry(child, &event->child_list, child_list) {
81132 total += perf_event_read(child);
81133 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
81134 userpg->offset -= local64_read(&event->hw.prev_count);
81135
81136 userpg->time_enabled = enabled +
81137 - atomic64_read(&event->child_total_time_enabled);
81138 + atomic64_read_unchecked(&event->child_total_time_enabled);
81139
81140 userpg->time_running = running +
81141 - atomic64_read(&event->child_total_time_running);
81142 + atomic64_read_unchecked(&event->child_total_time_running);
81143
81144 arch_perf_update_userpage(userpg, now);
81145
81146 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
81147
81148 /* Data. */
81149 sp = perf_user_stack_pointer(regs);
81150 - rem = __output_copy_user(handle, (void *) sp, dump_size);
81151 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
81152 dyn_size = dump_size - rem;
81153
81154 perf_output_skip(handle, rem);
81155 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
81156 values[n++] = perf_event_count(event);
81157 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
81158 values[n++] = enabled +
81159 - atomic64_read(&event->child_total_time_enabled);
81160 + atomic64_read_unchecked(&event->child_total_time_enabled);
81161 }
81162 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
81163 values[n++] = running +
81164 - atomic64_read(&event->child_total_time_running);
81165 + atomic64_read_unchecked(&event->child_total_time_running);
81166 }
81167 if (read_format & PERF_FORMAT_ID)
81168 values[n++] = primary_event_id(event);
81169 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
81170 * need to add enough zero bytes after the string to handle
81171 * the 64bit alignment we do later.
81172 */
81173 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
81174 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
81175 if (!buf) {
81176 name = strncpy(tmp, "//enomem", sizeof(tmp));
81177 goto got_name;
81178 }
81179 - name = d_path(&file->f_path, buf, PATH_MAX);
81180 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
81181 if (IS_ERR(name)) {
81182 name = strncpy(tmp, "//toolong", sizeof(tmp));
81183 goto got_name;
81184 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
81185 event->parent = parent_event;
81186
81187 event->ns = get_pid_ns(task_active_pid_ns(current));
81188 - event->id = atomic64_inc_return(&perf_event_id);
81189 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
81190
81191 event->state = PERF_EVENT_STATE_INACTIVE;
81192
81193 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
81194 if (flags & ~PERF_FLAG_ALL)
81195 return -EINVAL;
81196
81197 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81198 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
81199 + return -EACCES;
81200 +#endif
81201 +
81202 err = perf_copy_attr(attr_uptr, &attr);
81203 if (err)
81204 return err;
81205 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
81206 /*
81207 * Add back the child's count to the parent's count:
81208 */
81209 - atomic64_add(child_val, &parent_event->child_count);
81210 - atomic64_add(child_event->total_time_enabled,
81211 + atomic64_add_unchecked(child_val, &parent_event->child_count);
81212 + atomic64_add_unchecked(child_event->total_time_enabled,
81213 &parent_event->child_total_time_enabled);
81214 - atomic64_add(child_event->total_time_running,
81215 + atomic64_add_unchecked(child_event->total_time_running,
81216 &parent_event->child_total_time_running);
81217
81218 /*
81219 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
81220 index ca65997..60df03d 100644
81221 --- a/kernel/events/internal.h
81222 +++ b/kernel/events/internal.h
81223 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
81224 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
81225 }
81226
81227 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
81228 -static inline unsigned int \
81229 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
81230 +static inline unsigned long \
81231 func_name(struct perf_output_handle *handle, \
81232 - const void *buf, unsigned int len) \
81233 + const void user *buf, unsigned long len) \
81234 { \
81235 unsigned long size, written; \
81236 \
81237 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
81238 return n;
81239 }
81240
81241 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
81242 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
81243
81244 #define MEMCPY_SKIP(dst, src, n) (n)
81245
81246 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
81247 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
81248
81249 #ifndef arch_perf_out_copy_user
81250 #define arch_perf_out_copy_user __copy_from_user_inatomic
81251 #endif
81252
81253 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
81254 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
81255
81256 /* Callchain handling */
81257 extern struct perf_callchain_entry *
81258 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
81259 index ad8e1bd..fed7ba9 100644
81260 --- a/kernel/events/uprobes.c
81261 +++ b/kernel/events/uprobes.c
81262 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
81263 {
81264 struct page *page;
81265 uprobe_opcode_t opcode;
81266 - int result;
81267 + long result;
81268
81269 pagefault_disable();
81270 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
81271 diff --git a/kernel/exit.c b/kernel/exit.c
81272 index a949819..a5f127d 100644
81273 --- a/kernel/exit.c
81274 +++ b/kernel/exit.c
81275 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
81276 struct task_struct *leader;
81277 int zap_leader;
81278 repeat:
81279 +#ifdef CONFIG_NET
81280 + gr_del_task_from_ip_table(p);
81281 +#endif
81282 +
81283 /* don't need to get the RCU readlock here - the process is dead and
81284 * can't be modifying its own credentials. But shut RCU-lockdep up */
81285 rcu_read_lock();
81286 @@ -329,7 +333,7 @@ int allow_signal(int sig)
81287 * know it'll be handled, so that they don't get converted to
81288 * SIGKILL or just silently dropped.
81289 */
81290 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
81291 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
81292 recalc_sigpending();
81293 spin_unlock_irq(&current->sighand->siglock);
81294 return 0;
81295 @@ -698,6 +702,8 @@ void do_exit(long code)
81296 struct task_struct *tsk = current;
81297 int group_dead;
81298
81299 + set_fs(USER_DS);
81300 +
81301 profile_task_exit(tsk);
81302
81303 WARN_ON(blk_needs_flush_plug(tsk));
81304 @@ -714,7 +720,6 @@ void do_exit(long code)
81305 * mm_release()->clear_child_tid() from writing to a user-controlled
81306 * kernel address.
81307 */
81308 - set_fs(USER_DS);
81309
81310 ptrace_event(PTRACE_EVENT_EXIT, code);
81311
81312 @@ -773,6 +778,9 @@ void do_exit(long code)
81313 tsk->exit_code = code;
81314 taskstats_exit(tsk, group_dead);
81315
81316 + gr_acl_handle_psacct(tsk, code);
81317 + gr_acl_handle_exit();
81318 +
81319 exit_mm(tsk);
81320
81321 if (group_dead)
81322 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
81323 * Take down every thread in the group. This is called by fatal signals
81324 * as well as by sys_exit_group (below).
81325 */
81326 -void
81327 +__noreturn void
81328 do_group_exit(int exit_code)
81329 {
81330 struct signal_struct *sig = current->signal;
81331 diff --git a/kernel/fork.c b/kernel/fork.c
81332 index 086fe73..72c1122 100644
81333 --- a/kernel/fork.c
81334 +++ b/kernel/fork.c
81335 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
81336 *stackend = STACK_END_MAGIC; /* for overflow detection */
81337
81338 #ifdef CONFIG_CC_STACKPROTECTOR
81339 - tsk->stack_canary = get_random_int();
81340 + tsk->stack_canary = pax_get_random_long();
81341 #endif
81342
81343 /*
81344 @@ -345,12 +345,80 @@ free_tsk:
81345 }
81346
81347 #ifdef CONFIG_MMU
81348 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81349 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
81350 +{
81351 + struct vm_area_struct *tmp;
81352 + unsigned long charge;
81353 + struct file *file;
81354 + int retval;
81355 +
81356 + charge = 0;
81357 + if (mpnt->vm_flags & VM_ACCOUNT) {
81358 + unsigned long len = vma_pages(mpnt);
81359 +
81360 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81361 + goto fail_nomem;
81362 + charge = len;
81363 + }
81364 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81365 + if (!tmp)
81366 + goto fail_nomem;
81367 + *tmp = *mpnt;
81368 + tmp->vm_mm = mm;
81369 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
81370 + retval = vma_dup_policy(mpnt, tmp);
81371 + if (retval)
81372 + goto fail_nomem_policy;
81373 + if (anon_vma_fork(tmp, mpnt))
81374 + goto fail_nomem_anon_vma_fork;
81375 + tmp->vm_flags &= ~VM_LOCKED;
81376 + tmp->vm_next = tmp->vm_prev = NULL;
81377 + tmp->vm_mirror = NULL;
81378 + file = tmp->vm_file;
81379 + if (file) {
81380 + struct inode *inode = file_inode(file);
81381 + struct address_space *mapping = file->f_mapping;
81382 +
81383 + get_file(file);
81384 + if (tmp->vm_flags & VM_DENYWRITE)
81385 + atomic_dec(&inode->i_writecount);
81386 + mutex_lock(&mapping->i_mmap_mutex);
81387 + if (tmp->vm_flags & VM_SHARED)
81388 + mapping->i_mmap_writable++;
81389 + flush_dcache_mmap_lock(mapping);
81390 + /* insert tmp into the share list, just after mpnt */
81391 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81392 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
81393 + else
81394 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
81395 + flush_dcache_mmap_unlock(mapping);
81396 + mutex_unlock(&mapping->i_mmap_mutex);
81397 + }
81398 +
81399 + /*
81400 + * Clear hugetlb-related page reserves for children. This only
81401 + * affects MAP_PRIVATE mappings. Faults generated by the child
81402 + * are not guaranteed to succeed, even if read-only
81403 + */
81404 + if (is_vm_hugetlb_page(tmp))
81405 + reset_vma_resv_huge_pages(tmp);
81406 +
81407 + return tmp;
81408 +
81409 +fail_nomem_anon_vma_fork:
81410 + mpol_put(vma_policy(tmp));
81411 +fail_nomem_policy:
81412 + kmem_cache_free(vm_area_cachep, tmp);
81413 +fail_nomem:
81414 + vm_unacct_memory(charge);
81415 + return NULL;
81416 +}
81417 +
81418 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81419 {
81420 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
81421 struct rb_node **rb_link, *rb_parent;
81422 int retval;
81423 - unsigned long charge;
81424
81425 uprobe_start_dup_mmap();
81426 down_write(&oldmm->mmap_sem);
81427 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81428
81429 prev = NULL;
81430 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
81431 - struct file *file;
81432 -
81433 if (mpnt->vm_flags & VM_DONTCOPY) {
81434 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
81435 -vma_pages(mpnt));
81436 continue;
81437 }
81438 - charge = 0;
81439 - if (mpnt->vm_flags & VM_ACCOUNT) {
81440 - unsigned long len = vma_pages(mpnt);
81441 -
81442 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81443 - goto fail_nomem;
81444 - charge = len;
81445 - }
81446 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81447 - if (!tmp)
81448 - goto fail_nomem;
81449 - *tmp = *mpnt;
81450 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
81451 - retval = vma_dup_policy(mpnt, tmp);
81452 - if (retval)
81453 - goto fail_nomem_policy;
81454 - tmp->vm_mm = mm;
81455 - if (anon_vma_fork(tmp, mpnt))
81456 - goto fail_nomem_anon_vma_fork;
81457 - tmp->vm_flags &= ~VM_LOCKED;
81458 - tmp->vm_next = tmp->vm_prev = NULL;
81459 - file = tmp->vm_file;
81460 - if (file) {
81461 - struct inode *inode = file_inode(file);
81462 - struct address_space *mapping = file->f_mapping;
81463 -
81464 - get_file(file);
81465 - if (tmp->vm_flags & VM_DENYWRITE)
81466 - atomic_dec(&inode->i_writecount);
81467 - mutex_lock(&mapping->i_mmap_mutex);
81468 - if (tmp->vm_flags & VM_SHARED)
81469 - mapping->i_mmap_writable++;
81470 - flush_dcache_mmap_lock(mapping);
81471 - /* insert tmp into the share list, just after mpnt */
81472 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81473 - vma_nonlinear_insert(tmp,
81474 - &mapping->i_mmap_nonlinear);
81475 - else
81476 - vma_interval_tree_insert_after(tmp, mpnt,
81477 - &mapping->i_mmap);
81478 - flush_dcache_mmap_unlock(mapping);
81479 - mutex_unlock(&mapping->i_mmap_mutex);
81480 + tmp = dup_vma(mm, oldmm, mpnt);
81481 + if (!tmp) {
81482 + retval = -ENOMEM;
81483 + goto out;
81484 }
81485
81486 /*
81487 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81488 if (retval)
81489 goto out;
81490 }
81491 +
81492 +#ifdef CONFIG_PAX_SEGMEXEC
81493 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
81494 + struct vm_area_struct *mpnt_m;
81495 +
81496 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
81497 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
81498 +
81499 + if (!mpnt->vm_mirror)
81500 + continue;
81501 +
81502 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
81503 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
81504 + mpnt->vm_mirror = mpnt_m;
81505 + } else {
81506 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
81507 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
81508 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
81509 + mpnt->vm_mirror->vm_mirror = mpnt;
81510 + }
81511 + }
81512 + BUG_ON(mpnt_m);
81513 + }
81514 +#endif
81515 +
81516 /* a new mm has just been created */
81517 arch_dup_mmap(oldmm, mm);
81518 retval = 0;
81519 @@ -468,14 +521,6 @@ out:
81520 up_write(&oldmm->mmap_sem);
81521 uprobe_end_dup_mmap();
81522 return retval;
81523 -fail_nomem_anon_vma_fork:
81524 - mpol_put(vma_policy(tmp));
81525 -fail_nomem_policy:
81526 - kmem_cache_free(vm_area_cachep, tmp);
81527 -fail_nomem:
81528 - retval = -ENOMEM;
81529 - vm_unacct_memory(charge);
81530 - goto out;
81531 }
81532
81533 static inline int mm_alloc_pgd(struct mm_struct *mm)
81534 @@ -688,8 +733,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
81535 return ERR_PTR(err);
81536
81537 mm = get_task_mm(task);
81538 - if (mm && mm != current->mm &&
81539 - !ptrace_may_access(task, mode)) {
81540 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
81541 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
81542 mmput(mm);
81543 mm = ERR_PTR(-EACCES);
81544 }
81545 @@ -911,13 +956,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
81546 spin_unlock(&fs->lock);
81547 return -EAGAIN;
81548 }
81549 - fs->users++;
81550 + atomic_inc(&fs->users);
81551 spin_unlock(&fs->lock);
81552 return 0;
81553 }
81554 tsk->fs = copy_fs_struct(fs);
81555 if (!tsk->fs)
81556 return -ENOMEM;
81557 + /* Carry through gr_chroot_dentry and is_chrooted instead
81558 + of recomputing it here. Already copied when the task struct
81559 + is duplicated. This allows pivot_root to not be treated as
81560 + a chroot
81561 + */
81562 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
81563 +
81564 return 0;
81565 }
81566
81567 @@ -1128,7 +1180,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
81568 * parts of the process environment (as per the clone
81569 * flags). The actual kick-off is left to the caller.
81570 */
81571 -static struct task_struct *copy_process(unsigned long clone_flags,
81572 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
81573 unsigned long stack_start,
81574 unsigned long stack_size,
81575 int __user *child_tidptr,
81576 @@ -1200,6 +1252,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81577 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
81578 #endif
81579 retval = -EAGAIN;
81580 +
81581 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
81582 +
81583 if (atomic_read(&p->real_cred->user->processes) >=
81584 task_rlimit(p, RLIMIT_NPROC)) {
81585 if (p->real_cred->user != INIT_USER &&
81586 @@ -1449,6 +1504,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81587 goto bad_fork_free_pid;
81588 }
81589
81590 + /* synchronizes with gr_set_acls()
81591 + we need to call this past the point of no return for fork()
81592 + */
81593 + gr_copy_label(p);
81594 +
81595 if (likely(p->pid)) {
81596 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
81597
81598 @@ -1534,6 +1594,8 @@ bad_fork_cleanup_count:
81599 bad_fork_free:
81600 free_task(p);
81601 fork_out:
81602 + gr_log_forkfail(retval);
81603 +
81604 return ERR_PTR(retval);
81605 }
81606
81607 @@ -1595,6 +1657,7 @@ long do_fork(unsigned long clone_flags,
81608
81609 p = copy_process(clone_flags, stack_start, stack_size,
81610 child_tidptr, NULL, trace);
81611 + add_latent_entropy();
81612 /*
81613 * Do this prior waking up the new thread - the thread pointer
81614 * might get invalid after that point, if the thread exits quickly.
81615 @@ -1609,6 +1672,8 @@ long do_fork(unsigned long clone_flags,
81616 if (clone_flags & CLONE_PARENT_SETTID)
81617 put_user(nr, parent_tidptr);
81618
81619 + gr_handle_brute_check();
81620 +
81621 if (clone_flags & CLONE_VFORK) {
81622 p->vfork_done = &vfork;
81623 init_completion(&vfork);
81624 @@ -1725,7 +1790,7 @@ void __init proc_caches_init(void)
81625 mm_cachep = kmem_cache_create("mm_struct",
81626 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
81627 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
81628 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
81629 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
81630 mmap_init();
81631 nsproxy_cache_init();
81632 }
81633 @@ -1765,7 +1830,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
81634 return 0;
81635
81636 /* don't need lock here; in the worst case we'll do useless copy */
81637 - if (fs->users == 1)
81638 + if (atomic_read(&fs->users) == 1)
81639 return 0;
81640
81641 *new_fsp = copy_fs_struct(fs);
81642 @@ -1872,7 +1937,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
81643 fs = current->fs;
81644 spin_lock(&fs->lock);
81645 current->fs = new_fs;
81646 - if (--fs->users)
81647 + gr_set_chroot_entries(current, &current->fs->root);
81648 + if (atomic_dec_return(&fs->users))
81649 new_fs = NULL;
81650 else
81651 new_fs = fs;
81652 diff --git a/kernel/futex.c b/kernel/futex.c
81653 index c3a1a55..e32b4a98 100644
81654 --- a/kernel/futex.c
81655 +++ b/kernel/futex.c
81656 @@ -54,6 +54,7 @@
81657 #include <linux/mount.h>
81658 #include <linux/pagemap.h>
81659 #include <linux/syscalls.h>
81660 +#include <linux/ptrace.h>
81661 #include <linux/signal.h>
81662 #include <linux/export.h>
81663 #include <linux/magic.h>
81664 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
81665 struct page *page, *page_head;
81666 int err, ro = 0;
81667
81668 +#ifdef CONFIG_PAX_SEGMEXEC
81669 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
81670 + return -EFAULT;
81671 +#endif
81672 +
81673 /*
81674 * The futex address must be "naturally" aligned.
81675 */
81676 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
81677
81678 static int get_futex_value_locked(u32 *dest, u32 __user *from)
81679 {
81680 - int ret;
81681 + unsigned long ret;
81682
81683 pagefault_disable();
81684 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
81685 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
81686 {
81687 u32 curval;
81688 int i;
81689 + mm_segment_t oldfs;
81690
81691 /*
81692 * This will fail and we want it. Some arch implementations do
81693 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
81694 * implementation, the non-functional ones will return
81695 * -ENOSYS.
81696 */
81697 + oldfs = get_fs();
81698 + set_fs(USER_DS);
81699 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
81700 futex_cmpxchg_enabled = 1;
81701 + set_fs(oldfs);
81702
81703 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
81704 plist_head_init(&futex_queues[i].chain);
81705 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
81706 index f9f44fd..29885e4 100644
81707 --- a/kernel/futex_compat.c
81708 +++ b/kernel/futex_compat.c
81709 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
81710 return 0;
81711 }
81712
81713 -static void __user *futex_uaddr(struct robust_list __user *entry,
81714 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
81715 compat_long_t futex_offset)
81716 {
81717 compat_uptr_t base = ptr_to_compat(entry);
81718 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
81719 index 9b22d03..6295b62 100644
81720 --- a/kernel/gcov/base.c
81721 +++ b/kernel/gcov/base.c
81722 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
81723 }
81724
81725 #ifdef CONFIG_MODULES
81726 -static inline int within(void *addr, void *start, unsigned long size)
81727 -{
81728 - return ((addr >= start) && (addr < start + size));
81729 -}
81730 -
81731 /* Update list and generate events when modules are unloaded. */
81732 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81733 void *data)
81734 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81735 prev = NULL;
81736 /* Remove entries located in module from linked list. */
81737 for (info = gcov_info_head; info; info = info->next) {
81738 - if (within(info, mod->module_core, mod->core_size)) {
81739 + if (within_module_core_rw((unsigned long)info, mod)) {
81740 if (prev)
81741 prev->next = info->next;
81742 else
81743 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
81744 index 383319b..56ebb13 100644
81745 --- a/kernel/hrtimer.c
81746 +++ b/kernel/hrtimer.c
81747 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
81748 local_irq_restore(flags);
81749 }
81750
81751 -static void run_hrtimer_softirq(struct softirq_action *h)
81752 +static __latent_entropy void run_hrtimer_softirq(void)
81753 {
81754 hrtimer_peek_ahead_timers();
81755 }
81756 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
81757 index 55fcce6..0e4cf34 100644
81758 --- a/kernel/irq_work.c
81759 +++ b/kernel/irq_work.c
81760 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
81761 return NOTIFY_OK;
81762 }
81763
81764 -static struct notifier_block cpu_notify;
81765 +static struct notifier_block cpu_notify = {
81766 + .notifier_call = irq_work_cpu_notify,
81767 + .priority = 0,
81768 +};
81769
81770 static __init int irq_work_init_cpu_notifier(void)
81771 {
81772 - cpu_notify.notifier_call = irq_work_cpu_notify;
81773 - cpu_notify.priority = 0;
81774 register_cpu_notifier(&cpu_notify);
81775 return 0;
81776 }
81777 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
81778 index 297a924..7290070 100644
81779 --- a/kernel/jump_label.c
81780 +++ b/kernel/jump_label.c
81781 @@ -14,6 +14,7 @@
81782 #include <linux/err.h>
81783 #include <linux/static_key.h>
81784 #include <linux/jump_label_ratelimit.h>
81785 +#include <linux/mm.h>
81786
81787 #ifdef HAVE_JUMP_LABEL
81788
81789 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
81790
81791 size = (((unsigned long)stop - (unsigned long)start)
81792 / sizeof(struct jump_entry));
81793 + pax_open_kernel();
81794 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
81795 + pax_close_kernel();
81796 }
81797
81798 static void jump_label_update(struct static_key *key, int enable);
81799 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
81800 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
81801 struct jump_entry *iter;
81802
81803 + pax_open_kernel();
81804 for (iter = iter_start; iter < iter_stop; iter++) {
81805 if (within_module_init(iter->code, mod))
81806 iter->code = 0;
81807 }
81808 + pax_close_kernel();
81809 }
81810
81811 static int
81812 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
81813 index 3127ad5..159d880 100644
81814 --- a/kernel/kallsyms.c
81815 +++ b/kernel/kallsyms.c
81816 @@ -11,6 +11,9 @@
81817 * Changed the compression method from stem compression to "table lookup"
81818 * compression (see scripts/kallsyms.c for a more complete description)
81819 */
81820 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81821 +#define __INCLUDED_BY_HIDESYM 1
81822 +#endif
81823 #include <linux/kallsyms.h>
81824 #include <linux/module.h>
81825 #include <linux/init.h>
81826 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
81827
81828 static inline int is_kernel_inittext(unsigned long addr)
81829 {
81830 + if (system_state != SYSTEM_BOOTING)
81831 + return 0;
81832 +
81833 if (addr >= (unsigned long)_sinittext
81834 && addr <= (unsigned long)_einittext)
81835 return 1;
81836 return 0;
81837 }
81838
81839 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81840 +#ifdef CONFIG_MODULES
81841 +static inline int is_module_text(unsigned long addr)
81842 +{
81843 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
81844 + return 1;
81845 +
81846 + addr = ktla_ktva(addr);
81847 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
81848 +}
81849 +#else
81850 +static inline int is_module_text(unsigned long addr)
81851 +{
81852 + return 0;
81853 +}
81854 +#endif
81855 +#endif
81856 +
81857 static inline int is_kernel_text(unsigned long addr)
81858 {
81859 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
81860 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
81861
81862 static inline int is_kernel(unsigned long addr)
81863 {
81864 +
81865 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81866 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
81867 + return 1;
81868 +
81869 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
81870 +#else
81871 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
81872 +#endif
81873 +
81874 return 1;
81875 return in_gate_area_no_mm(addr);
81876 }
81877
81878 static int is_ksym_addr(unsigned long addr)
81879 {
81880 +
81881 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81882 + if (is_module_text(addr))
81883 + return 0;
81884 +#endif
81885 +
81886 if (all_var)
81887 return is_kernel(addr);
81888
81889 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
81890
81891 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
81892 {
81893 - iter->name[0] = '\0';
81894 iter->nameoff = get_symbol_offset(new_pos);
81895 iter->pos = new_pos;
81896 }
81897 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
81898 {
81899 struct kallsym_iter *iter = m->private;
81900
81901 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81902 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
81903 + return 0;
81904 +#endif
81905 +
81906 /* Some debugging symbols have no name. Ignore them. */
81907 if (!iter->name[0])
81908 return 0;
81909 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
81910 */
81911 type = iter->exported ? toupper(iter->type) :
81912 tolower(iter->type);
81913 +
81914 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
81915 type, iter->name, iter->module_name);
81916 } else
81917 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
81918 struct kallsym_iter *iter;
81919 int ret;
81920
81921 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
81922 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
81923 if (!iter)
81924 return -ENOMEM;
81925 reset_iter(iter, 0);
81926 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
81927 index e30ac0f..3528cac 100644
81928 --- a/kernel/kcmp.c
81929 +++ b/kernel/kcmp.c
81930 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
81931 struct task_struct *task1, *task2;
81932 int ret;
81933
81934 +#ifdef CONFIG_GRKERNSEC
81935 + return -ENOSYS;
81936 +#endif
81937 +
81938 rcu_read_lock();
81939
81940 /*
81941 diff --git a/kernel/kexec.c b/kernel/kexec.c
81942 index 2a74f30..d139351 100644
81943 --- a/kernel/kexec.c
81944 +++ b/kernel/kexec.c
81945 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81946 unsigned long flags)
81947 {
81948 struct compat_kexec_segment in;
81949 - struct kexec_segment out, __user *ksegments;
81950 + struct kexec_segment out;
81951 + struct kexec_segment __user *ksegments;
81952 unsigned long i, result;
81953
81954 /* Don't allow clients that don't understand the native
81955 diff --git a/kernel/kmod.c b/kernel/kmod.c
81956 index b086006..56b1feb 100644
81957 --- a/kernel/kmod.c
81958 +++ b/kernel/kmod.c
81959 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81960 kfree(info->argv);
81961 }
81962
81963 -static int call_modprobe(char *module_name, int wait)
81964 +static int call_modprobe(char *module_name, char *module_param, int wait)
81965 {
81966 struct subprocess_info *info;
81967 static char *envp[] = {
81968 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81969 NULL
81970 };
81971
81972 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81973 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81974 if (!argv)
81975 goto out;
81976
81977 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81978 argv[1] = "-q";
81979 argv[2] = "--";
81980 argv[3] = module_name; /* check free_modprobe_argv() */
81981 - argv[4] = NULL;
81982 + argv[4] = module_param;
81983 + argv[5] = NULL;
81984
81985 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81986 NULL, free_modprobe_argv, NULL);
81987 @@ -129,9 +130,8 @@ out:
81988 * If module auto-loading support is disabled then this function
81989 * becomes a no-operation.
81990 */
81991 -int __request_module(bool wait, const char *fmt, ...)
81992 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81993 {
81994 - va_list args;
81995 char module_name[MODULE_NAME_LEN];
81996 unsigned int max_modprobes;
81997 int ret;
81998 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81999 if (!modprobe_path[0])
82000 return 0;
82001
82002 - va_start(args, fmt);
82003 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
82004 - va_end(args);
82005 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
82006 if (ret >= MODULE_NAME_LEN)
82007 return -ENAMETOOLONG;
82008
82009 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
82010 if (ret)
82011 return ret;
82012
82013 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82014 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82015 + /* hack to workaround consolekit/udisks stupidity */
82016 + read_lock(&tasklist_lock);
82017 + if (!strcmp(current->comm, "mount") &&
82018 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
82019 + read_unlock(&tasklist_lock);
82020 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
82021 + return -EPERM;
82022 + }
82023 + read_unlock(&tasklist_lock);
82024 + }
82025 +#endif
82026 +
82027 /* If modprobe needs a service that is in a module, we get a recursive
82028 * loop. Limit the number of running kmod threads to max_threads/2 or
82029 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
82030 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
82031
82032 trace_module_request(module_name, wait, _RET_IP_);
82033
82034 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82035 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82036
82037 atomic_dec(&kmod_concurrent);
82038 return ret;
82039 }
82040 +
82041 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
82042 +{
82043 + va_list args;
82044 + int ret;
82045 +
82046 + va_start(args, fmt);
82047 + ret = ____request_module(wait, module_param, fmt, args);
82048 + va_end(args);
82049 +
82050 + return ret;
82051 +}
82052 +
82053 +int __request_module(bool wait, const char *fmt, ...)
82054 +{
82055 + va_list args;
82056 + int ret;
82057 +
82058 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82059 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82060 + char module_param[MODULE_NAME_LEN];
82061 +
82062 + memset(module_param, 0, sizeof(module_param));
82063 +
82064 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
82065 +
82066 + va_start(args, fmt);
82067 + ret = ____request_module(wait, module_param, fmt, args);
82068 + va_end(args);
82069 +
82070 + return ret;
82071 + }
82072 +#endif
82073 +
82074 + va_start(args, fmt);
82075 + ret = ____request_module(wait, NULL, fmt, args);
82076 + va_end(args);
82077 +
82078 + return ret;
82079 +}
82080 +
82081 EXPORT_SYMBOL(__request_module);
82082 #endif /* CONFIG_MODULES */
82083
82084 @@ -218,6 +271,18 @@ static int ____call_usermodehelper(void *data)
82085 */
82086 set_user_nice(current, 0);
82087
82088 +#ifdef CONFIG_GRKERNSEC
82089 + /* this is race-free as far as userland is concerned as we copied
82090 + out the path to be used prior to this point and are now operating
82091 + on that copy
82092 + */
82093 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/systemd/", 17)) || strstr(sub_info->path, "..")) {
82094 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and /usr/lib/systemd\n", sub_info->path);
82095 + retval = -EPERM;
82096 + goto fail;
82097 + }
82098 +#endif
82099 +
82100 retval = -ENOMEM;
82101 new = prepare_kernel_cred(current);
82102 if (!new)
82103 @@ -260,6 +325,10 @@ static int call_helper(void *data)
82104
82105 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
82106 {
82107 +#ifdef CONFIG_GRKERNSEC
82108 + kfree(info->path);
82109 + info->path = info->origpath;
82110 +#endif
82111 if (info->cleanup)
82112 (*info->cleanup)(info);
82113 kfree(info);
82114 @@ -303,7 +372,7 @@ static int wait_for_helper(void *data)
82115 *
82116 * Thus the __user pointer cast is valid here.
82117 */
82118 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
82119 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
82120
82121 /*
82122 * If ret is 0, either ____call_usermodehelper failed and the
82123 @@ -542,7 +611,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
82124 goto out;
82125
82126 INIT_WORK(&sub_info->work, __call_usermodehelper);
82127 +#ifdef CONFIG_GRKERNSEC
82128 + sub_info->origpath = path;
82129 + sub_info->path = kstrdup(path, gfp_mask);
82130 +#else
82131 sub_info->path = path;
82132 +#endif
82133 sub_info->argv = argv;
82134 sub_info->envp = envp;
82135
82136 @@ -650,7 +724,7 @@ EXPORT_SYMBOL(call_usermodehelper);
82137 static int proc_cap_handler(struct ctl_table *table, int write,
82138 void __user *buffer, size_t *lenp, loff_t *ppos)
82139 {
82140 - struct ctl_table t;
82141 + ctl_table_no_const t;
82142 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
82143 kernel_cap_t new_cap;
82144 int err, i;
82145 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
82146 index a0d367a..11c18b6 100644
82147 --- a/kernel/kprobes.c
82148 +++ b/kernel/kprobes.c
82149 @@ -31,6 +31,9 @@
82150 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
82151 * <prasanna@in.ibm.com> added function-return probes.
82152 */
82153 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82154 +#define __INCLUDED_BY_HIDESYM 1
82155 +#endif
82156 #include <linux/kprobes.h>
82157 #include <linux/hash.h>
82158 #include <linux/init.h>
82159 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
82160
82161 static void *alloc_insn_page(void)
82162 {
82163 - return module_alloc(PAGE_SIZE);
82164 + return module_alloc_exec(PAGE_SIZE);
82165 }
82166
82167 static void free_insn_page(void *page)
82168 {
82169 - module_free(NULL, page);
82170 + module_free_exec(NULL, page);
82171 }
82172
82173 struct kprobe_insn_cache kprobe_insn_slots = {
82174 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
82175 {
82176 int i, err = 0;
82177 unsigned long offset = 0, size = 0;
82178 - char *modname, namebuf[128];
82179 + char *modname, namebuf[KSYM_NAME_LEN];
82180 const char *symbol_name;
82181 void *addr;
82182 struct kprobe_blackpoint *kb;
82183 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
82184 kprobe_type = "k";
82185
82186 if (sym)
82187 - seq_printf(pi, "%p %s %s+0x%x %s ",
82188 + seq_printf(pi, "%pK %s %s+0x%x %s ",
82189 p->addr, kprobe_type, sym, offset,
82190 (modname ? modname : " "));
82191 else
82192 - seq_printf(pi, "%p %s %p ",
82193 + seq_printf(pi, "%pK %s %pK ",
82194 p->addr, kprobe_type, p->addr);
82195
82196 if (!pp)
82197 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
82198 const char *sym = NULL;
82199 unsigned int i = *(loff_t *) v;
82200 unsigned long offset = 0;
82201 - char *modname, namebuf[128];
82202 + char *modname, namebuf[KSYM_NAME_LEN];
82203
82204 head = &kprobe_table[i];
82205 preempt_disable();
82206 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
82207 index 9659d38..bffd520 100644
82208 --- a/kernel/ksysfs.c
82209 +++ b/kernel/ksysfs.c
82210 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
82211 {
82212 if (count+1 > UEVENT_HELPER_PATH_LEN)
82213 return -ENOENT;
82214 + if (!capable(CAP_SYS_ADMIN))
82215 + return -EPERM;
82216 memcpy(uevent_helper, buf, count);
82217 uevent_helper[count] = '\0';
82218 if (count && uevent_helper[count-1] == '\n')
82219 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
82220 return count;
82221 }
82222
82223 -static struct bin_attribute notes_attr = {
82224 +static bin_attribute_no_const notes_attr __read_only = {
82225 .attr = {
82226 .name = "notes",
82227 .mode = S_IRUGO,
82228 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
82229 index e16c45b..6f49c48 100644
82230 --- a/kernel/lockdep.c
82231 +++ b/kernel/lockdep.c
82232 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
82233 end = (unsigned long) &_end,
82234 addr = (unsigned long) obj;
82235
82236 +#ifdef CONFIG_PAX_KERNEXEC
82237 + start = ktla_ktva(start);
82238 +#endif
82239 +
82240 /*
82241 * static variable?
82242 */
82243 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
82244 if (!static_obj(lock->key)) {
82245 debug_locks_off();
82246 printk("INFO: trying to register non-static key.\n");
82247 + printk("lock:%pS key:%pS.\n", lock, lock->key);
82248 printk("the code is fine but needs lockdep annotation.\n");
82249 printk("turning off the locking correctness validator.\n");
82250 dump_stack();
82251 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
82252 if (!class)
82253 return 0;
82254 }
82255 - atomic_inc((atomic_t *)&class->ops);
82256 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
82257 if (very_verbose(class)) {
82258 printk("\nacquire class [%p] %s", class->key, class->name);
82259 if (class->name_version > 1)
82260 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
82261 index b2c71c5..7b88d63 100644
82262 --- a/kernel/lockdep_proc.c
82263 +++ b/kernel/lockdep_proc.c
82264 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
82265 return 0;
82266 }
82267
82268 - seq_printf(m, "%p", class->key);
82269 + seq_printf(m, "%pK", class->key);
82270 #ifdef CONFIG_DEBUG_LOCKDEP
82271 seq_printf(m, " OPS:%8ld", class->ops);
82272 #endif
82273 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
82274
82275 list_for_each_entry(entry, &class->locks_after, entry) {
82276 if (entry->distance == 1) {
82277 - seq_printf(m, " -> [%p] ", entry->class->key);
82278 + seq_printf(m, " -> [%pK] ", entry->class->key);
82279 print_name(m, entry->class);
82280 seq_puts(m, "\n");
82281 }
82282 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
82283 if (!class->key)
82284 continue;
82285
82286 - seq_printf(m, "[%p] ", class->key);
82287 + seq_printf(m, "[%pK] ", class->key);
82288 print_name(m, class);
82289 seq_puts(m, "\n");
82290 }
82291 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82292 if (!i)
82293 seq_line(m, '-', 40-namelen, namelen);
82294
82295 - snprintf(ip, sizeof(ip), "[<%p>]",
82296 + snprintf(ip, sizeof(ip), "[<%pK>]",
82297 (void *)class->contention_point[i]);
82298 seq_printf(m, "%40s %14lu %29s %pS\n",
82299 name, stats->contention_point[i],
82300 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82301 if (!i)
82302 seq_line(m, '-', 40-namelen, namelen);
82303
82304 - snprintf(ip, sizeof(ip), "[<%p>]",
82305 + snprintf(ip, sizeof(ip), "[<%pK>]",
82306 (void *)class->contending_point[i]);
82307 seq_printf(m, "%40s %14lu %29s %pS\n",
82308 name, stats->contending_point[i],
82309 diff --git a/kernel/module.c b/kernel/module.c
82310 index dc58274..3ddfa55 100644
82311 --- a/kernel/module.c
82312 +++ b/kernel/module.c
82313 @@ -61,6 +61,7 @@
82314 #include <linux/pfn.h>
82315 #include <linux/bsearch.h>
82316 #include <linux/fips.h>
82317 +#include <linux/grsecurity.h>
82318 #include <uapi/linux/module.h>
82319 #include "module-internal.h"
82320
82321 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
82322
82323 /* Bounds of module allocation, for speeding __module_address.
82324 * Protected by module_mutex. */
82325 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
82326 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
82327 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
82328
82329 int register_module_notifier(struct notifier_block * nb)
82330 {
82331 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82332 return true;
82333
82334 list_for_each_entry_rcu(mod, &modules, list) {
82335 - struct symsearch arr[] = {
82336 + struct symsearch modarr[] = {
82337 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
82338 NOT_GPL_ONLY, false },
82339 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
82340 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82341 if (mod->state == MODULE_STATE_UNFORMED)
82342 continue;
82343
82344 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
82345 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
82346 return true;
82347 }
82348 return false;
82349 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
82350 if (!pcpusec->sh_size)
82351 return 0;
82352
82353 - if (align > PAGE_SIZE) {
82354 + if (align-1 >= PAGE_SIZE) {
82355 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
82356 mod->name, align, PAGE_SIZE);
82357 align = PAGE_SIZE;
82358 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
82359 static ssize_t show_coresize(struct module_attribute *mattr,
82360 struct module_kobject *mk, char *buffer)
82361 {
82362 - return sprintf(buffer, "%u\n", mk->mod->core_size);
82363 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
82364 }
82365
82366 static struct module_attribute modinfo_coresize =
82367 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
82368 static ssize_t show_initsize(struct module_attribute *mattr,
82369 struct module_kobject *mk, char *buffer)
82370 {
82371 - return sprintf(buffer, "%u\n", mk->mod->init_size);
82372 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
82373 }
82374
82375 static struct module_attribute modinfo_initsize =
82376 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
82377 */
82378 #ifdef CONFIG_SYSFS
82379
82380 -#ifdef CONFIG_KALLSYMS
82381 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82382 static inline bool sect_empty(const Elf_Shdr *sect)
82383 {
82384 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
82385 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
82386 {
82387 unsigned int notes, loaded, i;
82388 struct module_notes_attrs *notes_attrs;
82389 - struct bin_attribute *nattr;
82390 + bin_attribute_no_const *nattr;
82391
82392 /* failed to create section attributes, so can't create notes */
82393 if (!mod->sect_attrs)
82394 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
82395 static int module_add_modinfo_attrs(struct module *mod)
82396 {
82397 struct module_attribute *attr;
82398 - struct module_attribute *temp_attr;
82399 + module_attribute_no_const *temp_attr;
82400 int error = 0;
82401 int i;
82402
82403 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
82404
82405 static void unset_module_core_ro_nx(struct module *mod)
82406 {
82407 - set_page_attributes(mod->module_core + mod->core_text_size,
82408 - mod->module_core + mod->core_size,
82409 + set_page_attributes(mod->module_core_rw,
82410 + mod->module_core_rw + mod->core_size_rw,
82411 set_memory_x);
82412 - set_page_attributes(mod->module_core,
82413 - mod->module_core + mod->core_ro_size,
82414 + set_page_attributes(mod->module_core_rx,
82415 + mod->module_core_rx + mod->core_size_rx,
82416 set_memory_rw);
82417 }
82418
82419 static void unset_module_init_ro_nx(struct module *mod)
82420 {
82421 - set_page_attributes(mod->module_init + mod->init_text_size,
82422 - mod->module_init + mod->init_size,
82423 + set_page_attributes(mod->module_init_rw,
82424 + mod->module_init_rw + mod->init_size_rw,
82425 set_memory_x);
82426 - set_page_attributes(mod->module_init,
82427 - mod->module_init + mod->init_ro_size,
82428 + set_page_attributes(mod->module_init_rx,
82429 + mod->module_init_rx + mod->init_size_rx,
82430 set_memory_rw);
82431 }
82432
82433 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
82434 list_for_each_entry_rcu(mod, &modules, list) {
82435 if (mod->state == MODULE_STATE_UNFORMED)
82436 continue;
82437 - if ((mod->module_core) && (mod->core_text_size)) {
82438 - set_page_attributes(mod->module_core,
82439 - mod->module_core + mod->core_text_size,
82440 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82441 + set_page_attributes(mod->module_core_rx,
82442 + mod->module_core_rx + mod->core_size_rx,
82443 set_memory_rw);
82444 }
82445 - if ((mod->module_init) && (mod->init_text_size)) {
82446 - set_page_attributes(mod->module_init,
82447 - mod->module_init + mod->init_text_size,
82448 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82449 + set_page_attributes(mod->module_init_rx,
82450 + mod->module_init_rx + mod->init_size_rx,
82451 set_memory_rw);
82452 }
82453 }
82454 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
82455 list_for_each_entry_rcu(mod, &modules, list) {
82456 if (mod->state == MODULE_STATE_UNFORMED)
82457 continue;
82458 - if ((mod->module_core) && (mod->core_text_size)) {
82459 - set_page_attributes(mod->module_core,
82460 - mod->module_core + mod->core_text_size,
82461 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82462 + set_page_attributes(mod->module_core_rx,
82463 + mod->module_core_rx + mod->core_size_rx,
82464 set_memory_ro);
82465 }
82466 - if ((mod->module_init) && (mod->init_text_size)) {
82467 - set_page_attributes(mod->module_init,
82468 - mod->module_init + mod->init_text_size,
82469 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82470 + set_page_attributes(mod->module_init_rx,
82471 + mod->module_init_rx + mod->init_size_rx,
82472 set_memory_ro);
82473 }
82474 }
82475 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
82476
82477 /* This may be NULL, but that's OK */
82478 unset_module_init_ro_nx(mod);
82479 - module_free(mod, mod->module_init);
82480 + module_free(mod, mod->module_init_rw);
82481 + module_free_exec(mod, mod->module_init_rx);
82482 kfree(mod->args);
82483 percpu_modfree(mod);
82484
82485 /* Free lock-classes: */
82486 - lockdep_free_key_range(mod->module_core, mod->core_size);
82487 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
82488 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
82489
82490 /* Finally, free the core (containing the module structure) */
82491 unset_module_core_ro_nx(mod);
82492 - module_free(mod, mod->module_core);
82493 + module_free_exec(mod, mod->module_core_rx);
82494 + module_free(mod, mod->module_core_rw);
82495
82496 #ifdef CONFIG_MPU
82497 update_protections(current->mm);
82498 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82499 int ret = 0;
82500 const struct kernel_symbol *ksym;
82501
82502 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82503 + int is_fs_load = 0;
82504 + int register_filesystem_found = 0;
82505 + char *p;
82506 +
82507 + p = strstr(mod->args, "grsec_modharden_fs");
82508 + if (p) {
82509 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
82510 + /* copy \0 as well */
82511 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
82512 + is_fs_load = 1;
82513 + }
82514 +#endif
82515 +
82516 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
82517 const char *name = info->strtab + sym[i].st_name;
82518
82519 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82520 + /* it's a real shame this will never get ripped and copied
82521 + upstream! ;(
82522 + */
82523 + if (is_fs_load && !strcmp(name, "register_filesystem"))
82524 + register_filesystem_found = 1;
82525 +#endif
82526 +
82527 switch (sym[i].st_shndx) {
82528 case SHN_COMMON:
82529 /* We compiled with -fno-common. These are not
82530 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82531 ksym = resolve_symbol_wait(mod, info, name);
82532 /* Ok if resolved. */
82533 if (ksym && !IS_ERR(ksym)) {
82534 + pax_open_kernel();
82535 sym[i].st_value = ksym->value;
82536 + pax_close_kernel();
82537 break;
82538 }
82539
82540 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82541 secbase = (unsigned long)mod_percpu(mod);
82542 else
82543 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
82544 + pax_open_kernel();
82545 sym[i].st_value += secbase;
82546 + pax_close_kernel();
82547 break;
82548 }
82549 }
82550
82551 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82552 + if (is_fs_load && !register_filesystem_found) {
82553 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
82554 + ret = -EPERM;
82555 + }
82556 +#endif
82557 +
82558 return ret;
82559 }
82560
82561 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
82562 || s->sh_entsize != ~0UL
82563 || strstarts(sname, ".init"))
82564 continue;
82565 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
82566 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82567 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
82568 + else
82569 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
82570 pr_debug("\t%s\n", sname);
82571 }
82572 - switch (m) {
82573 - case 0: /* executable */
82574 - mod->core_size = debug_align(mod->core_size);
82575 - mod->core_text_size = mod->core_size;
82576 - break;
82577 - case 1: /* RO: text and ro-data */
82578 - mod->core_size = debug_align(mod->core_size);
82579 - mod->core_ro_size = mod->core_size;
82580 - break;
82581 - case 3: /* whole core */
82582 - mod->core_size = debug_align(mod->core_size);
82583 - break;
82584 - }
82585 }
82586
82587 pr_debug("Init section allocation order:\n");
82588 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
82589 || s->sh_entsize != ~0UL
82590 || !strstarts(sname, ".init"))
82591 continue;
82592 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
82593 - | INIT_OFFSET_MASK);
82594 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82595 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
82596 + else
82597 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
82598 + s->sh_entsize |= INIT_OFFSET_MASK;
82599 pr_debug("\t%s\n", sname);
82600 }
82601 - switch (m) {
82602 - case 0: /* executable */
82603 - mod->init_size = debug_align(mod->init_size);
82604 - mod->init_text_size = mod->init_size;
82605 - break;
82606 - case 1: /* RO: text and ro-data */
82607 - mod->init_size = debug_align(mod->init_size);
82608 - mod->init_ro_size = mod->init_size;
82609 - break;
82610 - case 3: /* whole init */
82611 - mod->init_size = debug_align(mod->init_size);
82612 - break;
82613 - }
82614 }
82615 }
82616
82617 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82618
82619 /* Put symbol section at end of init part of module. */
82620 symsect->sh_flags |= SHF_ALLOC;
82621 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
82622 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
82623 info->index.sym) | INIT_OFFSET_MASK;
82624 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
82625
82626 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82627 }
82628
82629 /* Append room for core symbols at end of core part. */
82630 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
82631 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
82632 - mod->core_size += strtab_size;
82633 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
82634 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
82635 + mod->core_size_rx += strtab_size;
82636
82637 /* Put string table section at end of init part of module. */
82638 strsect->sh_flags |= SHF_ALLOC;
82639 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
82640 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
82641 info->index.str) | INIT_OFFSET_MASK;
82642 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
82643 }
82644 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82645 /* Make sure we get permanent strtab: don't use info->strtab. */
82646 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
82647
82648 + pax_open_kernel();
82649 +
82650 /* Set types up while we still have access to sections. */
82651 for (i = 0; i < mod->num_symtab; i++)
82652 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
82653
82654 - mod->core_symtab = dst = mod->module_core + info->symoffs;
82655 - mod->core_strtab = s = mod->module_core + info->stroffs;
82656 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
82657 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
82658 src = mod->symtab;
82659 for (ndst = i = 0; i < mod->num_symtab; i++) {
82660 if (i == 0 ||
82661 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82662 }
82663 }
82664 mod->core_num_syms = ndst;
82665 +
82666 + pax_close_kernel();
82667 }
82668 #else
82669 static inline void layout_symtab(struct module *mod, struct load_info *info)
82670 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
82671 return vmalloc_exec(size);
82672 }
82673
82674 -static void *module_alloc_update_bounds(unsigned long size)
82675 +static void *module_alloc_update_bounds_rw(unsigned long size)
82676 {
82677 void *ret = module_alloc(size);
82678
82679 if (ret) {
82680 mutex_lock(&module_mutex);
82681 /* Update module bounds. */
82682 - if ((unsigned long)ret < module_addr_min)
82683 - module_addr_min = (unsigned long)ret;
82684 - if ((unsigned long)ret + size > module_addr_max)
82685 - module_addr_max = (unsigned long)ret + size;
82686 + if ((unsigned long)ret < module_addr_min_rw)
82687 + module_addr_min_rw = (unsigned long)ret;
82688 + if ((unsigned long)ret + size > module_addr_max_rw)
82689 + module_addr_max_rw = (unsigned long)ret + size;
82690 + mutex_unlock(&module_mutex);
82691 + }
82692 + return ret;
82693 +}
82694 +
82695 +static void *module_alloc_update_bounds_rx(unsigned long size)
82696 +{
82697 + void *ret = module_alloc_exec(size);
82698 +
82699 + if (ret) {
82700 + mutex_lock(&module_mutex);
82701 + /* Update module bounds. */
82702 + if ((unsigned long)ret < module_addr_min_rx)
82703 + module_addr_min_rx = (unsigned long)ret;
82704 + if ((unsigned long)ret + size > module_addr_max_rx)
82705 + module_addr_max_rx = (unsigned long)ret + size;
82706 mutex_unlock(&module_mutex);
82707 }
82708 return ret;
82709 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
82710 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82711 {
82712 const char *modmagic = get_modinfo(info, "vermagic");
82713 + const char *license = get_modinfo(info, "license");
82714 int err;
82715
82716 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
82717 + if (!license || !license_is_gpl_compatible(license))
82718 + return -ENOEXEC;
82719 +#endif
82720 +
82721 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
82722 modmagic = NULL;
82723
82724 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82725 }
82726
82727 /* Set up license info based on the info section */
82728 - set_license(mod, get_modinfo(info, "license"));
82729 + set_license(mod, license);
82730
82731 return 0;
82732 }
82733 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
82734 void *ptr;
82735
82736 /* Do the allocs. */
82737 - ptr = module_alloc_update_bounds(mod->core_size);
82738 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
82739 /*
82740 * The pointer to this block is stored in the module structure
82741 * which is inside the block. Just mark it as not being a
82742 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
82743 if (!ptr)
82744 return -ENOMEM;
82745
82746 - memset(ptr, 0, mod->core_size);
82747 - mod->module_core = ptr;
82748 + memset(ptr, 0, mod->core_size_rw);
82749 + mod->module_core_rw = ptr;
82750
82751 - if (mod->init_size) {
82752 - ptr = module_alloc_update_bounds(mod->init_size);
82753 + if (mod->init_size_rw) {
82754 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
82755 /*
82756 * The pointer to this block is stored in the module structure
82757 * which is inside the block. This block doesn't need to be
82758 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
82759 */
82760 kmemleak_ignore(ptr);
82761 if (!ptr) {
82762 - module_free(mod, mod->module_core);
82763 + module_free(mod, mod->module_core_rw);
82764 return -ENOMEM;
82765 }
82766 - memset(ptr, 0, mod->init_size);
82767 - mod->module_init = ptr;
82768 + memset(ptr, 0, mod->init_size_rw);
82769 + mod->module_init_rw = ptr;
82770 } else
82771 - mod->module_init = NULL;
82772 + mod->module_init_rw = NULL;
82773 +
82774 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
82775 + kmemleak_not_leak(ptr);
82776 + if (!ptr) {
82777 + if (mod->module_init_rw)
82778 + module_free(mod, mod->module_init_rw);
82779 + module_free(mod, mod->module_core_rw);
82780 + return -ENOMEM;
82781 + }
82782 +
82783 + pax_open_kernel();
82784 + memset(ptr, 0, mod->core_size_rx);
82785 + pax_close_kernel();
82786 + mod->module_core_rx = ptr;
82787 +
82788 + if (mod->init_size_rx) {
82789 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
82790 + kmemleak_ignore(ptr);
82791 + if (!ptr && mod->init_size_rx) {
82792 + module_free_exec(mod, mod->module_core_rx);
82793 + if (mod->module_init_rw)
82794 + module_free(mod, mod->module_init_rw);
82795 + module_free(mod, mod->module_core_rw);
82796 + return -ENOMEM;
82797 + }
82798 +
82799 + pax_open_kernel();
82800 + memset(ptr, 0, mod->init_size_rx);
82801 + pax_close_kernel();
82802 + mod->module_init_rx = ptr;
82803 + } else
82804 + mod->module_init_rx = NULL;
82805
82806 /* Transfer each section which specifies SHF_ALLOC */
82807 pr_debug("final section addresses:\n");
82808 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
82809 if (!(shdr->sh_flags & SHF_ALLOC))
82810 continue;
82811
82812 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
82813 - dest = mod->module_init
82814 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82815 - else
82816 - dest = mod->module_core + shdr->sh_entsize;
82817 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
82818 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82819 + dest = mod->module_init_rw
82820 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82821 + else
82822 + dest = mod->module_init_rx
82823 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82824 + } else {
82825 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82826 + dest = mod->module_core_rw + shdr->sh_entsize;
82827 + else
82828 + dest = mod->module_core_rx + shdr->sh_entsize;
82829 + }
82830 +
82831 + if (shdr->sh_type != SHT_NOBITS) {
82832 +
82833 +#ifdef CONFIG_PAX_KERNEXEC
82834 +#ifdef CONFIG_X86_64
82835 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
82836 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
82837 +#endif
82838 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
82839 + pax_open_kernel();
82840 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82841 + pax_close_kernel();
82842 + } else
82843 +#endif
82844
82845 - if (shdr->sh_type != SHT_NOBITS)
82846 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82847 + }
82848 /* Update sh_addr to point to copy in image. */
82849 - shdr->sh_addr = (unsigned long)dest;
82850 +
82851 +#ifdef CONFIG_PAX_KERNEXEC
82852 + if (shdr->sh_flags & SHF_EXECINSTR)
82853 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
82854 + else
82855 +#endif
82856 +
82857 + shdr->sh_addr = (unsigned long)dest;
82858 pr_debug("\t0x%lx %s\n",
82859 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
82860 }
82861 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
82862 * Do it before processing of module parameters, so the module
82863 * can provide parameter accessor functions of its own.
82864 */
82865 - if (mod->module_init)
82866 - flush_icache_range((unsigned long)mod->module_init,
82867 - (unsigned long)mod->module_init
82868 - + mod->init_size);
82869 - flush_icache_range((unsigned long)mod->module_core,
82870 - (unsigned long)mod->module_core + mod->core_size);
82871 + if (mod->module_init_rx)
82872 + flush_icache_range((unsigned long)mod->module_init_rx,
82873 + (unsigned long)mod->module_init_rx
82874 + + mod->init_size_rx);
82875 + flush_icache_range((unsigned long)mod->module_core_rx,
82876 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
82877
82878 set_fs(old_fs);
82879 }
82880 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
82881 static void module_deallocate(struct module *mod, struct load_info *info)
82882 {
82883 percpu_modfree(mod);
82884 - module_free(mod, mod->module_init);
82885 - module_free(mod, mod->module_core);
82886 + module_free_exec(mod, mod->module_init_rx);
82887 + module_free_exec(mod, mod->module_core_rx);
82888 + module_free(mod, mod->module_init_rw);
82889 + module_free(mod, mod->module_core_rw);
82890 }
82891
82892 int __weak module_finalize(const Elf_Ehdr *hdr,
82893 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
82894 static int post_relocation(struct module *mod, const struct load_info *info)
82895 {
82896 /* Sort exception table now relocations are done. */
82897 + pax_open_kernel();
82898 sort_extable(mod->extable, mod->extable + mod->num_exentries);
82899 + pax_close_kernel();
82900
82901 /* Copy relocated percpu area over. */
82902 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
82903 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
82904 MODULE_STATE_COMING, mod);
82905
82906 /* Set RO and NX regions for core */
82907 - set_section_ro_nx(mod->module_core,
82908 - mod->core_text_size,
82909 - mod->core_ro_size,
82910 - mod->core_size);
82911 + set_section_ro_nx(mod->module_core_rx,
82912 + mod->core_size_rx,
82913 + mod->core_size_rx,
82914 + mod->core_size_rx);
82915
82916 /* Set RO and NX regions for init */
82917 - set_section_ro_nx(mod->module_init,
82918 - mod->init_text_size,
82919 - mod->init_ro_size,
82920 - mod->init_size);
82921 + set_section_ro_nx(mod->module_init_rx,
82922 + mod->init_size_rx,
82923 + mod->init_size_rx,
82924 + mod->init_size_rx);
82925
82926 do_mod_ctors(mod);
82927 /* Start the module */
82928 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
82929 mod->strtab = mod->core_strtab;
82930 #endif
82931 unset_module_init_ro_nx(mod);
82932 - module_free(mod, mod->module_init);
82933 - mod->module_init = NULL;
82934 - mod->init_size = 0;
82935 - mod->init_ro_size = 0;
82936 - mod->init_text_size = 0;
82937 + module_free(mod, mod->module_init_rw);
82938 + module_free_exec(mod, mod->module_init_rx);
82939 + mod->module_init_rw = NULL;
82940 + mod->module_init_rx = NULL;
82941 + mod->init_size_rw = 0;
82942 + mod->init_size_rx = 0;
82943 mutex_unlock(&module_mutex);
82944 wake_up_all(&module_wq);
82945
82946 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
82947 if (err)
82948 goto free_unload;
82949
82950 + /* Now copy in args */
82951 + mod->args = strndup_user(uargs, ~0UL >> 1);
82952 + if (IS_ERR(mod->args)) {
82953 + err = PTR_ERR(mod->args);
82954 + goto free_unload;
82955 + }
82956 +
82957 /* Set up MODINFO_ATTR fields */
82958 setup_modinfo(mod, info);
82959
82960 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82961 + {
82962 + char *p, *p2;
82963 +
82964 + if (strstr(mod->args, "grsec_modharden_netdev")) {
82965 + 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);
82966 + err = -EPERM;
82967 + goto free_modinfo;
82968 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
82969 + p += sizeof("grsec_modharden_normal") - 1;
82970 + p2 = strstr(p, "_");
82971 + if (p2) {
82972 + *p2 = '\0';
82973 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
82974 + *p2 = '_';
82975 + }
82976 + err = -EPERM;
82977 + goto free_modinfo;
82978 + }
82979 + }
82980 +#endif
82981 +
82982 /* Fix up syms, so that st_value is a pointer to location. */
82983 err = simplify_symbols(mod, info);
82984 if (err < 0)
82985 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
82986
82987 flush_module_icache(mod);
82988
82989 - /* Now copy in args */
82990 - mod->args = strndup_user(uargs, ~0UL >> 1);
82991 - if (IS_ERR(mod->args)) {
82992 - err = PTR_ERR(mod->args);
82993 - goto free_arch_cleanup;
82994 - }
82995 -
82996 dynamic_debug_setup(info->debug, info->num_debug);
82997
82998 /* Finally it's fully formed, ready to start executing. */
82999 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
83000 ddebug_cleanup:
83001 dynamic_debug_remove(info->debug);
83002 synchronize_sched();
83003 - kfree(mod->args);
83004 - free_arch_cleanup:
83005 module_arch_cleanup(mod);
83006 free_modinfo:
83007 free_modinfo(mod);
83008 + kfree(mod->args);
83009 free_unload:
83010 module_unload_free(mod);
83011 unlink_mod:
83012 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
83013 unsigned long nextval;
83014
83015 /* At worse, next value is at end of module */
83016 - if (within_module_init(addr, mod))
83017 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
83018 + if (within_module_init_rx(addr, mod))
83019 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
83020 + else if (within_module_init_rw(addr, mod))
83021 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
83022 + else if (within_module_core_rx(addr, mod))
83023 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
83024 + else if (within_module_core_rw(addr, mod))
83025 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
83026 else
83027 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
83028 + return NULL;
83029
83030 /* Scan for closest preceding symbol, and next symbol. (ELF
83031 starts real symbols at 1). */
83032 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
83033 return 0;
83034
83035 seq_printf(m, "%s %u",
83036 - mod->name, mod->init_size + mod->core_size);
83037 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
83038 print_unload_info(m, mod);
83039
83040 /* Informative for users. */
83041 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
83042 mod->state == MODULE_STATE_COMING ? "Loading":
83043 "Live");
83044 /* Used by oprofile and other similar tools. */
83045 - seq_printf(m, " 0x%pK", mod->module_core);
83046 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
83047
83048 /* Taints info */
83049 if (mod->taints)
83050 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
83051
83052 static int __init proc_modules_init(void)
83053 {
83054 +#ifndef CONFIG_GRKERNSEC_HIDESYM
83055 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83056 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83057 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83058 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
83059 +#else
83060 proc_create("modules", 0, NULL, &proc_modules_operations);
83061 +#endif
83062 +#else
83063 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83064 +#endif
83065 return 0;
83066 }
83067 module_init(proc_modules_init);
83068 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
83069 {
83070 struct module *mod;
83071
83072 - if (addr < module_addr_min || addr > module_addr_max)
83073 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
83074 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
83075 return NULL;
83076
83077 list_for_each_entry_rcu(mod, &modules, list) {
83078 if (mod->state == MODULE_STATE_UNFORMED)
83079 continue;
83080 - if (within_module_core(addr, mod)
83081 - || within_module_init(addr, mod))
83082 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
83083 return mod;
83084 }
83085 return NULL;
83086 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
83087 */
83088 struct module *__module_text_address(unsigned long addr)
83089 {
83090 - struct module *mod = __module_address(addr);
83091 + struct module *mod;
83092 +
83093 +#ifdef CONFIG_X86_32
83094 + addr = ktla_ktva(addr);
83095 +#endif
83096 +
83097 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
83098 + return NULL;
83099 +
83100 + mod = __module_address(addr);
83101 +
83102 if (mod) {
83103 /* Make sure it's within the text section. */
83104 - if (!within(addr, mod->module_init, mod->init_text_size)
83105 - && !within(addr, mod->module_core, mod->core_text_size))
83106 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
83107 mod = NULL;
83108 }
83109 return mod;
83110 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
83111 index 7e3443f..b2a1e6b 100644
83112 --- a/kernel/mutex-debug.c
83113 +++ b/kernel/mutex-debug.c
83114 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
83115 }
83116
83117 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83118 - struct thread_info *ti)
83119 + struct task_struct *task)
83120 {
83121 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
83122
83123 /* Mark the current thread as blocked on the lock: */
83124 - ti->task->blocked_on = waiter;
83125 + task->blocked_on = waiter;
83126 }
83127
83128 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83129 - struct thread_info *ti)
83130 + struct task_struct *task)
83131 {
83132 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
83133 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
83134 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
83135 - ti->task->blocked_on = NULL;
83136 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
83137 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
83138 + task->blocked_on = NULL;
83139
83140 list_del_init(&waiter->list);
83141 waiter->task = NULL;
83142 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
83143 index 0799fd3..d06ae3b 100644
83144 --- a/kernel/mutex-debug.h
83145 +++ b/kernel/mutex-debug.h
83146 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
83147 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
83148 extern void debug_mutex_add_waiter(struct mutex *lock,
83149 struct mutex_waiter *waiter,
83150 - struct thread_info *ti);
83151 + struct task_struct *task);
83152 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83153 - struct thread_info *ti);
83154 + struct task_struct *task);
83155 extern void debug_mutex_unlock(struct mutex *lock);
83156 extern void debug_mutex_init(struct mutex *lock, const char *name,
83157 struct lock_class_key *key);
83158 diff --git a/kernel/mutex.c b/kernel/mutex.c
83159 index d24105b..15648eb 100644
83160 --- a/kernel/mutex.c
83161 +++ b/kernel/mutex.c
83162 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
83163 node->locked = 1;
83164 return;
83165 }
83166 - ACCESS_ONCE(prev->next) = node;
83167 + ACCESS_ONCE_RW(prev->next) = node;
83168 smp_wmb();
83169 /* Wait until the lock holder passes the lock down */
83170 while (!ACCESS_ONCE(node->locked))
83171 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
83172 while (!(next = ACCESS_ONCE(node->next)))
83173 arch_mutex_cpu_relax();
83174 }
83175 - ACCESS_ONCE(next->locked) = 1;
83176 + ACCESS_ONCE_RW(next->locked) = 1;
83177 smp_wmb();
83178 }
83179
83180 @@ -520,7 +520,7 @@ slowpath:
83181 goto skip_wait;
83182
83183 debug_mutex_lock_common(lock, &waiter);
83184 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
83185 + debug_mutex_add_waiter(lock, &waiter, task);
83186
83187 /* add waiting tasks to the end of the waitqueue (FIFO): */
83188 list_add_tail(&waiter.list, &lock->wait_list);
83189 @@ -564,7 +564,7 @@ slowpath:
83190 schedule_preempt_disabled();
83191 spin_lock_mutex(&lock->wait_lock, flags);
83192 }
83193 - mutex_remove_waiter(lock, &waiter, current_thread_info());
83194 + mutex_remove_waiter(lock, &waiter, task);
83195 /* set it to 0 if there are no waiters left: */
83196 if (likely(list_empty(&lock->wait_list)))
83197 atomic_set(&lock->count, 0);
83198 @@ -601,7 +601,7 @@ skip_wait:
83199 return 0;
83200
83201 err:
83202 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
83203 + mutex_remove_waiter(lock, &waiter, task);
83204 spin_unlock_mutex(&lock->wait_lock, flags);
83205 debug_mutex_free_waiter(&waiter);
83206 mutex_release(&lock->dep_map, 1, ip);
83207 diff --git a/kernel/notifier.c b/kernel/notifier.c
83208 index 2d5cc4c..d9ea600 100644
83209 --- a/kernel/notifier.c
83210 +++ b/kernel/notifier.c
83211 @@ -5,6 +5,7 @@
83212 #include <linux/rcupdate.h>
83213 #include <linux/vmalloc.h>
83214 #include <linux/reboot.h>
83215 +#include <linux/mm.h>
83216
83217 /*
83218 * Notifier list for kernel code which wants to be called
83219 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
83220 while ((*nl) != NULL) {
83221 if (n->priority > (*nl)->priority)
83222 break;
83223 - nl = &((*nl)->next);
83224 + nl = (struct notifier_block **)&((*nl)->next);
83225 }
83226 - n->next = *nl;
83227 + pax_open_kernel();
83228 + *(const void **)&n->next = *nl;
83229 rcu_assign_pointer(*nl, n);
83230 + pax_close_kernel();
83231 return 0;
83232 }
83233
83234 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
83235 return 0;
83236 if (n->priority > (*nl)->priority)
83237 break;
83238 - nl = &((*nl)->next);
83239 + nl = (struct notifier_block **)&((*nl)->next);
83240 }
83241 - n->next = *nl;
83242 + pax_open_kernel();
83243 + *(const void **)&n->next = *nl;
83244 rcu_assign_pointer(*nl, n);
83245 + pax_close_kernel();
83246 return 0;
83247 }
83248
83249 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
83250 {
83251 while ((*nl) != NULL) {
83252 if ((*nl) == n) {
83253 + pax_open_kernel();
83254 rcu_assign_pointer(*nl, n->next);
83255 + pax_close_kernel();
83256 return 0;
83257 }
83258 - nl = &((*nl)->next);
83259 + nl = (struct notifier_block **)&((*nl)->next);
83260 }
83261 return -ENOENT;
83262 }
83263 diff --git a/kernel/panic.c b/kernel/panic.c
83264 index b6c482c..5578061 100644
83265 --- a/kernel/panic.c
83266 +++ b/kernel/panic.c
83267 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
83268 disable_trace_on_warning();
83269
83270 pr_warn("------------[ cut here ]------------\n");
83271 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
83272 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
83273 raw_smp_processor_id(), current->pid, file, line, caller);
83274
83275 if (args)
83276 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
83277 */
83278 void __stack_chk_fail(void)
83279 {
83280 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
83281 + dump_stack();
83282 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
83283 __builtin_return_address(0));
83284 }
83285 EXPORT_SYMBOL(__stack_chk_fail);
83286 diff --git a/kernel/pid.c b/kernel/pid.c
83287 index 9b9a266..c20ef80 100644
83288 --- a/kernel/pid.c
83289 +++ b/kernel/pid.c
83290 @@ -33,6 +33,7 @@
83291 #include <linux/rculist.h>
83292 #include <linux/bootmem.h>
83293 #include <linux/hash.h>
83294 +#include <linux/security.h>
83295 #include <linux/pid_namespace.h>
83296 #include <linux/init_task.h>
83297 #include <linux/syscalls.h>
83298 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
83299
83300 int pid_max = PID_MAX_DEFAULT;
83301
83302 -#define RESERVED_PIDS 300
83303 +#define RESERVED_PIDS 500
83304
83305 int pid_max_min = RESERVED_PIDS + 1;
83306 int pid_max_max = PID_MAX_LIMIT;
83307 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
83308 */
83309 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
83310 {
83311 + struct task_struct *task;
83312 +
83313 rcu_lockdep_assert(rcu_read_lock_held(),
83314 "find_task_by_pid_ns() needs rcu_read_lock()"
83315 " protection");
83316 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83317 +
83318 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83319 +
83320 + if (gr_pid_is_chrooted(task))
83321 + return NULL;
83322 +
83323 + return task;
83324 }
83325
83326 struct task_struct *find_task_by_vpid(pid_t vnr)
83327 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
83328 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
83329 }
83330
83331 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
83332 +{
83333 + rcu_lockdep_assert(rcu_read_lock_held(),
83334 + "find_task_by_pid_ns() needs rcu_read_lock()"
83335 + " protection");
83336 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
83337 +}
83338 +
83339 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
83340 {
83341 struct pid *pid;
83342 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
83343 index 4208655..19f36a5 100644
83344 --- a/kernel/pid_namespace.c
83345 +++ b/kernel/pid_namespace.c
83346 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
83347 void __user *buffer, size_t *lenp, loff_t *ppos)
83348 {
83349 struct pid_namespace *pid_ns = task_active_pid_ns(current);
83350 - struct ctl_table tmp = *table;
83351 + ctl_table_no_const tmp = *table;
83352
83353 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
83354 return -EPERM;
83355 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
83356 index c7f31aa..2b44977 100644
83357 --- a/kernel/posix-cpu-timers.c
83358 +++ b/kernel/posix-cpu-timers.c
83359 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
83360
83361 static __init int init_posix_cpu_timers(void)
83362 {
83363 - struct k_clock process = {
83364 + static struct k_clock process = {
83365 .clock_getres = process_cpu_clock_getres,
83366 .clock_get = process_cpu_clock_get,
83367 .timer_create = process_cpu_timer_create,
83368 .nsleep = process_cpu_nsleep,
83369 .nsleep_restart = process_cpu_nsleep_restart,
83370 };
83371 - struct k_clock thread = {
83372 + static struct k_clock thread = {
83373 .clock_getres = thread_cpu_clock_getres,
83374 .clock_get = thread_cpu_clock_get,
83375 .timer_create = thread_cpu_timer_create,
83376 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
83377 index 424c2d4..679242f 100644
83378 --- a/kernel/posix-timers.c
83379 +++ b/kernel/posix-timers.c
83380 @@ -43,6 +43,7 @@
83381 #include <linux/hash.h>
83382 #include <linux/posix-clock.h>
83383 #include <linux/posix-timers.h>
83384 +#include <linux/grsecurity.h>
83385 #include <linux/syscalls.h>
83386 #include <linux/wait.h>
83387 #include <linux/workqueue.h>
83388 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
83389 * which we beg off on and pass to do_sys_settimeofday().
83390 */
83391
83392 -static struct k_clock posix_clocks[MAX_CLOCKS];
83393 +static struct k_clock *posix_clocks[MAX_CLOCKS];
83394
83395 /*
83396 * These ones are defined below.
83397 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
83398 */
83399 static __init int init_posix_timers(void)
83400 {
83401 - struct k_clock clock_realtime = {
83402 + static struct k_clock clock_realtime = {
83403 .clock_getres = hrtimer_get_res,
83404 .clock_get = posix_clock_realtime_get,
83405 .clock_set = posix_clock_realtime_set,
83406 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
83407 .timer_get = common_timer_get,
83408 .timer_del = common_timer_del,
83409 };
83410 - struct k_clock clock_monotonic = {
83411 + static struct k_clock clock_monotonic = {
83412 .clock_getres = hrtimer_get_res,
83413 .clock_get = posix_ktime_get_ts,
83414 .nsleep = common_nsleep,
83415 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
83416 .timer_get = common_timer_get,
83417 .timer_del = common_timer_del,
83418 };
83419 - struct k_clock clock_monotonic_raw = {
83420 + static struct k_clock clock_monotonic_raw = {
83421 .clock_getres = hrtimer_get_res,
83422 .clock_get = posix_get_monotonic_raw,
83423 };
83424 - struct k_clock clock_realtime_coarse = {
83425 + static struct k_clock clock_realtime_coarse = {
83426 .clock_getres = posix_get_coarse_res,
83427 .clock_get = posix_get_realtime_coarse,
83428 };
83429 - struct k_clock clock_monotonic_coarse = {
83430 + static struct k_clock clock_monotonic_coarse = {
83431 .clock_getres = posix_get_coarse_res,
83432 .clock_get = posix_get_monotonic_coarse,
83433 };
83434 - struct k_clock clock_tai = {
83435 + static struct k_clock clock_tai = {
83436 .clock_getres = hrtimer_get_res,
83437 .clock_get = posix_get_tai,
83438 .nsleep = common_nsleep,
83439 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
83440 .timer_get = common_timer_get,
83441 .timer_del = common_timer_del,
83442 };
83443 - struct k_clock clock_boottime = {
83444 + static struct k_clock clock_boottime = {
83445 .clock_getres = hrtimer_get_res,
83446 .clock_get = posix_get_boottime,
83447 .nsleep = common_nsleep,
83448 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
83449 return;
83450 }
83451
83452 - posix_clocks[clock_id] = *new_clock;
83453 + posix_clocks[clock_id] = new_clock;
83454 }
83455 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
83456
83457 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
83458 return (id & CLOCKFD_MASK) == CLOCKFD ?
83459 &clock_posix_dynamic : &clock_posix_cpu;
83460
83461 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
83462 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
83463 return NULL;
83464 - return &posix_clocks[id];
83465 + return posix_clocks[id];
83466 }
83467
83468 static int common_timer_create(struct k_itimer *new_timer)
83469 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
83470 struct k_clock *kc = clockid_to_kclock(which_clock);
83471 struct k_itimer *new_timer;
83472 int error, new_timer_id;
83473 - sigevent_t event;
83474 + sigevent_t event = { };
83475 int it_id_set = IT_ID_NOT_SET;
83476
83477 if (!kc)
83478 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
83479 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
83480 return -EFAULT;
83481
83482 + /* only the CLOCK_REALTIME clock can be set, all other clocks
83483 + have their clock_set fptr set to a nosettime dummy function
83484 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
83485 + call common_clock_set, which calls do_sys_settimeofday, which
83486 + we hook
83487 + */
83488 +
83489 return kc->clock_set(which_clock, &new_tp);
83490 }
83491
83492 diff --git a/kernel/power/process.c b/kernel/power/process.c
83493 index 06ec886..9dba35e 100644
83494 --- a/kernel/power/process.c
83495 +++ b/kernel/power/process.c
83496 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
83497 unsigned int elapsed_msecs;
83498 bool wakeup = false;
83499 int sleep_usecs = USEC_PER_MSEC;
83500 + bool timedout = false;
83501
83502 do_gettimeofday(&start);
83503
83504 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
83505
83506 while (true) {
83507 todo = 0;
83508 + if (time_after(jiffies, end_time))
83509 + timedout = true;
83510 read_lock(&tasklist_lock);
83511 do_each_thread(g, p) {
83512 if (p == current || !freeze_task(p))
83513 continue;
83514
83515 - if (!freezer_should_skip(p))
83516 + if (!freezer_should_skip(p)) {
83517 todo++;
83518 + if (timedout) {
83519 + printk(KERN_ERR "Task refusing to freeze:\n");
83520 + sched_show_task(p);
83521 + }
83522 + }
83523 } while_each_thread(g, p);
83524 read_unlock(&tasklist_lock);
83525
83526 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
83527 todo += wq_busy;
83528 }
83529
83530 - if (!todo || time_after(jiffies, end_time))
83531 + if (!todo || timedout)
83532 break;
83533
83534 if (pm_wakeup_pending()) {
83535 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
83536 index b4e8500..b457a6c 100644
83537 --- a/kernel/printk/printk.c
83538 +++ b/kernel/printk/printk.c
83539 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
83540 if (from_file && type != SYSLOG_ACTION_OPEN)
83541 return 0;
83542
83543 +#ifdef CONFIG_GRKERNSEC_DMESG
83544 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
83545 + return -EPERM;
83546 +#endif
83547 +
83548 if (syslog_action_restricted(type)) {
83549 if (capable(CAP_SYSLOG))
83550 return 0;
83551 diff --git a/kernel/profile.c b/kernel/profile.c
83552 index 6631e1e..310c266 100644
83553 --- a/kernel/profile.c
83554 +++ b/kernel/profile.c
83555 @@ -37,7 +37,7 @@ struct profile_hit {
83556 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
83557 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
83558
83559 -static atomic_t *prof_buffer;
83560 +static atomic_unchecked_t *prof_buffer;
83561 static unsigned long prof_len, prof_shift;
83562
83563 int prof_on __read_mostly;
83564 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
83565 hits[i].pc = 0;
83566 continue;
83567 }
83568 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83569 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83570 hits[i].hits = hits[i].pc = 0;
83571 }
83572 }
83573 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83574 * Add the current hit(s) and flush the write-queue out
83575 * to the global buffer:
83576 */
83577 - atomic_add(nr_hits, &prof_buffer[pc]);
83578 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
83579 for (i = 0; i < NR_PROFILE_HIT; ++i) {
83580 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83581 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83582 hits[i].pc = hits[i].hits = 0;
83583 }
83584 out:
83585 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83586 {
83587 unsigned long pc;
83588 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
83589 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83590 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83591 }
83592 #endif /* !CONFIG_SMP */
83593
83594 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
83595 return -EFAULT;
83596 buf++; p++; count--; read++;
83597 }
83598 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
83599 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
83600 if (copy_to_user(buf, (void *)pnt, count))
83601 return -EFAULT;
83602 read += count;
83603 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
83604 }
83605 #endif
83606 profile_discard_flip_buffers();
83607 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
83608 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
83609 return count;
83610 }
83611
83612 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
83613 index dd562e9..74fc16d 100644
83614 --- a/kernel/ptrace.c
83615 +++ b/kernel/ptrace.c
83616 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
83617 if (seize)
83618 flags |= PT_SEIZED;
83619 rcu_read_lock();
83620 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83621 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83622 flags |= PT_PTRACE_CAP;
83623 rcu_read_unlock();
83624 task->ptrace = flags;
83625 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
83626 break;
83627 return -EIO;
83628 }
83629 - if (copy_to_user(dst, buf, retval))
83630 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
83631 return -EFAULT;
83632 copied += retval;
83633 src += retval;
83634 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
83635 bool seized = child->ptrace & PT_SEIZED;
83636 int ret = -EIO;
83637 siginfo_t siginfo, *si;
83638 - void __user *datavp = (void __user *) data;
83639 + void __user *datavp = (__force void __user *) data;
83640 unsigned long __user *datalp = datavp;
83641 unsigned long flags;
83642
83643 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
83644 goto out;
83645 }
83646
83647 + if (gr_handle_ptrace(child, request)) {
83648 + ret = -EPERM;
83649 + goto out_put_task_struct;
83650 + }
83651 +
83652 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83653 ret = ptrace_attach(child, request, addr, data);
83654 /*
83655 * Some architectures need to do book-keeping after
83656 * a ptrace attach.
83657 */
83658 - if (!ret)
83659 + if (!ret) {
83660 arch_ptrace_attach(child);
83661 + gr_audit_ptrace(child);
83662 + }
83663 goto out_put_task_struct;
83664 }
83665
83666 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
83667 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
83668 if (copied != sizeof(tmp))
83669 return -EIO;
83670 - return put_user(tmp, (unsigned long __user *)data);
83671 + return put_user(tmp, (__force unsigned long __user *)data);
83672 }
83673
83674 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
83675 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
83676 }
83677
83678 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83679 - compat_long_t addr, compat_long_t data)
83680 + compat_ulong_t addr, compat_ulong_t data)
83681 {
83682 struct task_struct *child;
83683 long ret;
83684 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83685 goto out;
83686 }
83687
83688 + if (gr_handle_ptrace(child, request)) {
83689 + ret = -EPERM;
83690 + goto out_put_task_struct;
83691 + }
83692 +
83693 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83694 ret = ptrace_attach(child, request, addr, data);
83695 /*
83696 * Some architectures need to do book-keeping after
83697 * a ptrace attach.
83698 */
83699 - if (!ret)
83700 + if (!ret) {
83701 arch_ptrace_attach(child);
83702 + gr_audit_ptrace(child);
83703 + }
83704 goto out_put_task_struct;
83705 }
83706
83707 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
83708 index b02a339..ce2d20c 100644
83709 --- a/kernel/rcupdate.c
83710 +++ b/kernel/rcupdate.c
83711 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
83712 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
83713 */
83714 if (till_stall_check < 3) {
83715 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
83716 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
83717 till_stall_check = 3;
83718 } else if (till_stall_check > 300) {
83719 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
83720 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
83721 till_stall_check = 300;
83722 }
83723 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
83724 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
83725 index 9ed6075..c9e8a63 100644
83726 --- a/kernel/rcutiny.c
83727 +++ b/kernel/rcutiny.c
83728 @@ -45,7 +45,7 @@
83729 /* Forward declarations for rcutiny_plugin.h. */
83730 struct rcu_ctrlblk;
83731 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
83732 -static void rcu_process_callbacks(struct softirq_action *unused);
83733 +static void rcu_process_callbacks(void);
83734 static void __call_rcu(struct rcu_head *head,
83735 void (*func)(struct rcu_head *rcu),
83736 struct rcu_ctrlblk *rcp);
83737 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
83738 false));
83739 }
83740
83741 -static void rcu_process_callbacks(struct softirq_action *unused)
83742 +static __latent_entropy void rcu_process_callbacks(void)
83743 {
83744 __rcu_process_callbacks(&rcu_sched_ctrlblk);
83745 __rcu_process_callbacks(&rcu_bh_ctrlblk);
83746 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
83747 index be63101..05cf721 100644
83748 --- a/kernel/rcutorture.c
83749 +++ b/kernel/rcutorture.c
83750 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
83751 { 0 };
83752 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
83753 { 0 };
83754 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83755 -static atomic_t n_rcu_torture_alloc;
83756 -static atomic_t n_rcu_torture_alloc_fail;
83757 -static atomic_t n_rcu_torture_free;
83758 -static atomic_t n_rcu_torture_mberror;
83759 -static atomic_t n_rcu_torture_error;
83760 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83761 +static atomic_unchecked_t n_rcu_torture_alloc;
83762 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
83763 +static atomic_unchecked_t n_rcu_torture_free;
83764 +static atomic_unchecked_t n_rcu_torture_mberror;
83765 +static atomic_unchecked_t n_rcu_torture_error;
83766 static long n_rcu_torture_barrier_error;
83767 static long n_rcu_torture_boost_ktrerror;
83768 static long n_rcu_torture_boost_rterror;
83769 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
83770
83771 spin_lock_bh(&rcu_torture_lock);
83772 if (list_empty(&rcu_torture_freelist)) {
83773 - atomic_inc(&n_rcu_torture_alloc_fail);
83774 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
83775 spin_unlock_bh(&rcu_torture_lock);
83776 return NULL;
83777 }
83778 - atomic_inc(&n_rcu_torture_alloc);
83779 + atomic_inc_unchecked(&n_rcu_torture_alloc);
83780 p = rcu_torture_freelist.next;
83781 list_del_init(p);
83782 spin_unlock_bh(&rcu_torture_lock);
83783 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
83784 static void
83785 rcu_torture_free(struct rcu_torture *p)
83786 {
83787 - atomic_inc(&n_rcu_torture_free);
83788 + atomic_inc_unchecked(&n_rcu_torture_free);
83789 spin_lock_bh(&rcu_torture_lock);
83790 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
83791 spin_unlock_bh(&rcu_torture_lock);
83792 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
83793 i = rp->rtort_pipe_count;
83794 if (i > RCU_TORTURE_PIPE_LEN)
83795 i = RCU_TORTURE_PIPE_LEN;
83796 - atomic_inc(&rcu_torture_wcount[i]);
83797 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83798 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
83799 rp->rtort_mbtest = 0;
83800 rcu_torture_free(rp);
83801 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
83802 i = old_rp->rtort_pipe_count;
83803 if (i > RCU_TORTURE_PIPE_LEN)
83804 i = RCU_TORTURE_PIPE_LEN;
83805 - atomic_inc(&rcu_torture_wcount[i]);
83806 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83807 old_rp->rtort_pipe_count++;
83808 if (gp_normal == gp_exp)
83809 exp = !!(rcu_random(&rand) & 0x80);
83810 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
83811 i = rp->rtort_pipe_count;
83812 if (i > RCU_TORTURE_PIPE_LEN)
83813 i = RCU_TORTURE_PIPE_LEN;
83814 - atomic_inc(&rcu_torture_wcount[i]);
83815 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83816 if (++rp->rtort_pipe_count >=
83817 RCU_TORTURE_PIPE_LEN) {
83818 rp->rtort_mbtest = 0;
83819 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
83820 return;
83821 }
83822 if (p->rtort_mbtest == 0)
83823 - atomic_inc(&n_rcu_torture_mberror);
83824 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83825 spin_lock(&rand_lock);
83826 cur_ops->read_delay(&rand);
83827 n_rcu_torture_timers++;
83828 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
83829 continue;
83830 }
83831 if (p->rtort_mbtest == 0)
83832 - atomic_inc(&n_rcu_torture_mberror);
83833 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83834 cur_ops->read_delay(&rand);
83835 preempt_disable();
83836 pipe_count = p->rtort_pipe_count;
83837 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
83838 rcu_torture_current,
83839 rcu_torture_current_version,
83840 list_empty(&rcu_torture_freelist),
83841 - atomic_read(&n_rcu_torture_alloc),
83842 - atomic_read(&n_rcu_torture_alloc_fail),
83843 - atomic_read(&n_rcu_torture_free));
83844 + atomic_read_unchecked(&n_rcu_torture_alloc),
83845 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
83846 + atomic_read_unchecked(&n_rcu_torture_free));
83847 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
83848 - atomic_read(&n_rcu_torture_mberror),
83849 + atomic_read_unchecked(&n_rcu_torture_mberror),
83850 n_rcu_torture_boost_ktrerror,
83851 n_rcu_torture_boost_rterror);
83852 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
83853 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
83854 n_barrier_attempts,
83855 n_rcu_torture_barrier_error);
83856 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
83857 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
83858 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
83859 n_rcu_torture_barrier_error != 0 ||
83860 n_rcu_torture_boost_ktrerror != 0 ||
83861 n_rcu_torture_boost_rterror != 0 ||
83862 n_rcu_torture_boost_failure != 0 ||
83863 i > 1) {
83864 cnt += sprintf(&page[cnt], "!!! ");
83865 - atomic_inc(&n_rcu_torture_error);
83866 + atomic_inc_unchecked(&n_rcu_torture_error);
83867 WARN_ON_ONCE(1);
83868 }
83869 cnt += sprintf(&page[cnt], "Reader Pipe: ");
83870 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
83871 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
83872 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83873 cnt += sprintf(&page[cnt], " %d",
83874 - atomic_read(&rcu_torture_wcount[i]));
83875 + atomic_read_unchecked(&rcu_torture_wcount[i]));
83876 }
83877 cnt += sprintf(&page[cnt], "\n");
83878 if (cur_ops->stats)
83879 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
83880
83881 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
83882
83883 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83884 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83885 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
83886 else if (n_online_successes != n_online_attempts ||
83887 n_offline_successes != n_offline_attempts)
83888 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
83889
83890 rcu_torture_current = NULL;
83891 rcu_torture_current_version = 0;
83892 - atomic_set(&n_rcu_torture_alloc, 0);
83893 - atomic_set(&n_rcu_torture_alloc_fail, 0);
83894 - atomic_set(&n_rcu_torture_free, 0);
83895 - atomic_set(&n_rcu_torture_mberror, 0);
83896 - atomic_set(&n_rcu_torture_error, 0);
83897 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
83898 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
83899 + atomic_set_unchecked(&n_rcu_torture_free, 0);
83900 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
83901 + atomic_set_unchecked(&n_rcu_torture_error, 0);
83902 n_rcu_torture_barrier_error = 0;
83903 n_rcu_torture_boost_ktrerror = 0;
83904 n_rcu_torture_boost_rterror = 0;
83905 n_rcu_torture_boost_failure = 0;
83906 n_rcu_torture_boosts = 0;
83907 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
83908 - atomic_set(&rcu_torture_wcount[i], 0);
83909 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
83910 for_each_possible_cpu(cpu) {
83911 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83912 per_cpu(rcu_torture_count, cpu)[i] = 0;
83913 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
83914 index 32618b3..c1fb822 100644
83915 --- a/kernel/rcutree.c
83916 +++ b/kernel/rcutree.c
83917 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
83918 rcu_prepare_for_idle(smp_processor_id());
83919 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83920 smp_mb__before_atomic_inc(); /* See above. */
83921 - atomic_inc(&rdtp->dynticks);
83922 + atomic_inc_unchecked(&rdtp->dynticks);
83923 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
83924 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83925 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83926
83927 /*
83928 * It is illegal to enter an extended quiescent state while
83929 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
83930 int user)
83931 {
83932 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
83933 - atomic_inc(&rdtp->dynticks);
83934 + atomic_inc_unchecked(&rdtp->dynticks);
83935 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83936 smp_mb__after_atomic_inc(); /* See above. */
83937 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83938 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83939 rcu_cleanup_after_idle(smp_processor_id());
83940 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
83941 if (!user && !is_idle_task(current)) {
83942 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
83943 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
83944
83945 if (rdtp->dynticks_nmi_nesting == 0 &&
83946 - (atomic_read(&rdtp->dynticks) & 0x1))
83947 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
83948 return;
83949 rdtp->dynticks_nmi_nesting++;
83950 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
83951 - atomic_inc(&rdtp->dynticks);
83952 + atomic_inc_unchecked(&rdtp->dynticks);
83953 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83954 smp_mb__after_atomic_inc(); /* See above. */
83955 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83956 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83957 }
83958
83959 /**
83960 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
83961 return;
83962 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83963 smp_mb__before_atomic_inc(); /* See above. */
83964 - atomic_inc(&rdtp->dynticks);
83965 + atomic_inc_unchecked(&rdtp->dynticks);
83966 smp_mb__after_atomic_inc(); /* Force delay to next write. */
83967 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83968 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83969 }
83970
83971 /**
83972 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
83973 int ret;
83974
83975 preempt_disable();
83976 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83977 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83978 preempt_enable();
83979 return ret;
83980 }
83981 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
83982 static int dyntick_save_progress_counter(struct rcu_data *rdp,
83983 bool *isidle, unsigned long *maxj)
83984 {
83985 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
83986 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83987 rcu_sysidle_check_cpu(rdp, isidle, maxj);
83988 return (rdp->dynticks_snap & 0x1) == 0;
83989 }
83990 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
83991 unsigned int curr;
83992 unsigned int snap;
83993
83994 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
83995 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83996 snap = (unsigned int)rdp->dynticks_snap;
83997
83998 /*
83999 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
84000 rdp = this_cpu_ptr(rsp->rda);
84001 rcu_preempt_check_blocked_tasks(rnp);
84002 rnp->qsmask = rnp->qsmaskinit;
84003 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
84004 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
84005 WARN_ON_ONCE(rnp->completed != rsp->completed);
84006 - ACCESS_ONCE(rnp->completed) = rsp->completed;
84007 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
84008 if (rnp == rdp->mynode)
84009 __note_gp_changes(rsp, rnp, rdp);
84010 rcu_preempt_boost_start_gp(rnp);
84011 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
84012 */
84013 rcu_for_each_node_breadth_first(rsp, rnp) {
84014 raw_spin_lock_irq(&rnp->lock);
84015 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
84016 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
84017 rdp = this_cpu_ptr(rsp->rda);
84018 if (rnp == rdp->mynode)
84019 __note_gp_changes(rsp, rnp, rdp);
84020 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
84021 rsp->qlen += rdp->qlen;
84022 rdp->n_cbs_orphaned += rdp->qlen;
84023 rdp->qlen_lazy = 0;
84024 - ACCESS_ONCE(rdp->qlen) = 0;
84025 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84026 }
84027
84028 /*
84029 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
84030 }
84031 smp_mb(); /* List handling before counting for rcu_barrier(). */
84032 rdp->qlen_lazy -= count_lazy;
84033 - ACCESS_ONCE(rdp->qlen) -= count;
84034 + ACCESS_ONCE_RW(rdp->qlen) -= count;
84035 rdp->n_cbs_invoked += count;
84036
84037 /* Reinstate batch limit if we have worked down the excess. */
84038 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
84039 /*
84040 * Do RCU core processing for the current CPU.
84041 */
84042 -static void rcu_process_callbacks(struct softirq_action *unused)
84043 +static __latent_entropy void rcu_process_callbacks(void)
84044 {
84045 struct rcu_state *rsp;
84046
84047 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84048 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
84049 if (debug_rcu_head_queue(head)) {
84050 /* Probable double call_rcu(), so leak the callback. */
84051 - ACCESS_ONCE(head->func) = rcu_leak_callback;
84052 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
84053 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
84054 return;
84055 }
84056 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84057 local_irq_restore(flags);
84058 return;
84059 }
84060 - ACCESS_ONCE(rdp->qlen)++;
84061 + ACCESS_ONCE_RW(rdp->qlen)++;
84062 if (lazy)
84063 rdp->qlen_lazy++;
84064 else
84065 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
84066 * counter wrap on a 32-bit system. Quite a few more CPUs would of
84067 * course be required on a 64-bit system.
84068 */
84069 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
84070 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
84071 (ulong)atomic_long_read(&rsp->expedited_done) +
84072 ULONG_MAX / 8)) {
84073 synchronize_sched();
84074 - atomic_long_inc(&rsp->expedited_wrap);
84075 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
84076 return;
84077 }
84078
84079 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
84080 * Take a ticket. Note that atomic_inc_return() implies a
84081 * full memory barrier.
84082 */
84083 - snap = atomic_long_inc_return(&rsp->expedited_start);
84084 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
84085 firstsnap = snap;
84086 get_online_cpus();
84087 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
84088 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
84089 synchronize_sched_expedited_cpu_stop,
84090 NULL) == -EAGAIN) {
84091 put_online_cpus();
84092 - atomic_long_inc(&rsp->expedited_tryfail);
84093 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
84094
84095 /* Check to see if someone else did our work for us. */
84096 s = atomic_long_read(&rsp->expedited_done);
84097 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84098 /* ensure test happens before caller kfree */
84099 smp_mb__before_atomic_inc(); /* ^^^ */
84100 - atomic_long_inc(&rsp->expedited_workdone1);
84101 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
84102 return;
84103 }
84104
84105 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
84106 udelay(trycount * num_online_cpus());
84107 } else {
84108 wait_rcu_gp(call_rcu_sched);
84109 - atomic_long_inc(&rsp->expedited_normal);
84110 + atomic_long_inc_unchecked(&rsp->expedited_normal);
84111 return;
84112 }
84113
84114 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
84115 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84116 /* ensure test happens before caller kfree */
84117 smp_mb__before_atomic_inc(); /* ^^^ */
84118 - atomic_long_inc(&rsp->expedited_workdone2);
84119 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
84120 return;
84121 }
84122
84123 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
84124 * period works for us.
84125 */
84126 get_online_cpus();
84127 - snap = atomic_long_read(&rsp->expedited_start);
84128 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
84129 smp_mb(); /* ensure read is before try_stop_cpus(). */
84130 }
84131 - atomic_long_inc(&rsp->expedited_stoppedcpus);
84132 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
84133
84134 /*
84135 * Everyone up to our most recent fetch is covered by our grace
84136 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
84137 * than we did already did their update.
84138 */
84139 do {
84140 - atomic_long_inc(&rsp->expedited_done_tries);
84141 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
84142 s = atomic_long_read(&rsp->expedited_done);
84143 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
84144 /* ensure test happens before caller kfree */
84145 smp_mb__before_atomic_inc(); /* ^^^ */
84146 - atomic_long_inc(&rsp->expedited_done_lost);
84147 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
84148 break;
84149 }
84150 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
84151 - atomic_long_inc(&rsp->expedited_done_exit);
84152 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
84153
84154 put_online_cpus();
84155 }
84156 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84157 * ACCESS_ONCE() to prevent the compiler from speculating
84158 * the increment to precede the early-exit check.
84159 */
84160 - ACCESS_ONCE(rsp->n_barrier_done)++;
84161 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84162 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
84163 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
84164 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
84165 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84166
84167 /* Increment ->n_barrier_done to prevent duplicate work. */
84168 smp_mb(); /* Keep increment after above mechanism. */
84169 - ACCESS_ONCE(rsp->n_barrier_done)++;
84170 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84171 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
84172 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
84173 smp_mb(); /* Keep increment before caller's subsequent code. */
84174 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
84175 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
84176 init_callback_list(rdp);
84177 rdp->qlen_lazy = 0;
84178 - ACCESS_ONCE(rdp->qlen) = 0;
84179 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84180 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
84181 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
84182 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
84183 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
84184 rdp->cpu = cpu;
84185 rdp->rsp = rsp;
84186 rcu_boot_init_nocb_percpu_data(rdp);
84187 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
84188 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
84189 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
84190 rcu_sysidle_init_percpu_data(rdp->dynticks);
84191 - atomic_set(&rdp->dynticks->dynticks,
84192 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
84193 + atomic_set_unchecked(&rdp->dynticks->dynticks,
84194 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
84195 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
84196
84197 /* Add CPU to rcu_node bitmasks. */
84198 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
84199 index 5f97eab..db8f687 100644
84200 --- a/kernel/rcutree.h
84201 +++ b/kernel/rcutree.h
84202 @@ -87,11 +87,11 @@ struct rcu_dynticks {
84203 long long dynticks_nesting; /* Track irq/process nesting level. */
84204 /* Process level is worth LLONG_MAX/2. */
84205 int dynticks_nmi_nesting; /* Track NMI nesting level. */
84206 - atomic_t dynticks; /* Even value for idle, else odd. */
84207 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
84208 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
84209 long long dynticks_idle_nesting;
84210 /* irq/process nesting level from idle. */
84211 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
84212 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
84213 /* "Idle" excludes userspace execution. */
84214 unsigned long dynticks_idle_jiffies;
84215 /* End of last non-NMI non-idle period. */
84216 @@ -427,17 +427,17 @@ struct rcu_state {
84217 /* _rcu_barrier(). */
84218 /* End of fields guarded by barrier_mutex. */
84219
84220 - atomic_long_t expedited_start; /* Starting ticket. */
84221 - atomic_long_t expedited_done; /* Done ticket. */
84222 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
84223 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
84224 - atomic_long_t expedited_workdone1; /* # done by others #1. */
84225 - atomic_long_t expedited_workdone2; /* # done by others #2. */
84226 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
84227 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
84228 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
84229 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
84230 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
84231 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
84232 + atomic_long_t expedited_done; /* Done ticket. */
84233 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
84234 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
84235 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
84236 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
84237 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
84238 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
84239 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
84240 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
84241 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
84242
84243 unsigned long jiffies_force_qs; /* Time at which to invoke */
84244 /* force_quiescent_state(). */
84245 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
84246 index 130c97b..da2e5fc 100644
84247 --- a/kernel/rcutree_plugin.h
84248 +++ b/kernel/rcutree_plugin.h
84249 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
84250
84251 /* Clean up and exit. */
84252 smp_mb(); /* ensure expedited GP seen before counter increment. */
84253 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
84254 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
84255 unlock_mb_ret:
84256 mutex_unlock(&sync_rcu_preempt_exp_mutex);
84257 mb_ret:
84258 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
84259 free_cpumask_var(cm);
84260 }
84261
84262 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
84263 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
84264 .store = &rcu_cpu_kthread_task,
84265 .thread_should_run = rcu_cpu_kthread_should_run,
84266 .thread_fn = rcu_cpu_kthread,
84267 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
84268 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
84269 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
84270 cpu, ticks_value, ticks_title,
84271 - atomic_read(&rdtp->dynticks) & 0xfff,
84272 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
84273 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
84274 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
84275 fast_no_hz);
84276 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
84277
84278 /* Enqueue the callback on the nocb list and update counts. */
84279 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
84280 - ACCESS_ONCE(*old_rhpp) = rhp;
84281 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
84282 atomic_long_add(rhcount, &rdp->nocb_q_count);
84283 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
84284
84285 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
84286 * Extract queued callbacks, update counts, and wait
84287 * for a grace period to elapse.
84288 */
84289 - ACCESS_ONCE(rdp->nocb_head) = NULL;
84290 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
84291 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
84292 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
84293 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
84294 - ACCESS_ONCE(rdp->nocb_p_count) += c;
84295 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
84296 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
84297 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
84298 rcu_nocb_wait_gp(rdp);
84299
84300 /* Each pass through the following loop invokes a callback. */
84301 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
84302 list = next;
84303 }
84304 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
84305 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
84306 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
84307 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
84308 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
84309 rdp->n_nocbs_invoked += c;
84310 }
84311 return 0;
84312 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
84313 t = kthread_run(rcu_nocb_kthread, rdp,
84314 "rcuo%c/%d", rsp->abbr, cpu);
84315 BUG_ON(IS_ERR(t));
84316 - ACCESS_ONCE(rdp->nocb_kthread) = t;
84317 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
84318 }
84319 }
84320
84321 @@ -2425,9 +2425,9 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
84322 j = jiffies;
84323 ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
84324 smp_mb__before_atomic_inc();
84325 - atomic_inc(&rdtp->dynticks_idle);
84326 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84327 smp_mb__after_atomic_inc();
84328 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
84329 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
84330 }
84331
84332 /*
84333 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
84334
84335 /* Record end of idle period. */
84336 smp_mb__before_atomic_inc();
84337 - atomic_inc(&rdtp->dynticks_idle);
84338 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84339 smp_mb__after_atomic_inc();
84340 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
84341 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
84342
84343 /*
84344 * If we are the timekeeping CPU, we are permitted to be non-idle
84345 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
84346 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
84347
84348 /* Pick up current idle and NMI-nesting counter and check. */
84349 - cur = atomic_read(&rdtp->dynticks_idle);
84350 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
84351 if (cur & 0x1) {
84352 *isidle = false; /* We are not idle! */
84353 return;
84354 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
84355 index cf6c174..a8f4b50 100644
84356 --- a/kernel/rcutree_trace.c
84357 +++ b/kernel/rcutree_trace.c
84358 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
84359 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
84360 rdp->passed_quiesce, rdp->qs_pending);
84361 seq_printf(m, " dt=%d/%llx/%d df=%lu",
84362 - atomic_read(&rdp->dynticks->dynticks),
84363 + atomic_read_unchecked(&rdp->dynticks->dynticks),
84364 rdp->dynticks->dynticks_nesting,
84365 rdp->dynticks->dynticks_nmi_nesting,
84366 rdp->dynticks_fqs);
84367 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
84368 struct rcu_state *rsp = (struct rcu_state *)m->private;
84369
84370 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",
84371 - atomic_long_read(&rsp->expedited_start),
84372 + atomic_long_read_unchecked(&rsp->expedited_start),
84373 atomic_long_read(&rsp->expedited_done),
84374 - atomic_long_read(&rsp->expedited_wrap),
84375 - atomic_long_read(&rsp->expedited_tryfail),
84376 - atomic_long_read(&rsp->expedited_workdone1),
84377 - atomic_long_read(&rsp->expedited_workdone2),
84378 - atomic_long_read(&rsp->expedited_normal),
84379 - atomic_long_read(&rsp->expedited_stoppedcpus),
84380 - atomic_long_read(&rsp->expedited_done_tries),
84381 - atomic_long_read(&rsp->expedited_done_lost),
84382 - atomic_long_read(&rsp->expedited_done_exit));
84383 + atomic_long_read_unchecked(&rsp->expedited_wrap),
84384 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
84385 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
84386 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
84387 + atomic_long_read_unchecked(&rsp->expedited_normal),
84388 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
84389 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
84390 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
84391 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
84392 return 0;
84393 }
84394
84395 diff --git a/kernel/resource.c b/kernel/resource.c
84396 index 3f285dc..5755f62 100644
84397 --- a/kernel/resource.c
84398 +++ b/kernel/resource.c
84399 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
84400
84401 static int __init ioresources_init(void)
84402 {
84403 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84404 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84405 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
84406 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
84407 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84408 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
84409 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
84410 +#endif
84411 +#else
84412 proc_create("ioports", 0, NULL, &proc_ioports_operations);
84413 proc_create("iomem", 0, NULL, &proc_iomem_operations);
84414 +#endif
84415 return 0;
84416 }
84417 __initcall(ioresources_init);
84418 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
84419 index 1d96dd0..994ff19 100644
84420 --- a/kernel/rtmutex-tester.c
84421 +++ b/kernel/rtmutex-tester.c
84422 @@ -22,7 +22,7 @@
84423 #define MAX_RT_TEST_MUTEXES 8
84424
84425 static spinlock_t rttest_lock;
84426 -static atomic_t rttest_event;
84427 +static atomic_unchecked_t rttest_event;
84428
84429 struct test_thread_data {
84430 int opcode;
84431 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84432
84433 case RTTEST_LOCKCONT:
84434 td->mutexes[td->opdata] = 1;
84435 - td->event = atomic_add_return(1, &rttest_event);
84436 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84437 return 0;
84438
84439 case RTTEST_RESET:
84440 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84441 return 0;
84442
84443 case RTTEST_RESETEVENT:
84444 - atomic_set(&rttest_event, 0);
84445 + atomic_set_unchecked(&rttest_event, 0);
84446 return 0;
84447
84448 default:
84449 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84450 return ret;
84451
84452 td->mutexes[id] = 1;
84453 - td->event = atomic_add_return(1, &rttest_event);
84454 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84455 rt_mutex_lock(&mutexes[id]);
84456 - td->event = atomic_add_return(1, &rttest_event);
84457 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84458 td->mutexes[id] = 4;
84459 return 0;
84460
84461 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84462 return ret;
84463
84464 td->mutexes[id] = 1;
84465 - td->event = atomic_add_return(1, &rttest_event);
84466 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84467 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
84468 - td->event = atomic_add_return(1, &rttest_event);
84469 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84470 td->mutexes[id] = ret ? 0 : 4;
84471 return ret ? -EINTR : 0;
84472
84473 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84474 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
84475 return ret;
84476
84477 - td->event = atomic_add_return(1, &rttest_event);
84478 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84479 rt_mutex_unlock(&mutexes[id]);
84480 - td->event = atomic_add_return(1, &rttest_event);
84481 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84482 td->mutexes[id] = 0;
84483 return 0;
84484
84485 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84486 break;
84487
84488 td->mutexes[dat] = 2;
84489 - td->event = atomic_add_return(1, &rttest_event);
84490 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84491 break;
84492
84493 default:
84494 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84495 return;
84496
84497 td->mutexes[dat] = 3;
84498 - td->event = atomic_add_return(1, &rttest_event);
84499 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84500 break;
84501
84502 case RTTEST_LOCKNOWAIT:
84503 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84504 return;
84505
84506 td->mutexes[dat] = 1;
84507 - td->event = atomic_add_return(1, &rttest_event);
84508 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84509 return;
84510
84511 default:
84512 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
84513 index 4a07353..66b5291 100644
84514 --- a/kernel/sched/auto_group.c
84515 +++ b/kernel/sched/auto_group.c
84516 @@ -11,7 +11,7 @@
84517
84518 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
84519 static struct autogroup autogroup_default;
84520 -static atomic_t autogroup_seq_nr;
84521 +static atomic_unchecked_t autogroup_seq_nr;
84522
84523 void __init autogroup_init(struct task_struct *init_task)
84524 {
84525 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
84526
84527 kref_init(&ag->kref);
84528 init_rwsem(&ag->lock);
84529 - ag->id = atomic_inc_return(&autogroup_seq_nr);
84530 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
84531 ag->tg = tg;
84532 #ifdef CONFIG_RT_GROUP_SCHED
84533 /*
84534 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
84535 index 5ac63c9..d912786 100644
84536 --- a/kernel/sched/core.c
84537 +++ b/kernel/sched/core.c
84538 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
84539 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84540 * or number of jiffies left till timeout) if completed.
84541 */
84542 -long __sched
84543 +long __sched __intentional_overflow(-1)
84544 wait_for_completion_interruptible_timeout(struct completion *x,
84545 unsigned long timeout)
84546 {
84547 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
84548 *
84549 * Return: -ERESTARTSYS if interrupted, 0 if completed.
84550 */
84551 -int __sched wait_for_completion_killable(struct completion *x)
84552 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
84553 {
84554 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
84555 if (t == -ERESTARTSYS)
84556 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
84557 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84558 * or number of jiffies left till timeout) if completed.
84559 */
84560 -long __sched
84561 +long __sched __intentional_overflow(-1)
84562 wait_for_completion_killable_timeout(struct completion *x,
84563 unsigned long timeout)
84564 {
84565 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
84566 /* convert nice value [19,-20] to rlimit style value [1,40] */
84567 int nice_rlim = 20 - nice;
84568
84569 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
84570 +
84571 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
84572 capable(CAP_SYS_NICE));
84573 }
84574 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
84575 if (nice > 19)
84576 nice = 19;
84577
84578 - if (increment < 0 && !can_nice(current, nice))
84579 + if (increment < 0 && (!can_nice(current, nice) ||
84580 + gr_handle_chroot_nice()))
84581 return -EPERM;
84582
84583 retval = security_task_setnice(current, nice);
84584 @@ -3327,6 +3330,7 @@ recheck:
84585 unsigned long rlim_rtprio =
84586 task_rlimit(p, RLIMIT_RTPRIO);
84587
84588 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
84589 /* can't set/change the rt policy */
84590 if (policy != p->policy && !rlim_rtprio)
84591 return -EPERM;
84592 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
84593
84594 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
84595
84596 -static struct ctl_table sd_ctl_dir[] = {
84597 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
84598 {
84599 .procname = "sched_domain",
84600 .mode = 0555,
84601 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
84602 {}
84603 };
84604
84605 -static struct ctl_table *sd_alloc_ctl_entry(int n)
84606 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
84607 {
84608 - struct ctl_table *entry =
84609 + ctl_table_no_const *entry =
84610 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
84611
84612 return entry;
84613 }
84614
84615 -static void sd_free_ctl_entry(struct ctl_table **tablep)
84616 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
84617 {
84618 - struct ctl_table *entry;
84619 + ctl_table_no_const *entry;
84620
84621 /*
84622 * In the intermediate directories, both the child directory and
84623 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
84624 * will always be set. In the lowest directory the names are
84625 * static strings and all have proc handlers.
84626 */
84627 - for (entry = *tablep; entry->mode; entry++) {
84628 - if (entry->child)
84629 - sd_free_ctl_entry(&entry->child);
84630 + for (entry = tablep; entry->mode; entry++) {
84631 + if (entry->child) {
84632 + sd_free_ctl_entry(entry->child);
84633 + pax_open_kernel();
84634 + entry->child = NULL;
84635 + pax_close_kernel();
84636 + }
84637 if (entry->proc_handler == NULL)
84638 kfree(entry->procname);
84639 }
84640
84641 - kfree(*tablep);
84642 - *tablep = NULL;
84643 + kfree(tablep);
84644 }
84645
84646 static int min_load_idx = 0;
84647 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
84648
84649 static void
84650 -set_table_entry(struct ctl_table *entry,
84651 +set_table_entry(ctl_table_no_const *entry,
84652 const char *procname, void *data, int maxlen,
84653 umode_t mode, proc_handler *proc_handler,
84654 bool load_idx)
84655 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
84656 static struct ctl_table *
84657 sd_alloc_ctl_domain_table(struct sched_domain *sd)
84658 {
84659 - struct ctl_table *table = sd_alloc_ctl_entry(13);
84660 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
84661
84662 if (table == NULL)
84663 return NULL;
84664 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
84665 return table;
84666 }
84667
84668 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
84669 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
84670 {
84671 - struct ctl_table *entry, *table;
84672 + ctl_table_no_const *entry, *table;
84673 struct sched_domain *sd;
84674 int domain_num = 0, i;
84675 char buf[32];
84676 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
84677 static void register_sched_domain_sysctl(void)
84678 {
84679 int i, cpu_num = num_possible_cpus();
84680 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
84681 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
84682 char buf[32];
84683
84684 WARN_ON(sd_ctl_dir[0].child);
84685 + pax_open_kernel();
84686 sd_ctl_dir[0].child = entry;
84687 + pax_close_kernel();
84688
84689 if (entry == NULL)
84690 return;
84691 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
84692 if (sd_sysctl_header)
84693 unregister_sysctl_table(sd_sysctl_header);
84694 sd_sysctl_header = NULL;
84695 - if (sd_ctl_dir[0].child)
84696 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
84697 + if (sd_ctl_dir[0].child) {
84698 + sd_free_ctl_entry(sd_ctl_dir[0].child);
84699 + pax_open_kernel();
84700 + sd_ctl_dir[0].child = NULL;
84701 + pax_close_kernel();
84702 + }
84703 }
84704 #else
84705 static void register_sched_domain_sysctl(void)
84706 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
84707 index 7c70201..23f52b6 100644
84708 --- a/kernel/sched/fair.c
84709 +++ b/kernel/sched/fair.c
84710 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
84711
84712 static void reset_ptenuma_scan(struct task_struct *p)
84713 {
84714 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
84715 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
84716 p->mm->numa_scan_offset = 0;
84717 }
84718
84719 @@ -5838,7 +5838,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
84720 * run_rebalance_domains is triggered when needed from the scheduler tick.
84721 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
84722 */
84723 -static void run_rebalance_domains(struct softirq_action *h)
84724 +static __latent_entropy void run_rebalance_domains(void)
84725 {
84726 int this_cpu = smp_processor_id();
84727 struct rq *this_rq = cpu_rq(this_cpu);
84728 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
84729 index b3c5653..a4d192a 100644
84730 --- a/kernel/sched/sched.h
84731 +++ b/kernel/sched/sched.h
84732 @@ -1004,7 +1004,7 @@ struct sched_class {
84733 #ifdef CONFIG_FAIR_GROUP_SCHED
84734 void (*task_move_group) (struct task_struct *p, int on_rq);
84735 #endif
84736 -};
84737 +} __do_const;
84738
84739 #define sched_class_highest (&stop_sched_class)
84740 #define for_each_class(class) \
84741 diff --git a/kernel/signal.c b/kernel/signal.c
84742 index ded28b9..6886c08 100644
84743 --- a/kernel/signal.c
84744 +++ b/kernel/signal.c
84745 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
84746
84747 int print_fatal_signals __read_mostly;
84748
84749 -static void __user *sig_handler(struct task_struct *t, int sig)
84750 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
84751 {
84752 return t->sighand->action[sig - 1].sa.sa_handler;
84753 }
84754
84755 -static int sig_handler_ignored(void __user *handler, int sig)
84756 +static int sig_handler_ignored(__sighandler_t handler, int sig)
84757 {
84758 /* Is it explicitly or implicitly ignored? */
84759 return handler == SIG_IGN ||
84760 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
84761
84762 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
84763 {
84764 - void __user *handler;
84765 + __sighandler_t handler;
84766
84767 handler = sig_handler(t, sig);
84768
84769 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
84770 atomic_inc(&user->sigpending);
84771 rcu_read_unlock();
84772
84773 + if (!override_rlimit)
84774 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
84775 +
84776 if (override_rlimit ||
84777 atomic_read(&user->sigpending) <=
84778 task_rlimit(t, RLIMIT_SIGPENDING)) {
84779 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
84780
84781 int unhandled_signal(struct task_struct *tsk, int sig)
84782 {
84783 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
84784 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
84785 if (is_global_init(tsk))
84786 return 1;
84787 if (handler != SIG_IGN && handler != SIG_DFL)
84788 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
84789 }
84790 }
84791
84792 + /* allow glibc communication via tgkill to other threads in our
84793 + thread group */
84794 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
84795 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
84796 + && gr_handle_signal(t, sig))
84797 + return -EPERM;
84798 +
84799 return security_task_kill(t, info, sig, 0);
84800 }
84801
84802 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84803 return send_signal(sig, info, p, 1);
84804 }
84805
84806 -static int
84807 +int
84808 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84809 {
84810 return send_signal(sig, info, t, 0);
84811 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84812 unsigned long int flags;
84813 int ret, blocked, ignored;
84814 struct k_sigaction *action;
84815 + int is_unhandled = 0;
84816
84817 spin_lock_irqsave(&t->sighand->siglock, flags);
84818 action = &t->sighand->action[sig-1];
84819 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84820 }
84821 if (action->sa.sa_handler == SIG_DFL)
84822 t->signal->flags &= ~SIGNAL_UNKILLABLE;
84823 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
84824 + is_unhandled = 1;
84825 ret = specific_send_sig_info(sig, info, t);
84826 spin_unlock_irqrestore(&t->sighand->siglock, flags);
84827
84828 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
84829 + normal operation */
84830 + if (is_unhandled) {
84831 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
84832 + gr_handle_crash(t, sig);
84833 + }
84834 +
84835 return ret;
84836 }
84837
84838 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84839 ret = check_kill_permission(sig, info, p);
84840 rcu_read_unlock();
84841
84842 - if (!ret && sig)
84843 + if (!ret && sig) {
84844 ret = do_send_sig_info(sig, info, p, true);
84845 + if (!ret)
84846 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
84847 + }
84848
84849 return ret;
84850 }
84851 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
84852 int error = -ESRCH;
84853
84854 rcu_read_lock();
84855 - p = find_task_by_vpid(pid);
84856 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
84857 + /* allow glibc communication via tgkill to other threads in our
84858 + thread group */
84859 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
84860 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
84861 + p = find_task_by_vpid_unrestricted(pid);
84862 + else
84863 +#endif
84864 + p = find_task_by_vpid(pid);
84865 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
84866 error = check_kill_permission(sig, info, p);
84867 /*
84868 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
84869 }
84870 seg = get_fs();
84871 set_fs(KERNEL_DS);
84872 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
84873 - (stack_t __force __user *) &uoss,
84874 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
84875 + (stack_t __force_user *) &uoss,
84876 compat_user_stack_pointer());
84877 set_fs(seg);
84878 if (ret >= 0 && uoss_ptr) {
84879 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
84880 index eb89e18..a4e6792 100644
84881 --- a/kernel/smpboot.c
84882 +++ b/kernel/smpboot.c
84883 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
84884 }
84885 smpboot_unpark_thread(plug_thread, cpu);
84886 }
84887 - list_add(&plug_thread->list, &hotplug_threads);
84888 + pax_list_add(&plug_thread->list, &hotplug_threads);
84889 out:
84890 mutex_unlock(&smpboot_threads_lock);
84891 return ret;
84892 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
84893 {
84894 get_online_cpus();
84895 mutex_lock(&smpboot_threads_lock);
84896 - list_del(&plug_thread->list);
84897 + pax_list_del(&plug_thread->list);
84898 smpboot_destroy_threads(plug_thread);
84899 mutex_unlock(&smpboot_threads_lock);
84900 put_online_cpus();
84901 diff --git a/kernel/softirq.c b/kernel/softirq.c
84902 index d7d498d..94fe0f7 100644
84903 --- a/kernel/softirq.c
84904 +++ b/kernel/softirq.c
84905 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
84906 EXPORT_SYMBOL(irq_stat);
84907 #endif
84908
84909 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
84910 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
84911
84912 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
84913
84914 -char *softirq_to_name[NR_SOFTIRQS] = {
84915 +const char * const softirq_to_name[NR_SOFTIRQS] = {
84916 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
84917 "TASKLET", "SCHED", "HRTIMER", "RCU"
84918 };
84919 @@ -248,7 +248,7 @@ restart:
84920 kstat_incr_softirqs_this_cpu(vec_nr);
84921
84922 trace_softirq_entry(vec_nr);
84923 - h->action(h);
84924 + h->action();
84925 trace_softirq_exit(vec_nr);
84926 if (unlikely(prev_count != preempt_count())) {
84927 printk(KERN_ERR "huh, entered softirq %u %s %p"
84928 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
84929 or_softirq_pending(1UL << nr);
84930 }
84931
84932 -void open_softirq(int nr, void (*action)(struct softirq_action *))
84933 +void __init open_softirq(int nr, void (*action)(void))
84934 {
84935 softirq_vec[nr].action = action;
84936 }
84937 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
84938
84939 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
84940
84941 -static void tasklet_action(struct softirq_action *a)
84942 +static __latent_entropy void tasklet_action(void)
84943 {
84944 struct tasklet_struct *list;
84945
84946 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
84947 }
84948 }
84949
84950 -static void tasklet_hi_action(struct softirq_action *a)
84951 +static __latent_entropy void tasklet_hi_action(void)
84952 {
84953 struct tasklet_struct *list;
84954
84955 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
84956 .notifier_call = cpu_callback
84957 };
84958
84959 -static struct smp_hotplug_thread softirq_threads = {
84960 +static struct smp_hotplug_thread softirq_threads __read_only = {
84961 .store = &ksoftirqd,
84962 .thread_should_run = ksoftirqd_should_run,
84963 .thread_fn = run_ksoftirqd,
84964 diff --git a/kernel/srcu.c b/kernel/srcu.c
84965 index 01d5ccb..cdcbee6 100644
84966 --- a/kernel/srcu.c
84967 +++ b/kernel/srcu.c
84968 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
84969
84970 idx = ACCESS_ONCE(sp->completed) & 0x1;
84971 preempt_disable();
84972 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84973 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84974 smp_mb(); /* B */ /* Avoid leaking the critical section. */
84975 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84976 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84977 preempt_enable();
84978 return idx;
84979 }
84980 diff --git a/kernel/sys.c b/kernel/sys.c
84981 index c18ecca..b3c2dd2 100644
84982 --- a/kernel/sys.c
84983 +++ b/kernel/sys.c
84984 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
84985 error = -EACCES;
84986 goto out;
84987 }
84988 +
84989 + if (gr_handle_chroot_setpriority(p, niceval)) {
84990 + error = -EACCES;
84991 + goto out;
84992 + }
84993 +
84994 no_nice = security_task_setnice(p, niceval);
84995 if (no_nice) {
84996 error = no_nice;
84997 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
84998 goto error;
84999 }
85000
85001 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
85002 + goto error;
85003 +
85004 if (rgid != (gid_t) -1 ||
85005 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
85006 new->sgid = new->egid;
85007 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
85008 old = current_cred();
85009
85010 retval = -EPERM;
85011 +
85012 + if (gr_check_group_change(kgid, kgid, kgid))
85013 + goto error;
85014 +
85015 if (ns_capable(old->user_ns, CAP_SETGID))
85016 new->gid = new->egid = new->sgid = new->fsgid = kgid;
85017 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
85018 @@ -404,7 +417,7 @@ error:
85019 /*
85020 * change the user struct in a credentials set to match the new UID
85021 */
85022 -static int set_user(struct cred *new)
85023 +int set_user(struct cred *new)
85024 {
85025 struct user_struct *new_user;
85026
85027 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
85028 goto error;
85029 }
85030
85031 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
85032 + goto error;
85033 +
85034 if (!uid_eq(new->uid, old->uid)) {
85035 retval = set_user(new);
85036 if (retval < 0)
85037 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
85038 old = current_cred();
85039
85040 retval = -EPERM;
85041 +
85042 + if (gr_check_crash_uid(kuid))
85043 + goto error;
85044 + if (gr_check_user_change(kuid, kuid, kuid))
85045 + goto error;
85046 +
85047 if (ns_capable(old->user_ns, CAP_SETUID)) {
85048 new->suid = new->uid = kuid;
85049 if (!uid_eq(kuid, old->uid)) {
85050 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
85051 goto error;
85052 }
85053
85054 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
85055 + goto error;
85056 +
85057 if (ruid != (uid_t) -1) {
85058 new->uid = kruid;
85059 if (!uid_eq(kruid, old->uid)) {
85060 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
85061 goto error;
85062 }
85063
85064 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
85065 + goto error;
85066 +
85067 if (rgid != (gid_t) -1)
85068 new->gid = krgid;
85069 if (egid != (gid_t) -1)
85070 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
85071 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
85072 ns_capable(old->user_ns, CAP_SETUID)) {
85073 if (!uid_eq(kuid, old->fsuid)) {
85074 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
85075 + goto error;
85076 +
85077 new->fsuid = kuid;
85078 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
85079 goto change_okay;
85080 }
85081 }
85082
85083 +error:
85084 abort_creds(new);
85085 return old_fsuid;
85086
85087 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
85088 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
85089 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
85090 ns_capable(old->user_ns, CAP_SETGID)) {
85091 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
85092 + goto error;
85093 +
85094 if (!gid_eq(kgid, old->fsgid)) {
85095 new->fsgid = kgid;
85096 goto change_okay;
85097 }
85098 }
85099
85100 +error:
85101 abort_creds(new);
85102 return old_fsgid;
85103
85104 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
85105 return -EFAULT;
85106
85107 down_read(&uts_sem);
85108 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
85109 + error = __copy_to_user(name->sysname, &utsname()->sysname,
85110 __OLD_UTS_LEN);
85111 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
85112 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
85113 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
85114 __OLD_UTS_LEN);
85115 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
85116 - error |= __copy_to_user(&name->release, &utsname()->release,
85117 + error |= __copy_to_user(name->release, &utsname()->release,
85118 __OLD_UTS_LEN);
85119 error |= __put_user(0, name->release + __OLD_UTS_LEN);
85120 - error |= __copy_to_user(&name->version, &utsname()->version,
85121 + error |= __copy_to_user(name->version, &utsname()->version,
85122 __OLD_UTS_LEN);
85123 error |= __put_user(0, name->version + __OLD_UTS_LEN);
85124 - error |= __copy_to_user(&name->machine, &utsname()->machine,
85125 + error |= __copy_to_user(name->machine, &utsname()->machine,
85126 __OLD_UTS_LEN);
85127 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
85128 up_read(&uts_sem);
85129 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
85130 */
85131 new_rlim->rlim_cur = 1;
85132 }
85133 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
85134 + is changed to a lower value. Since tasks can be created by the same
85135 + user in between this limit change and an execve by this task, force
85136 + a recheck only for this task by setting PF_NPROC_EXCEEDED
85137 + */
85138 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
85139 + tsk->flags |= PF_NPROC_EXCEEDED;
85140 }
85141 if (!retval) {
85142 if (old_rlim)
85143 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
85144 index b2f06f3..e6354ab 100644
85145 --- a/kernel/sysctl.c
85146 +++ b/kernel/sysctl.c
85147 @@ -93,7 +93,6 @@
85148
85149
85150 #if defined(CONFIG_SYSCTL)
85151 -
85152 /* External variables not in a header file. */
85153 extern int sysctl_overcommit_memory;
85154 extern int sysctl_overcommit_ratio;
85155 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
85156
85157 /* Constants used for minimum and maximum */
85158 #ifdef CONFIG_LOCKUP_DETECTOR
85159 -static int sixty = 60;
85160 +static int sixty __read_only = 60;
85161 #endif
85162
85163 -static int zero;
85164 -static int __maybe_unused one = 1;
85165 -static int __maybe_unused two = 2;
85166 -static int __maybe_unused three = 3;
85167 -static unsigned long one_ul = 1;
85168 -static int one_hundred = 100;
85169 +static int neg_one __read_only = -1;
85170 +static int zero __read_only = 0;
85171 +static int __maybe_unused one __read_only = 1;
85172 +static int __maybe_unused two __read_only = 2;
85173 +static int __maybe_unused three __read_only = 3;
85174 +static unsigned long one_ul __read_only = 1;
85175 +static int one_hundred __read_only = 100;
85176 #ifdef CONFIG_PRINTK
85177 -static int ten_thousand = 10000;
85178 +static int ten_thousand __read_only = 10000;
85179 #endif
85180
85181 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
85182 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
85183 void __user *buffer, size_t *lenp, loff_t *ppos);
85184 #endif
85185
85186 -#ifdef CONFIG_PRINTK
85187 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85188 void __user *buffer, size_t *lenp, loff_t *ppos);
85189 -#endif
85190
85191 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
85192 void __user *buffer, size_t *lenp, loff_t *ppos);
85193 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
85194
85195 #endif
85196
85197 +extern struct ctl_table grsecurity_table[];
85198 +
85199 static struct ctl_table kern_table[];
85200 static struct ctl_table vm_table[];
85201 static struct ctl_table fs_table[];
85202 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
85203 int sysctl_legacy_va_layout;
85204 #endif
85205
85206 +#ifdef CONFIG_PAX_SOFTMODE
85207 +static ctl_table pax_table[] = {
85208 + {
85209 + .procname = "softmode",
85210 + .data = &pax_softmode,
85211 + .maxlen = sizeof(unsigned int),
85212 + .mode = 0600,
85213 + .proc_handler = &proc_dointvec,
85214 + },
85215 +
85216 + { }
85217 +};
85218 +#endif
85219 +
85220 /* The default sysctl tables: */
85221
85222 static struct ctl_table sysctl_base_table[] = {
85223 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
85224 #endif
85225
85226 static struct ctl_table kern_table[] = {
85227 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
85228 + {
85229 + .procname = "grsecurity",
85230 + .mode = 0500,
85231 + .child = grsecurity_table,
85232 + },
85233 +#endif
85234 +
85235 +#ifdef CONFIG_PAX_SOFTMODE
85236 + {
85237 + .procname = "pax",
85238 + .mode = 0500,
85239 + .child = pax_table,
85240 + },
85241 +#endif
85242 +
85243 {
85244 .procname = "sched_child_runs_first",
85245 .data = &sysctl_sched_child_runs_first,
85246 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
85247 .data = &modprobe_path,
85248 .maxlen = KMOD_PATH_LEN,
85249 .mode = 0644,
85250 - .proc_handler = proc_dostring,
85251 + .proc_handler = proc_dostring_modpriv,
85252 },
85253 {
85254 .procname = "modules_disabled",
85255 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
85256 .extra1 = &zero,
85257 .extra2 = &one,
85258 },
85259 +#endif
85260 {
85261 .procname = "kptr_restrict",
85262 .data = &kptr_restrict,
85263 .maxlen = sizeof(int),
85264 .mode = 0644,
85265 .proc_handler = proc_dointvec_minmax_sysadmin,
85266 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85267 + .extra1 = &two,
85268 +#else
85269 .extra1 = &zero,
85270 +#endif
85271 .extra2 = &two,
85272 },
85273 -#endif
85274 {
85275 .procname = "ngroups_max",
85276 .data = &ngroups_max,
85277 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
85278 */
85279 {
85280 .procname = "perf_event_paranoid",
85281 - .data = &sysctl_perf_event_paranoid,
85282 - .maxlen = sizeof(sysctl_perf_event_paranoid),
85283 + .data = &sysctl_perf_event_legitimately_concerned,
85284 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
85285 .mode = 0644,
85286 - .proc_handler = proc_dointvec,
85287 + /* go ahead, be a hero */
85288 + .proc_handler = proc_dointvec_minmax_sysadmin,
85289 + .extra1 = &neg_one,
85290 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85291 + .extra2 = &three,
85292 +#else
85293 + .extra2 = &two,
85294 +#endif
85295 },
85296 {
85297 .procname = "perf_event_mlock_kb",
85298 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
85299 .proc_handler = proc_dointvec_minmax,
85300 .extra1 = &zero,
85301 },
85302 + {
85303 + .procname = "heap_stack_gap",
85304 + .data = &sysctl_heap_stack_gap,
85305 + .maxlen = sizeof(sysctl_heap_stack_gap),
85306 + .mode = 0644,
85307 + .proc_handler = proc_doulongvec_minmax,
85308 + },
85309 #else
85310 {
85311 .procname = "nr_trim_pages",
85312 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
85313 buffer, lenp, ppos);
85314 }
85315
85316 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85317 + void __user *buffer, size_t *lenp, loff_t *ppos)
85318 +{
85319 + if (write && !capable(CAP_SYS_MODULE))
85320 + return -EPERM;
85321 +
85322 + return _proc_do_string(table->data, table->maxlen, write,
85323 + buffer, lenp, ppos);
85324 +}
85325 +
85326 static size_t proc_skip_spaces(char **buf)
85327 {
85328 size_t ret;
85329 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
85330 len = strlen(tmp);
85331 if (len > *size)
85332 len = *size;
85333 + if (len > sizeof(tmp))
85334 + len = sizeof(tmp);
85335 if (copy_to_user(*buf, tmp, len))
85336 return -EFAULT;
85337 *size -= len;
85338 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
85339 static int proc_taint(struct ctl_table *table, int write,
85340 void __user *buffer, size_t *lenp, loff_t *ppos)
85341 {
85342 - struct ctl_table t;
85343 + ctl_table_no_const t;
85344 unsigned long tmptaint = get_taint();
85345 int err;
85346
85347 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
85348 return err;
85349 }
85350
85351 -#ifdef CONFIG_PRINTK
85352 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85353 void __user *buffer, size_t *lenp, loff_t *ppos)
85354 {
85355 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85356
85357 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
85358 }
85359 -#endif
85360
85361 struct do_proc_dointvec_minmax_conv_param {
85362 int *min;
85363 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
85364 *i = val;
85365 } else {
85366 val = convdiv * (*i) / convmul;
85367 - if (!first)
85368 + if (!first) {
85369 err = proc_put_char(&buffer, &left, '\t');
85370 + if (err)
85371 + break;
85372 + }
85373 err = proc_put_long(&buffer, &left, val, false);
85374 if (err)
85375 break;
85376 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
85377 return -ENOSYS;
85378 }
85379
85380 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85381 + void __user *buffer, size_t *lenp, loff_t *ppos)
85382 +{
85383 + return -ENOSYS;
85384 +}
85385 +
85386 int proc_dointvec(struct ctl_table *table, int write,
85387 void __user *buffer, size_t *lenp, loff_t *ppos)
85388 {
85389 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
85390 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
85391 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
85392 EXPORT_SYMBOL(proc_dostring);
85393 +EXPORT_SYMBOL(proc_dostring_modpriv);
85394 EXPORT_SYMBOL(proc_doulongvec_minmax);
85395 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
85396 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
85397 index 145bb4d..b2aa969 100644
85398 --- a/kernel/taskstats.c
85399 +++ b/kernel/taskstats.c
85400 @@ -28,9 +28,12 @@
85401 #include <linux/fs.h>
85402 #include <linux/file.h>
85403 #include <linux/pid_namespace.h>
85404 +#include <linux/grsecurity.h>
85405 #include <net/genetlink.h>
85406 #include <linux/atomic.h>
85407
85408 +extern int gr_is_taskstats_denied(int pid);
85409 +
85410 /*
85411 * Maximum length of a cpumask that can be specified in
85412 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
85413 @@ -570,6 +573,9 @@ err:
85414
85415 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
85416 {
85417 + if (gr_is_taskstats_denied(current->pid))
85418 + return -EACCES;
85419 +
85420 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
85421 return cmd_attr_register_cpumask(info);
85422 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
85423 diff --git a/kernel/time.c b/kernel/time.c
85424 index 7c7964c..2a0d412 100644
85425 --- a/kernel/time.c
85426 +++ b/kernel/time.c
85427 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
85428 return error;
85429
85430 if (tz) {
85431 + /* we log in do_settimeofday called below, so don't log twice
85432 + */
85433 + if (!tv)
85434 + gr_log_timechange();
85435 +
85436 sys_tz = *tz;
85437 update_vsyscall_tz();
85438 if (firsttime) {
85439 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
85440 index eec50fc..65e5df6 100644
85441 --- a/kernel/time/alarmtimer.c
85442 +++ b/kernel/time/alarmtimer.c
85443 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
85444 struct platform_device *pdev;
85445 int error = 0;
85446 int i;
85447 - struct k_clock alarm_clock = {
85448 + static struct k_clock alarm_clock = {
85449 .clock_getres = alarm_clock_getres,
85450 .clock_get = alarm_clock_get,
85451 .timer_create = alarm_timer_create,
85452 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
85453 index 947ba25..20cbade 100644
85454 --- a/kernel/time/timekeeping.c
85455 +++ b/kernel/time/timekeeping.c
85456 @@ -15,6 +15,7 @@
85457 #include <linux/init.h>
85458 #include <linux/mm.h>
85459 #include <linux/sched.h>
85460 +#include <linux/grsecurity.h>
85461 #include <linux/syscore_ops.h>
85462 #include <linux/clocksource.h>
85463 #include <linux/jiffies.h>
85464 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
85465 if (!timespec_valid_strict(tv))
85466 return -EINVAL;
85467
85468 + gr_log_timechange();
85469 +
85470 raw_spin_lock_irqsave(&timekeeper_lock, flags);
85471 write_seqcount_begin(&timekeeper_seq);
85472
85473 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
85474 index 61ed862..3b52c65 100644
85475 --- a/kernel/time/timer_list.c
85476 +++ b/kernel/time/timer_list.c
85477 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
85478
85479 static void print_name_offset(struct seq_file *m, void *sym)
85480 {
85481 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85482 + SEQ_printf(m, "<%p>", NULL);
85483 +#else
85484 char symname[KSYM_NAME_LEN];
85485
85486 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
85487 SEQ_printf(m, "<%pK>", sym);
85488 else
85489 SEQ_printf(m, "%s", symname);
85490 +#endif
85491 }
85492
85493 static void
85494 @@ -119,7 +123,11 @@ next_one:
85495 static void
85496 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
85497 {
85498 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85499 + SEQ_printf(m, " .base: %p\n", NULL);
85500 +#else
85501 SEQ_printf(m, " .base: %pK\n", base);
85502 +#endif
85503 SEQ_printf(m, " .index: %d\n",
85504 base->index);
85505 SEQ_printf(m, " .resolution: %Lu nsecs\n",
85506 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
85507 {
85508 struct proc_dir_entry *pe;
85509
85510 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85511 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
85512 +#else
85513 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
85514 +#endif
85515 if (!pe)
85516 return -ENOMEM;
85517 return 0;
85518 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
85519 index 0b537f2..40d6c20 100644
85520 --- a/kernel/time/timer_stats.c
85521 +++ b/kernel/time/timer_stats.c
85522 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
85523 static unsigned long nr_entries;
85524 static struct entry entries[MAX_ENTRIES];
85525
85526 -static atomic_t overflow_count;
85527 +static atomic_unchecked_t overflow_count;
85528
85529 /*
85530 * The entries are in a hash-table, for fast lookup:
85531 @@ -140,7 +140,7 @@ static void reset_entries(void)
85532 nr_entries = 0;
85533 memset(entries, 0, sizeof(entries));
85534 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
85535 - atomic_set(&overflow_count, 0);
85536 + atomic_set_unchecked(&overflow_count, 0);
85537 }
85538
85539 static struct entry *alloc_entry(void)
85540 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85541 if (likely(entry))
85542 entry->count++;
85543 else
85544 - atomic_inc(&overflow_count);
85545 + atomic_inc_unchecked(&overflow_count);
85546
85547 out_unlock:
85548 raw_spin_unlock_irqrestore(lock, flags);
85549 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85550
85551 static void print_name_offset(struct seq_file *m, unsigned long addr)
85552 {
85553 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85554 + seq_printf(m, "<%p>", NULL);
85555 +#else
85556 char symname[KSYM_NAME_LEN];
85557
85558 if (lookup_symbol_name(addr, symname) < 0)
85559 - seq_printf(m, "<%p>", (void *)addr);
85560 + seq_printf(m, "<%pK>", (void *)addr);
85561 else
85562 seq_printf(m, "%s", symname);
85563 +#endif
85564 }
85565
85566 static int tstats_show(struct seq_file *m, void *v)
85567 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
85568
85569 seq_puts(m, "Timer Stats Version: v0.2\n");
85570 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
85571 - if (atomic_read(&overflow_count))
85572 + if (atomic_read_unchecked(&overflow_count))
85573 seq_printf(m, "Overflow: %d entries\n",
85574 - atomic_read(&overflow_count));
85575 + atomic_read_unchecked(&overflow_count));
85576
85577 for (i = 0; i < nr_entries; i++) {
85578 entry = entries + i;
85579 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
85580 {
85581 struct proc_dir_entry *pe;
85582
85583 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85584 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
85585 +#else
85586 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
85587 +#endif
85588 if (!pe)
85589 return -ENOMEM;
85590 return 0;
85591 diff --git a/kernel/timer.c b/kernel/timer.c
85592 index 4296d13..0164b04 100644
85593 --- a/kernel/timer.c
85594 +++ b/kernel/timer.c
85595 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
85596 /*
85597 * This function runs timers and the timer-tq in bottom half context.
85598 */
85599 -static void run_timer_softirq(struct softirq_action *h)
85600 +static __latent_entropy void run_timer_softirq(void)
85601 {
85602 struct tvec_base *base = __this_cpu_read(tvec_bases);
85603
85604 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
85605 *
85606 * In all cases the return value is guaranteed to be non-negative.
85607 */
85608 -signed long __sched schedule_timeout(signed long timeout)
85609 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
85610 {
85611 struct timer_list timer;
85612 unsigned long expire;
85613 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
85614 index b8b8560..75b1a09 100644
85615 --- a/kernel/trace/blktrace.c
85616 +++ b/kernel/trace/blktrace.c
85617 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
85618 struct blk_trace *bt = filp->private_data;
85619 char buf[16];
85620
85621 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
85622 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
85623
85624 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
85625 }
85626 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
85627 return 1;
85628
85629 bt = buf->chan->private_data;
85630 - atomic_inc(&bt->dropped);
85631 + atomic_inc_unchecked(&bt->dropped);
85632 return 0;
85633 }
85634
85635 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
85636
85637 bt->dir = dir;
85638 bt->dev = dev;
85639 - atomic_set(&bt->dropped, 0);
85640 + atomic_set_unchecked(&bt->dropped, 0);
85641
85642 ret = -EIO;
85643 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
85644 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
85645 index 03cf44a..3051c64 100644
85646 --- a/kernel/trace/ftrace.c
85647 +++ b/kernel/trace/ftrace.c
85648 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
85649 if (unlikely(ftrace_disabled))
85650 return 0;
85651
85652 + ret = ftrace_arch_code_modify_prepare();
85653 + FTRACE_WARN_ON(ret);
85654 + if (ret)
85655 + return 0;
85656 +
85657 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
85658 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
85659 if (ret) {
85660 ftrace_bug(ret, ip);
85661 - return 0;
85662 }
85663 - return 1;
85664 + return ret ? 0 : 1;
85665 }
85666
85667 /*
85668 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
85669 if (!count)
85670 return 0;
85671
85672 + pax_open_kernel();
85673 sort(start, count, sizeof(*start),
85674 ftrace_cmp_ips, ftrace_swap_ips);
85675 + pax_close_kernel();
85676
85677 start_pg = ftrace_allocate_pages(count);
85678 if (!start_pg)
85679 @@ -4767,8 +4774,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
85680 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
85681
85682 static int ftrace_graph_active;
85683 -static struct notifier_block ftrace_suspend_notifier;
85684 -
85685 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
85686 {
85687 return 0;
85688 @@ -4912,6 +4917,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
85689 return NOTIFY_DONE;
85690 }
85691
85692 +static struct notifier_block ftrace_suspend_notifier = {
85693 + .notifier_call = ftrace_suspend_notifier_call
85694 +};
85695 +
85696 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85697 trace_func_graph_ent_t entryfunc)
85698 {
85699 @@ -4925,7 +4934,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85700 goto out;
85701 }
85702
85703 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
85704 register_pm_notifier(&ftrace_suspend_notifier);
85705
85706 ftrace_graph_active++;
85707 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
85708 index cc2f66f..05edd54 100644
85709 --- a/kernel/trace/ring_buffer.c
85710 +++ b/kernel/trace/ring_buffer.c
85711 @@ -352,9 +352,9 @@ struct buffer_data_page {
85712 */
85713 struct buffer_page {
85714 struct list_head list; /* list of buffer pages */
85715 - local_t write; /* index for next write */
85716 + local_unchecked_t write; /* index for next write */
85717 unsigned read; /* index for next read */
85718 - local_t entries; /* entries on this page */
85719 + local_unchecked_t entries; /* entries on this page */
85720 unsigned long real_end; /* real end of data */
85721 struct buffer_data_page *page; /* Actual data page */
85722 };
85723 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
85724 unsigned long last_overrun;
85725 local_t entries_bytes;
85726 local_t entries;
85727 - local_t overrun;
85728 - local_t commit_overrun;
85729 + local_unchecked_t overrun;
85730 + local_unchecked_t commit_overrun;
85731 local_t dropped_events;
85732 local_t committing;
85733 local_t commits;
85734 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85735 *
85736 * We add a counter to the write field to denote this.
85737 */
85738 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
85739 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
85740 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
85741 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
85742
85743 /*
85744 * Just make sure we have seen our old_write and synchronize
85745 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85746 * cmpxchg to only update if an interrupt did not already
85747 * do it for us. If the cmpxchg fails, we don't care.
85748 */
85749 - (void)local_cmpxchg(&next_page->write, old_write, val);
85750 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
85751 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
85752 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
85753
85754 /*
85755 * No need to worry about races with clearing out the commit.
85756 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
85757
85758 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
85759 {
85760 - return local_read(&bpage->entries) & RB_WRITE_MASK;
85761 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
85762 }
85763
85764 static inline unsigned long rb_page_write(struct buffer_page *bpage)
85765 {
85766 - return local_read(&bpage->write) & RB_WRITE_MASK;
85767 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
85768 }
85769
85770 static int
85771 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
85772 * bytes consumed in ring buffer from here.
85773 * Increment overrun to account for the lost events.
85774 */
85775 - local_add(page_entries, &cpu_buffer->overrun);
85776 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
85777 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85778 }
85779
85780 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
85781 * it is our responsibility to update
85782 * the counters.
85783 */
85784 - local_add(entries, &cpu_buffer->overrun);
85785 + local_add_unchecked(entries, &cpu_buffer->overrun);
85786 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85787
85788 /*
85789 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85790 if (tail == BUF_PAGE_SIZE)
85791 tail_page->real_end = 0;
85792
85793 - local_sub(length, &tail_page->write);
85794 + local_sub_unchecked(length, &tail_page->write);
85795 return;
85796 }
85797
85798 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85799 rb_event_set_padding(event);
85800
85801 /* Set the write back to the previous setting */
85802 - local_sub(length, &tail_page->write);
85803 + local_sub_unchecked(length, &tail_page->write);
85804 return;
85805 }
85806
85807 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85808
85809 /* Set write to end of buffer */
85810 length = (tail + length) - BUF_PAGE_SIZE;
85811 - local_sub(length, &tail_page->write);
85812 + local_sub_unchecked(length, &tail_page->write);
85813 }
85814
85815 /*
85816 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85817 * about it.
85818 */
85819 if (unlikely(next_page == commit_page)) {
85820 - local_inc(&cpu_buffer->commit_overrun);
85821 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85822 goto out_reset;
85823 }
85824
85825 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85826 cpu_buffer->tail_page) &&
85827 (cpu_buffer->commit_page ==
85828 cpu_buffer->reader_page))) {
85829 - local_inc(&cpu_buffer->commit_overrun);
85830 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85831 goto out_reset;
85832 }
85833 }
85834 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85835 length += RB_LEN_TIME_EXTEND;
85836
85837 tail_page = cpu_buffer->tail_page;
85838 - write = local_add_return(length, &tail_page->write);
85839 + write = local_add_return_unchecked(length, &tail_page->write);
85840
85841 /* set write to only the index of the write */
85842 write &= RB_WRITE_MASK;
85843 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85844 kmemcheck_annotate_bitfield(event, bitfield);
85845 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
85846
85847 - local_inc(&tail_page->entries);
85848 + local_inc_unchecked(&tail_page->entries);
85849
85850 /*
85851 * If this is the first commit on the page, then update
85852 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85853
85854 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
85855 unsigned long write_mask =
85856 - local_read(&bpage->write) & ~RB_WRITE_MASK;
85857 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
85858 unsigned long event_length = rb_event_length(event);
85859 /*
85860 * This is on the tail page. It is possible that
85861 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85862 */
85863 old_index += write_mask;
85864 new_index += write_mask;
85865 - index = local_cmpxchg(&bpage->write, old_index, new_index);
85866 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
85867 if (index == old_index) {
85868 /* update counters */
85869 local_sub(event_length, &cpu_buffer->entries_bytes);
85870 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85871
85872 /* Do the likely case first */
85873 if (likely(bpage->page == (void *)addr)) {
85874 - local_dec(&bpage->entries);
85875 + local_dec_unchecked(&bpage->entries);
85876 return;
85877 }
85878
85879 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85880 start = bpage;
85881 do {
85882 if (bpage->page == (void *)addr) {
85883 - local_dec(&bpage->entries);
85884 + local_dec_unchecked(&bpage->entries);
85885 return;
85886 }
85887 rb_inc_page(cpu_buffer, &bpage);
85888 @@ -3139,7 +3139,7 @@ static inline unsigned long
85889 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
85890 {
85891 return local_read(&cpu_buffer->entries) -
85892 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
85893 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
85894 }
85895
85896 /**
85897 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
85898 return 0;
85899
85900 cpu_buffer = buffer->buffers[cpu];
85901 - ret = local_read(&cpu_buffer->overrun);
85902 + ret = local_read_unchecked(&cpu_buffer->overrun);
85903
85904 return ret;
85905 }
85906 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
85907 return 0;
85908
85909 cpu_buffer = buffer->buffers[cpu];
85910 - ret = local_read(&cpu_buffer->commit_overrun);
85911 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
85912
85913 return ret;
85914 }
85915 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
85916 /* if you care about this being correct, lock the buffer */
85917 for_each_buffer_cpu(buffer, cpu) {
85918 cpu_buffer = buffer->buffers[cpu];
85919 - overruns += local_read(&cpu_buffer->overrun);
85920 + overruns += local_read_unchecked(&cpu_buffer->overrun);
85921 }
85922
85923 return overruns;
85924 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85925 /*
85926 * Reset the reader page to size zero.
85927 */
85928 - local_set(&cpu_buffer->reader_page->write, 0);
85929 - local_set(&cpu_buffer->reader_page->entries, 0);
85930 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85931 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85932 local_set(&cpu_buffer->reader_page->page->commit, 0);
85933 cpu_buffer->reader_page->real_end = 0;
85934
85935 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85936 * want to compare with the last_overrun.
85937 */
85938 smp_mb();
85939 - overwrite = local_read(&(cpu_buffer->overrun));
85940 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
85941
85942 /*
85943 * Here's the tricky part.
85944 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85945
85946 cpu_buffer->head_page
85947 = list_entry(cpu_buffer->pages, struct buffer_page, list);
85948 - local_set(&cpu_buffer->head_page->write, 0);
85949 - local_set(&cpu_buffer->head_page->entries, 0);
85950 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
85951 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
85952 local_set(&cpu_buffer->head_page->page->commit, 0);
85953
85954 cpu_buffer->head_page->read = 0;
85955 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85956
85957 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
85958 INIT_LIST_HEAD(&cpu_buffer->new_pages);
85959 - local_set(&cpu_buffer->reader_page->write, 0);
85960 - local_set(&cpu_buffer->reader_page->entries, 0);
85961 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85962 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85963 local_set(&cpu_buffer->reader_page->page->commit, 0);
85964 cpu_buffer->reader_page->read = 0;
85965
85966 local_set(&cpu_buffer->entries_bytes, 0);
85967 - local_set(&cpu_buffer->overrun, 0);
85968 - local_set(&cpu_buffer->commit_overrun, 0);
85969 + local_set_unchecked(&cpu_buffer->overrun, 0);
85970 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
85971 local_set(&cpu_buffer->dropped_events, 0);
85972 local_set(&cpu_buffer->entries, 0);
85973 local_set(&cpu_buffer->committing, 0);
85974 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
85975 rb_init_page(bpage);
85976 bpage = reader->page;
85977 reader->page = *data_page;
85978 - local_set(&reader->write, 0);
85979 - local_set(&reader->entries, 0);
85980 + local_set_unchecked(&reader->write, 0);
85981 + local_set_unchecked(&reader->entries, 0);
85982 reader->read = 0;
85983 *data_page = bpage;
85984
85985 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
85986 index b778e96..4e84621 100644
85987 --- a/kernel/trace/trace.c
85988 +++ b/kernel/trace/trace.c
85989 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
85990 return 0;
85991 }
85992
85993 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
85994 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
85995 {
85996 /* do nothing if flag is already set */
85997 if (!!(trace_flags & mask) == !!enabled)
85998 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
85999 index 10c86fb..645ab0a 100644
86000 --- a/kernel/trace/trace.h
86001 +++ b/kernel/trace/trace.h
86002 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
86003 void trace_printk_init_buffers(void);
86004 void trace_printk_start_comm(void);
86005 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
86006 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
86007 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
86008
86009 /*
86010 * Normal trace_printk() and friends allocates special buffers
86011 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
86012 index 26dc348..8708ca7 100644
86013 --- a/kernel/trace/trace_clock.c
86014 +++ b/kernel/trace/trace_clock.c
86015 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
86016 return now;
86017 }
86018
86019 -static atomic64_t trace_counter;
86020 +static atomic64_unchecked_t trace_counter;
86021
86022 /*
86023 * trace_clock_counter(): simply an atomic counter.
86024 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
86025 */
86026 u64 notrace trace_clock_counter(void)
86027 {
86028 - return atomic64_add_return(1, &trace_counter);
86029 + return atomic64_inc_return_unchecked(&trace_counter);
86030 }
86031 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
86032 index 368a4d5..7b6d1d5 100644
86033 --- a/kernel/trace/trace_events.c
86034 +++ b/kernel/trace/trace_events.c
86035 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
86036 return 0;
86037 }
86038
86039 -struct ftrace_module_file_ops;
86040 static void __add_event_to_tracers(struct ftrace_event_call *call);
86041
86042 /* Add an additional event_call dynamically */
86043 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
86044 index b3dcfb2..ebee344 100644
86045 --- a/kernel/trace/trace_mmiotrace.c
86046 +++ b/kernel/trace/trace_mmiotrace.c
86047 @@ -24,7 +24,7 @@ struct header_iter {
86048 static struct trace_array *mmio_trace_array;
86049 static bool overrun_detected;
86050 static unsigned long prev_overruns;
86051 -static atomic_t dropped_count;
86052 +static atomic_unchecked_t dropped_count;
86053
86054 static void mmio_reset_data(struct trace_array *tr)
86055 {
86056 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
86057
86058 static unsigned long count_overruns(struct trace_iterator *iter)
86059 {
86060 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
86061 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
86062 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
86063
86064 if (over > prev_overruns)
86065 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
86066 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
86067 sizeof(*entry), 0, pc);
86068 if (!event) {
86069 - atomic_inc(&dropped_count);
86070 + atomic_inc_unchecked(&dropped_count);
86071 return;
86072 }
86073 entry = ring_buffer_event_data(event);
86074 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
86075 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
86076 sizeof(*entry), 0, pc);
86077 if (!event) {
86078 - atomic_inc(&dropped_count);
86079 + atomic_inc_unchecked(&dropped_count);
86080 return;
86081 }
86082 entry = ring_buffer_event_data(event);
86083 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
86084 index 34e7cba..6f9a729 100644
86085 --- a/kernel/trace/trace_output.c
86086 +++ b/kernel/trace/trace_output.c
86087 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
86088
86089 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
86090 if (!IS_ERR(p)) {
86091 - p = mangle_path(s->buffer + s->len, p, "\n");
86092 + p = mangle_path(s->buffer + s->len, p, "\n\\");
86093 if (p) {
86094 s->len = p - s->buffer;
86095 return 1;
86096 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
86097 goto out;
86098 }
86099
86100 + pax_open_kernel();
86101 if (event->funcs->trace == NULL)
86102 - event->funcs->trace = trace_nop_print;
86103 + *(void **)&event->funcs->trace = trace_nop_print;
86104 if (event->funcs->raw == NULL)
86105 - event->funcs->raw = trace_nop_print;
86106 + *(void **)&event->funcs->raw = trace_nop_print;
86107 if (event->funcs->hex == NULL)
86108 - event->funcs->hex = trace_nop_print;
86109 + *(void **)&event->funcs->hex = trace_nop_print;
86110 if (event->funcs->binary == NULL)
86111 - event->funcs->binary = trace_nop_print;
86112 + *(void **)&event->funcs->binary = trace_nop_print;
86113 + pax_close_kernel();
86114
86115 key = event->type & (EVENT_HASHSIZE - 1);
86116
86117 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
86118 index b20428c..4845a10 100644
86119 --- a/kernel/trace/trace_stack.c
86120 +++ b/kernel/trace/trace_stack.c
86121 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
86122 return;
86123
86124 /* we do not handle interrupt stacks yet */
86125 - if (!object_is_on_stack(stack))
86126 + if (!object_starts_on_stack(stack))
86127 return;
86128
86129 local_irq_save(flags);
86130 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
86131 index 13fb113..a6ced3f 100644
86132 --- a/kernel/user_namespace.c
86133 +++ b/kernel/user_namespace.c
86134 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
86135 !kgid_has_mapping(parent_ns, group))
86136 return -EPERM;
86137
86138 +#ifdef CONFIG_GRKERNSEC
86139 + /*
86140 + * This doesn't really inspire confidence:
86141 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
86142 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
86143 + * Increases kernel attack surface in areas developers
86144 + * previously cared little about ("low importance due
86145 + * to requiring "root" capability")
86146 + * To be removed when this code receives *proper* review
86147 + */
86148 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
86149 + !capable(CAP_SETGID))
86150 + return -EPERM;
86151 +#endif
86152 +
86153 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
86154 if (!ns)
86155 return -ENOMEM;
86156 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
86157 if (atomic_read(&current->mm->mm_users) > 1)
86158 return -EINVAL;
86159
86160 - if (current->fs->users != 1)
86161 + if (atomic_read(&current->fs->users) != 1)
86162 return -EINVAL;
86163
86164 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
86165 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
86166 index 4f69f9a..7c6f8f8 100644
86167 --- a/kernel/utsname_sysctl.c
86168 +++ b/kernel/utsname_sysctl.c
86169 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
86170 static int proc_do_uts_string(ctl_table *table, int write,
86171 void __user *buffer, size_t *lenp, loff_t *ppos)
86172 {
86173 - struct ctl_table uts_table;
86174 + ctl_table_no_const uts_table;
86175 int r;
86176 memcpy(&uts_table, table, sizeof(uts_table));
86177 uts_table.data = get_uts(table, write);
86178 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
86179 index 4431610..4265616 100644
86180 --- a/kernel/watchdog.c
86181 +++ b/kernel/watchdog.c
86182 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
86183 static void watchdog_nmi_disable(unsigned int cpu) { return; }
86184 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
86185
86186 -static struct smp_hotplug_thread watchdog_threads = {
86187 +static struct smp_hotplug_thread watchdog_threads __read_only = {
86188 .store = &softlockup_watchdog,
86189 .thread_should_run = watchdog_should_run,
86190 .thread_fn = watchdog,
86191 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
86192 index 987293d..60b3043 100644
86193 --- a/kernel/workqueue.c
86194 +++ b/kernel/workqueue.c
86195 @@ -4658,7 +4658,7 @@ static void rebind_workers(struct worker_pool *pool)
86196 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
86197 worker_flags |= WORKER_REBOUND;
86198 worker_flags &= ~WORKER_UNBOUND;
86199 - ACCESS_ONCE(worker->flags) = worker_flags;
86200 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
86201 }
86202
86203 spin_unlock_irq(&pool->lock);
86204 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
86205 index 094f315..244a824 100644
86206 --- a/lib/Kconfig.debug
86207 +++ b/lib/Kconfig.debug
86208 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
86209
86210 config DEBUG_WW_MUTEX_SLOWPATH
86211 bool "Wait/wound mutex debugging: Slowpath testing"
86212 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86213 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86214 select DEBUG_LOCK_ALLOC
86215 select DEBUG_SPINLOCK
86216 select DEBUG_MUTEXES
86217 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
86218
86219 config DEBUG_LOCK_ALLOC
86220 bool "Lock debugging: detect incorrect freeing of live locks"
86221 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86222 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86223 select DEBUG_SPINLOCK
86224 select DEBUG_MUTEXES
86225 select LOCKDEP
86226 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
86227
86228 config PROVE_LOCKING
86229 bool "Lock debugging: prove locking correctness"
86230 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86231 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86232 select LOCKDEP
86233 select DEBUG_SPINLOCK
86234 select DEBUG_MUTEXES
86235 @@ -914,7 +914,7 @@ config LOCKDEP
86236
86237 config LOCK_STAT
86238 bool "Lock usage statistics"
86239 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86240 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86241 select LOCKDEP
86242 select DEBUG_SPINLOCK
86243 select DEBUG_MUTEXES
86244 @@ -1376,6 +1376,7 @@ config LATENCYTOP
86245 depends on DEBUG_KERNEL
86246 depends on STACKTRACE_SUPPORT
86247 depends on PROC_FS
86248 + depends on !GRKERNSEC_HIDESYM
86249 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
86250 select KALLSYMS
86251 select KALLSYMS_ALL
86252 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86253 config DEBUG_STRICT_USER_COPY_CHECKS
86254 bool "Strict user copy size checks"
86255 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86256 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
86257 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
86258 help
86259 Enabling this option turns a certain set of sanity checks for user
86260 copy operations into compile time failures.
86261 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
86262
86263 config PROVIDE_OHCI1394_DMA_INIT
86264 bool "Remote debugging over FireWire early on boot"
86265 - depends on PCI && X86
86266 + depends on PCI && X86 && !GRKERNSEC
86267 help
86268 If you want to debug problems which hang or crash the kernel early
86269 on boot and the crashing machine has a FireWire port, you can use
86270 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
86271
86272 config FIREWIRE_OHCI_REMOTE_DMA
86273 bool "Remote debugging over FireWire with firewire-ohci"
86274 - depends on FIREWIRE_OHCI
86275 + depends on FIREWIRE_OHCI && !GRKERNSEC
86276 help
86277 This option lets you use the FireWire bus for remote debugging
86278 with help of the firewire-ohci driver. It enables unfiltered
86279 diff --git a/lib/Makefile b/lib/Makefile
86280 index f3bb2cb..b358ace 100644
86281 --- a/lib/Makefile
86282 +++ b/lib/Makefile
86283 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
86284
86285 obj-$(CONFIG_BTREE) += btree.o
86286 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
86287 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
86288 +obj-y += list_debug.o
86289 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
86290
86291 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
86292 diff --git a/lib/bitmap.c b/lib/bitmap.c
86293 index 06f7e4f..f3cf2b0 100644
86294 --- a/lib/bitmap.c
86295 +++ b/lib/bitmap.c
86296 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
86297 {
86298 int c, old_c, totaldigits, ndigits, nchunks, nbits;
86299 u32 chunk;
86300 - const char __user __force *ubuf = (const char __user __force *)buf;
86301 + const char __user *ubuf = (const char __force_user *)buf;
86302
86303 bitmap_zero(maskp, nmaskbits);
86304
86305 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
86306 {
86307 if (!access_ok(VERIFY_READ, ubuf, ulen))
86308 return -EFAULT;
86309 - return __bitmap_parse((const char __force *)ubuf,
86310 + return __bitmap_parse((const char __force_kernel *)ubuf,
86311 ulen, 1, maskp, nmaskbits);
86312
86313 }
86314 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
86315 {
86316 unsigned a, b;
86317 int c, old_c, totaldigits;
86318 - const char __user __force *ubuf = (const char __user __force *)buf;
86319 + const char __user *ubuf = (const char __force_user *)buf;
86320 int exp_digit, in_range;
86321
86322 totaldigits = c = 0;
86323 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
86324 {
86325 if (!access_ok(VERIFY_READ, ubuf, ulen))
86326 return -EFAULT;
86327 - return __bitmap_parselist((const char __force *)ubuf,
86328 + return __bitmap_parselist((const char __force_kernel *)ubuf,
86329 ulen, 1, maskp, nmaskbits);
86330 }
86331 EXPORT_SYMBOL(bitmap_parselist_user);
86332 diff --git a/lib/bug.c b/lib/bug.c
86333 index 1686034..a9c00c8 100644
86334 --- a/lib/bug.c
86335 +++ b/lib/bug.c
86336 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
86337 return BUG_TRAP_TYPE_NONE;
86338
86339 bug = find_bug(bugaddr);
86340 + if (!bug)
86341 + return BUG_TRAP_TYPE_NONE;
86342
86343 file = NULL;
86344 line = 0;
86345 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
86346 index bf2c8b1..1d00ccf 100644
86347 --- a/lib/debugobjects.c
86348 +++ b/lib/debugobjects.c
86349 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
86350 if (limit > 4)
86351 return;
86352
86353 - is_on_stack = object_is_on_stack(addr);
86354 + is_on_stack = object_starts_on_stack(addr);
86355 if (is_on_stack == onstack)
86356 return;
86357
86358 diff --git a/lib/devres.c b/lib/devres.c
86359 index 8235331..5881053 100644
86360 --- a/lib/devres.c
86361 +++ b/lib/devres.c
86362 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
86363 void devm_iounmap(struct device *dev, void __iomem *addr)
86364 {
86365 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
86366 - (void *)addr));
86367 + (void __force *)addr));
86368 iounmap(addr);
86369 }
86370 EXPORT_SYMBOL(devm_iounmap);
86371 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
86372 {
86373 ioport_unmap(addr);
86374 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
86375 - devm_ioport_map_match, (void *)addr));
86376 + devm_ioport_map_match, (void __force *)addr));
86377 }
86378 EXPORT_SYMBOL(devm_ioport_unmap);
86379 #endif /* CONFIG_HAS_IOPORT */
86380 diff --git a/lib/div64.c b/lib/div64.c
86381 index 4382ad7..08aa558 100644
86382 --- a/lib/div64.c
86383 +++ b/lib/div64.c
86384 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
86385 EXPORT_SYMBOL(__div64_32);
86386
86387 #ifndef div_s64_rem
86388 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86389 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86390 {
86391 u64 quotient;
86392
86393 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
86394 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
86395 */
86396 #ifndef div64_u64
86397 -u64 div64_u64(u64 dividend, u64 divisor)
86398 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
86399 {
86400 u32 high = divisor >> 32;
86401 u64 quot;
86402 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
86403 index d87a17a..ac0d79a 100644
86404 --- a/lib/dma-debug.c
86405 +++ b/lib/dma-debug.c
86406 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
86407
86408 void dma_debug_add_bus(struct bus_type *bus)
86409 {
86410 - struct notifier_block *nb;
86411 + notifier_block_no_const *nb;
86412
86413 if (global_disable)
86414 return;
86415 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
86416
86417 static void check_for_stack(struct device *dev, void *addr)
86418 {
86419 - if (object_is_on_stack(addr))
86420 + if (object_starts_on_stack(addr))
86421 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
86422 "stack [addr=%p]\n", addr);
86423 }
86424 diff --git a/lib/inflate.c b/lib/inflate.c
86425 index 013a761..c28f3fc 100644
86426 --- a/lib/inflate.c
86427 +++ b/lib/inflate.c
86428 @@ -269,7 +269,7 @@ static void free(void *where)
86429 malloc_ptr = free_mem_ptr;
86430 }
86431 #else
86432 -#define malloc(a) kmalloc(a, GFP_KERNEL)
86433 +#define malloc(a) kmalloc((a), GFP_KERNEL)
86434 #define free(a) kfree(a)
86435 #endif
86436
86437 diff --git a/lib/ioremap.c b/lib/ioremap.c
86438 index 0c9216c..863bd89 100644
86439 --- a/lib/ioremap.c
86440 +++ b/lib/ioremap.c
86441 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
86442 unsigned long next;
86443
86444 phys_addr -= addr;
86445 - pmd = pmd_alloc(&init_mm, pud, addr);
86446 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86447 if (!pmd)
86448 return -ENOMEM;
86449 do {
86450 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
86451 unsigned long next;
86452
86453 phys_addr -= addr;
86454 - pud = pud_alloc(&init_mm, pgd, addr);
86455 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86456 if (!pud)
86457 return -ENOMEM;
86458 do {
86459 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
86460 index bd2bea9..6b3c95e 100644
86461 --- a/lib/is_single_threaded.c
86462 +++ b/lib/is_single_threaded.c
86463 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
86464 struct task_struct *p, *t;
86465 bool ret;
86466
86467 + if (!mm)
86468 + return true;
86469 +
86470 if (atomic_read(&task->signal->live) != 1)
86471 return false;
86472
86473 diff --git a/lib/kobject.c b/lib/kobject.c
86474 index 084f7b1..d265b8a 100644
86475 --- a/lib/kobject.c
86476 +++ b/lib/kobject.c
86477 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
86478
86479
86480 static DEFINE_SPINLOCK(kobj_ns_type_lock);
86481 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
86482 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
86483
86484 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86485 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86486 {
86487 enum kobj_ns_type type = ops->type;
86488 int error;
86489 diff --git a/lib/list_debug.c b/lib/list_debug.c
86490 index c24c2f7..f0296f4 100644
86491 --- a/lib/list_debug.c
86492 +++ b/lib/list_debug.c
86493 @@ -11,7 +11,9 @@
86494 #include <linux/bug.h>
86495 #include <linux/kernel.h>
86496 #include <linux/rculist.h>
86497 +#include <linux/mm.h>
86498
86499 +#ifdef CONFIG_DEBUG_LIST
86500 /*
86501 * Insert a new entry between two known consecutive entries.
86502 *
86503 @@ -19,21 +21,40 @@
86504 * the prev/next entries already!
86505 */
86506
86507 +static bool __list_add_debug(struct list_head *new,
86508 + struct list_head *prev,
86509 + struct list_head *next)
86510 +{
86511 + if (unlikely(next->prev != prev)) {
86512 + printk(KERN_ERR "list_add corruption. next->prev should be "
86513 + "prev (%p), but was %p. (next=%p).\n",
86514 + prev, next->prev, next);
86515 + BUG();
86516 + return false;
86517 + }
86518 + if (unlikely(prev->next != next)) {
86519 + printk(KERN_ERR "list_add corruption. prev->next should be "
86520 + "next (%p), but was %p. (prev=%p).\n",
86521 + next, prev->next, prev);
86522 + BUG();
86523 + return false;
86524 + }
86525 + if (unlikely(new == prev || new == next)) {
86526 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
86527 + new, prev, next);
86528 + BUG();
86529 + return false;
86530 + }
86531 + return true;
86532 +}
86533 +
86534 void __list_add(struct list_head *new,
86535 - struct list_head *prev,
86536 - struct list_head *next)
86537 + struct list_head *prev,
86538 + struct list_head *next)
86539 {
86540 - WARN(next->prev != prev,
86541 - "list_add corruption. next->prev should be "
86542 - "prev (%p), but was %p. (next=%p).\n",
86543 - prev, next->prev, next);
86544 - WARN(prev->next != next,
86545 - "list_add corruption. prev->next should be "
86546 - "next (%p), but was %p. (prev=%p).\n",
86547 - next, prev->next, prev);
86548 - WARN(new == prev || new == next,
86549 - "list_add double add: new=%p, prev=%p, next=%p.\n",
86550 - new, prev, next);
86551 + if (!__list_add_debug(new, prev, next))
86552 + return;
86553 +
86554 next->prev = new;
86555 new->next = next;
86556 new->prev = prev;
86557 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
86558 }
86559 EXPORT_SYMBOL(__list_add);
86560
86561 -void __list_del_entry(struct list_head *entry)
86562 +static bool __list_del_entry_debug(struct list_head *entry)
86563 {
86564 struct list_head *prev, *next;
86565
86566 prev = entry->prev;
86567 next = entry->next;
86568
86569 - if (WARN(next == LIST_POISON1,
86570 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86571 - entry, LIST_POISON1) ||
86572 - WARN(prev == LIST_POISON2,
86573 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86574 - entry, LIST_POISON2) ||
86575 - WARN(prev->next != entry,
86576 - "list_del corruption. prev->next should be %p, "
86577 - "but was %p\n", entry, prev->next) ||
86578 - WARN(next->prev != entry,
86579 - "list_del corruption. next->prev should be %p, "
86580 - "but was %p\n", entry, next->prev))
86581 + if (unlikely(next == LIST_POISON1)) {
86582 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86583 + entry, LIST_POISON1);
86584 + BUG();
86585 + return false;
86586 + }
86587 + if (unlikely(prev == LIST_POISON2)) {
86588 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86589 + entry, LIST_POISON2);
86590 + BUG();
86591 + return false;
86592 + }
86593 + if (unlikely(entry->prev->next != entry)) {
86594 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
86595 + "but was %p\n", entry, prev->next);
86596 + BUG();
86597 + return false;
86598 + }
86599 + if (unlikely(entry->next->prev != entry)) {
86600 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
86601 + "but was %p\n", entry, next->prev);
86602 + BUG();
86603 + return false;
86604 + }
86605 + return true;
86606 +}
86607 +
86608 +void __list_del_entry(struct list_head *entry)
86609 +{
86610 + if (!__list_del_entry_debug(entry))
86611 return;
86612
86613 - __list_del(prev, next);
86614 + __list_del(entry->prev, entry->next);
86615 }
86616 EXPORT_SYMBOL(__list_del_entry);
86617
86618 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
86619 void __list_add_rcu(struct list_head *new,
86620 struct list_head *prev, struct list_head *next)
86621 {
86622 - WARN(next->prev != prev,
86623 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
86624 - prev, next->prev, next);
86625 - WARN(prev->next != next,
86626 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
86627 - next, prev->next, prev);
86628 + if (!__list_add_debug(new, prev, next))
86629 + return;
86630 +
86631 new->next = next;
86632 new->prev = prev;
86633 rcu_assign_pointer(list_next_rcu(prev), new);
86634 next->prev = new;
86635 }
86636 EXPORT_SYMBOL(__list_add_rcu);
86637 +#endif
86638 +
86639 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
86640 +{
86641 +#ifdef CONFIG_DEBUG_LIST
86642 + if (!__list_add_debug(new, prev, next))
86643 + return;
86644 +#endif
86645 +
86646 + pax_open_kernel();
86647 + next->prev = new;
86648 + new->next = next;
86649 + new->prev = prev;
86650 + prev->next = new;
86651 + pax_close_kernel();
86652 +}
86653 +EXPORT_SYMBOL(__pax_list_add);
86654 +
86655 +void pax_list_del(struct list_head *entry)
86656 +{
86657 +#ifdef CONFIG_DEBUG_LIST
86658 + if (!__list_del_entry_debug(entry))
86659 + return;
86660 +#endif
86661 +
86662 + pax_open_kernel();
86663 + __list_del(entry->prev, entry->next);
86664 + entry->next = LIST_POISON1;
86665 + entry->prev = LIST_POISON2;
86666 + pax_close_kernel();
86667 +}
86668 +EXPORT_SYMBOL(pax_list_del);
86669 +
86670 +void pax_list_del_init(struct list_head *entry)
86671 +{
86672 + pax_open_kernel();
86673 + __list_del(entry->prev, entry->next);
86674 + INIT_LIST_HEAD(entry);
86675 + pax_close_kernel();
86676 +}
86677 +EXPORT_SYMBOL(pax_list_del_init);
86678 +
86679 +void __pax_list_add_rcu(struct list_head *new,
86680 + struct list_head *prev, struct list_head *next)
86681 +{
86682 +#ifdef CONFIG_DEBUG_LIST
86683 + if (!__list_add_debug(new, prev, next))
86684 + return;
86685 +#endif
86686 +
86687 + pax_open_kernel();
86688 + new->next = next;
86689 + new->prev = prev;
86690 + rcu_assign_pointer(list_next_rcu(prev), new);
86691 + next->prev = new;
86692 + pax_close_kernel();
86693 +}
86694 +EXPORT_SYMBOL(__pax_list_add_rcu);
86695 +
86696 +void pax_list_del_rcu(struct list_head *entry)
86697 +{
86698 +#ifdef CONFIG_DEBUG_LIST
86699 + if (!__list_del_entry_debug(entry))
86700 + return;
86701 +#endif
86702 +
86703 + pax_open_kernel();
86704 + __list_del(entry->prev, entry->next);
86705 + entry->next = LIST_POISON1;
86706 + entry->prev = LIST_POISON2;
86707 + pax_close_kernel();
86708 +}
86709 +EXPORT_SYMBOL(pax_list_del_rcu);
86710 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
86711 index 1a53d49..ace934c 100644
86712 --- a/lib/percpu-refcount.c
86713 +++ b/lib/percpu-refcount.c
86714 @@ -29,7 +29,7 @@
86715 * can't hit 0 before we've added up all the percpu refs.
86716 */
86717
86718 -#define PCPU_COUNT_BIAS (1U << 31)
86719 +#define PCPU_COUNT_BIAS (1U << 30)
86720
86721 /**
86722 * percpu_ref_init - initialize a percpu refcount
86723 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
86724 index 7811ed3..f80ca19 100644
86725 --- a/lib/radix-tree.c
86726 +++ b/lib/radix-tree.c
86727 @@ -93,7 +93,7 @@ struct radix_tree_preload {
86728 int nr;
86729 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
86730 };
86731 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
86732 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
86733
86734 static inline void *ptr_to_indirect(void *ptr)
86735 {
86736 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
86737 index bb2b201..46abaf9 100644
86738 --- a/lib/strncpy_from_user.c
86739 +++ b/lib/strncpy_from_user.c
86740 @@ -21,7 +21,7 @@
86741 */
86742 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
86743 {
86744 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86745 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86746 long res = 0;
86747
86748 /*
86749 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
86750 index a28df52..3d55877 100644
86751 --- a/lib/strnlen_user.c
86752 +++ b/lib/strnlen_user.c
86753 @@ -26,7 +26,7 @@
86754 */
86755 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
86756 {
86757 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86758 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86759 long align, res = 0;
86760 unsigned long c;
86761
86762 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
86763 index 4e8686c..3e8c92f 100644
86764 --- a/lib/swiotlb.c
86765 +++ b/lib/swiotlb.c
86766 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
86767
86768 void
86769 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
86770 - dma_addr_t dev_addr)
86771 + dma_addr_t dev_addr, struct dma_attrs *attrs)
86772 {
86773 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
86774
86775 diff --git a/lib/usercopy.c b/lib/usercopy.c
86776 index 4f5b1dd..7cab418 100644
86777 --- a/lib/usercopy.c
86778 +++ b/lib/usercopy.c
86779 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
86780 WARN(1, "Buffer overflow detected!\n");
86781 }
86782 EXPORT_SYMBOL(copy_from_user_overflow);
86783 +
86784 +void copy_to_user_overflow(void)
86785 +{
86786 + WARN(1, "Buffer overflow detected!\n");
86787 +}
86788 +EXPORT_SYMBOL(copy_to_user_overflow);
86789 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
86790 index 26559bd..ed614df 100644
86791 --- a/lib/vsprintf.c
86792 +++ b/lib/vsprintf.c
86793 @@ -16,6 +16,9 @@
86794 * - scnprintf and vscnprintf
86795 */
86796
86797 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86798 +#define __INCLUDED_BY_HIDESYM 1
86799 +#endif
86800 #include <stdarg.h>
86801 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
86802 #include <linux/types.h>
86803 @@ -1154,7 +1157,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
86804 return number(buf, end, *(const netdev_features_t *)addr, spec);
86805 }
86806
86807 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86808 +int kptr_restrict __read_mostly = 2;
86809 +#else
86810 int kptr_restrict __read_mostly;
86811 +#endif
86812
86813 /*
86814 * Show a '%p' thing. A kernel extension is that the '%p' is followed
86815 @@ -1167,6 +1174,7 @@ int kptr_restrict __read_mostly;
86816 * - 'f' For simple symbolic function names without offset
86817 * - 'S' For symbolic direct pointers with offset
86818 * - 's' For symbolic direct pointers without offset
86819 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
86820 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
86821 * - 'B' For backtraced symbolic direct pointers with offset
86822 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
86823 @@ -1231,12 +1239,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86824
86825 if (!ptr && *fmt != 'K') {
86826 /*
86827 - * Print (null) with the same width as a pointer so it makes
86828 + * Print (nil) with the same width as a pointer so it makes
86829 * tabular output look nice.
86830 */
86831 if (spec.field_width == -1)
86832 spec.field_width = default_width;
86833 - return string(buf, end, "(null)", spec);
86834 + return string(buf, end, "(nil)", spec);
86835 }
86836
86837 switch (*fmt) {
86838 @@ -1246,6 +1254,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86839 /* Fallthrough */
86840 case 'S':
86841 case 's':
86842 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86843 + break;
86844 +#else
86845 + return symbol_string(buf, end, ptr, spec, fmt);
86846 +#endif
86847 + case 'A':
86848 case 'B':
86849 return symbol_string(buf, end, ptr, spec, fmt);
86850 case 'R':
86851 @@ -1301,6 +1315,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86852 va_end(va);
86853 return buf;
86854 }
86855 + case 'P':
86856 + break;
86857 case 'K':
86858 /*
86859 * %pK cannot be used in IRQ context because its test
86860 @@ -1336,6 +1352,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86861 ((const struct file *)ptr)->f_path.dentry,
86862 spec, fmt);
86863 }
86864 +
86865 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86866 + /* 'P' = approved pointers to copy to userland,
86867 + as in the /proc/kallsyms case, as we make it display nothing
86868 + for non-root users, and the real contents for root users
86869 + Also ignore 'K' pointers, since we force their NULLing for non-root users
86870 + above
86871 + */
86872 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
86873 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
86874 + dump_stack();
86875 + ptr = NULL;
86876 + }
86877 +#endif
86878 +
86879 spec.flags |= SMALL;
86880 if (spec.field_width == -1) {
86881 spec.field_width = default_width;
86882 @@ -2059,11 +2090,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86883 typeof(type) value; \
86884 if (sizeof(type) == 8) { \
86885 args = PTR_ALIGN(args, sizeof(u32)); \
86886 - *(u32 *)&value = *(u32 *)args; \
86887 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
86888 + *(u32 *)&value = *(const u32 *)args; \
86889 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
86890 } else { \
86891 args = PTR_ALIGN(args, sizeof(type)); \
86892 - value = *(typeof(type) *)args; \
86893 + value = *(const typeof(type) *)args; \
86894 } \
86895 args += sizeof(type); \
86896 value; \
86897 @@ -2126,7 +2157,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86898 case FORMAT_TYPE_STR: {
86899 const char *str_arg = args;
86900 args += strlen(str_arg) + 1;
86901 - str = string(str, end, (char *)str_arg, spec);
86902 + str = string(str, end, str_arg, spec);
86903 break;
86904 }
86905
86906 diff --git a/localversion-grsec b/localversion-grsec
86907 new file mode 100644
86908 index 0000000..7cd6065
86909 --- /dev/null
86910 +++ b/localversion-grsec
86911 @@ -0,0 +1 @@
86912 +-grsec
86913 diff --git a/mm/Kconfig b/mm/Kconfig
86914 index 394838f..0e5f816 100644
86915 --- a/mm/Kconfig
86916 +++ b/mm/Kconfig
86917 @@ -317,10 +317,11 @@ config KSM
86918 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
86919
86920 config DEFAULT_MMAP_MIN_ADDR
86921 - int "Low address space to protect from user allocation"
86922 + int "Low address space to protect from user allocation"
86923 depends on MMU
86924 - default 4096
86925 - help
86926 + default 32768 if ALPHA || ARM || PARISC || SPARC32
86927 + default 65536
86928 + help
86929 This is the portion of low virtual memory which should be protected
86930 from userspace allocation. Keeping a user from writing to low pages
86931 can help reduce the impact of kernel NULL pointer bugs.
86932 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
86933
86934 config HWPOISON_INJECT
86935 tristate "HWPoison pages injector"
86936 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
86937 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
86938 select PROC_PAGE_MONITOR
86939
86940 config NOMMU_INITIAL_TRIM_EXCESS
86941 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
86942 index ce682f7..1fb54f9 100644
86943 --- a/mm/backing-dev.c
86944 +++ b/mm/backing-dev.c
86945 @@ -12,7 +12,7 @@
86946 #include <linux/device.h>
86947 #include <trace/events/writeback.h>
86948
86949 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
86950 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
86951
86952 struct backing_dev_info default_backing_dev_info = {
86953 .name = "default",
86954 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
86955 return err;
86956
86957 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
86958 - atomic_long_inc_return(&bdi_seq));
86959 + atomic_long_inc_return_unchecked(&bdi_seq));
86960 if (err) {
86961 bdi_destroy(bdi);
86962 return err;
86963 diff --git a/mm/filemap.c b/mm/filemap.c
86964 index ae4846f..b0acebe 100644
86965 --- a/mm/filemap.c
86966 +++ b/mm/filemap.c
86967 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
86968 struct address_space *mapping = file->f_mapping;
86969
86970 if (!mapping->a_ops->readpage)
86971 - return -ENOEXEC;
86972 + return -ENODEV;
86973 file_accessed(file);
86974 vma->vm_ops = &generic_file_vm_ops;
86975 return 0;
86976 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
86977
86978 while (bytes) {
86979 char __user *buf = iov->iov_base + base;
86980 - int copy = min(bytes, iov->iov_len - base);
86981 + size_t copy = min(bytes, iov->iov_len - base);
86982
86983 base = 0;
86984 left = __copy_from_user_inatomic(vaddr, buf, copy);
86985 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
86986 BUG_ON(!in_atomic());
86987 kaddr = kmap_atomic(page);
86988 if (likely(i->nr_segs == 1)) {
86989 - int left;
86990 + size_t left;
86991 char __user *buf = i->iov->iov_base + i->iov_offset;
86992 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
86993 copied = bytes - left;
86994 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
86995
86996 kaddr = kmap(page);
86997 if (likely(i->nr_segs == 1)) {
86998 - int left;
86999 + size_t left;
87000 char __user *buf = i->iov->iov_base + i->iov_offset;
87001 left = __copy_from_user(kaddr + offset, buf, bytes);
87002 copied = bytes - left;
87003 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
87004 * zero-length segments (without overruning the iovec).
87005 */
87006 while (bytes || unlikely(i->count && !iov->iov_len)) {
87007 - int copy;
87008 + size_t copy;
87009
87010 copy = min(bytes, iov->iov_len - base);
87011 BUG_ON(!i->count || i->count < copy);
87012 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
87013 *pos = i_size_read(inode);
87014
87015 if (limit != RLIM_INFINITY) {
87016 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
87017 if (*pos >= limit) {
87018 send_sig(SIGXFSZ, current, 0);
87019 return -EFBIG;
87020 diff --git a/mm/fremap.c b/mm/fremap.c
87021 index 5bff081..d8189a9 100644
87022 --- a/mm/fremap.c
87023 +++ b/mm/fremap.c
87024 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
87025 retry:
87026 vma = find_vma(mm, start);
87027
87028 +#ifdef CONFIG_PAX_SEGMEXEC
87029 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
87030 + goto out;
87031 +#endif
87032 +
87033 /*
87034 * Make sure the vma is shared, that it supports prefaulting,
87035 * and that the remapped range is valid and fully within
87036 diff --git a/mm/highmem.c b/mm/highmem.c
87037 index b32b70c..e512eb0 100644
87038 --- a/mm/highmem.c
87039 +++ b/mm/highmem.c
87040 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
87041 * So no dangers, even with speculative execution.
87042 */
87043 page = pte_page(pkmap_page_table[i]);
87044 + pax_open_kernel();
87045 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
87046 -
87047 + pax_close_kernel();
87048 set_page_address(page, NULL);
87049 need_flush = 1;
87050 }
87051 @@ -198,9 +199,11 @@ start:
87052 }
87053 }
87054 vaddr = PKMAP_ADDR(last_pkmap_nr);
87055 +
87056 + pax_open_kernel();
87057 set_pte_at(&init_mm, vaddr,
87058 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
87059 -
87060 + pax_close_kernel();
87061 pkmap_count[last_pkmap_nr] = 1;
87062 set_page_address(page, (void *)vaddr);
87063
87064 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
87065 index 0b7656e..d21cefc 100644
87066 --- a/mm/hugetlb.c
87067 +++ b/mm/hugetlb.c
87068 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
87069 struct hstate *h = &default_hstate;
87070 unsigned long tmp;
87071 int ret;
87072 + ctl_table_no_const hugetlb_table;
87073
87074 tmp = h->max_huge_pages;
87075
87076 if (write && h->order >= MAX_ORDER)
87077 return -EINVAL;
87078
87079 - table->data = &tmp;
87080 - table->maxlen = sizeof(unsigned long);
87081 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87082 + hugetlb_table = *table;
87083 + hugetlb_table.data = &tmp;
87084 + hugetlb_table.maxlen = sizeof(unsigned long);
87085 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87086 if (ret)
87087 goto out;
87088
87089 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
87090 struct hstate *h = &default_hstate;
87091 unsigned long tmp;
87092 int ret;
87093 + ctl_table_no_const hugetlb_table;
87094
87095 tmp = h->nr_overcommit_huge_pages;
87096
87097 if (write && h->order >= MAX_ORDER)
87098 return -EINVAL;
87099
87100 - table->data = &tmp;
87101 - table->maxlen = sizeof(unsigned long);
87102 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87103 + hugetlb_table = *table;
87104 + hugetlb_table.data = &tmp;
87105 + hugetlb_table.maxlen = sizeof(unsigned long);
87106 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87107 if (ret)
87108 goto out;
87109
87110 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
87111 return 1;
87112 }
87113
87114 +#ifdef CONFIG_PAX_SEGMEXEC
87115 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
87116 +{
87117 + struct mm_struct *mm = vma->vm_mm;
87118 + struct vm_area_struct *vma_m;
87119 + unsigned long address_m;
87120 + pte_t *ptep_m;
87121 +
87122 + vma_m = pax_find_mirror_vma(vma);
87123 + if (!vma_m)
87124 + return;
87125 +
87126 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87127 + address_m = address + SEGMEXEC_TASK_SIZE;
87128 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
87129 + get_page(page_m);
87130 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
87131 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
87132 +}
87133 +#endif
87134 +
87135 /*
87136 * Hugetlb_cow() should be called with page lock of the original hugepage held.
87137 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
87138 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
87139 make_huge_pte(vma, new_page, 1));
87140 page_remove_rmap(old_page);
87141 hugepage_add_new_anon_rmap(new_page, vma, address);
87142 +
87143 +#ifdef CONFIG_PAX_SEGMEXEC
87144 + pax_mirror_huge_pte(vma, address, new_page);
87145 +#endif
87146 +
87147 /* Make the old page be freed below */
87148 new_page = old_page;
87149 }
87150 @@ -2883,6 +2913,10 @@ retry:
87151 && (vma->vm_flags & VM_SHARED)));
87152 set_huge_pte_at(mm, address, ptep, new_pte);
87153
87154 +#ifdef CONFIG_PAX_SEGMEXEC
87155 + pax_mirror_huge_pte(vma, address, page);
87156 +#endif
87157 +
87158 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
87159 /* Optimization, do the COW without a second fault */
87160 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
87161 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87162 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
87163 struct hstate *h = hstate_vma(vma);
87164
87165 +#ifdef CONFIG_PAX_SEGMEXEC
87166 + struct vm_area_struct *vma_m;
87167 +#endif
87168 +
87169 address &= huge_page_mask(h);
87170
87171 ptep = huge_pte_offset(mm, address);
87172 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87173 VM_FAULT_SET_HINDEX(hstate_index(h));
87174 }
87175
87176 +#ifdef CONFIG_PAX_SEGMEXEC
87177 + vma_m = pax_find_mirror_vma(vma);
87178 + if (vma_m) {
87179 + unsigned long address_m;
87180 +
87181 + if (vma->vm_start > vma_m->vm_start) {
87182 + address_m = address;
87183 + address -= SEGMEXEC_TASK_SIZE;
87184 + vma = vma_m;
87185 + h = hstate_vma(vma);
87186 + } else
87187 + address_m = address + SEGMEXEC_TASK_SIZE;
87188 +
87189 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
87190 + return VM_FAULT_OOM;
87191 + address_m &= HPAGE_MASK;
87192 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
87193 + }
87194 +#endif
87195 +
87196 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
87197 if (!ptep)
87198 return VM_FAULT_OOM;
87199 diff --git a/mm/internal.h b/mm/internal.h
87200 index 684f7aa..9eb9edc 100644
87201 --- a/mm/internal.h
87202 +++ b/mm/internal.h
87203 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
87204 * in mm/page_alloc.c
87205 */
87206 extern void __free_pages_bootmem(struct page *page, unsigned int order);
87207 +extern void free_compound_page(struct page *page);
87208 extern void prep_compound_page(struct page *page, unsigned long order);
87209 #ifdef CONFIG_MEMORY_FAILURE
87210 extern bool is_free_buddy_page(struct page *page);
87211 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
87212
87213 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
87214 unsigned long, unsigned long,
87215 - unsigned long, unsigned long);
87216 + unsigned long, unsigned long) __intentional_overflow(-1);
87217
87218 extern void set_pageblock_order(void);
87219 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
87220 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
87221 index e126b0e..e986018 100644
87222 --- a/mm/kmemleak.c
87223 +++ b/mm/kmemleak.c
87224 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
87225
87226 for (i = 0; i < object->trace_len; i++) {
87227 void *ptr = (void *)object->trace[i];
87228 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
87229 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
87230 }
87231 }
87232
87233 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
87234 return -ENOMEM;
87235 }
87236
87237 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
87238 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
87239 &kmemleak_fops);
87240 if (!dentry)
87241 pr_warning("Failed to create the debugfs kmemleak file\n");
87242 diff --git a/mm/maccess.c b/mm/maccess.c
87243 index d53adf9..03a24bf 100644
87244 --- a/mm/maccess.c
87245 +++ b/mm/maccess.c
87246 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
87247 set_fs(KERNEL_DS);
87248 pagefault_disable();
87249 ret = __copy_from_user_inatomic(dst,
87250 - (__force const void __user *)src, size);
87251 + (const void __force_user *)src, size);
87252 pagefault_enable();
87253 set_fs(old_fs);
87254
87255 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
87256
87257 set_fs(KERNEL_DS);
87258 pagefault_disable();
87259 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
87260 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
87261 pagefault_enable();
87262 set_fs(old_fs);
87263
87264 diff --git a/mm/madvise.c b/mm/madvise.c
87265 index 539eeb9..e24a987 100644
87266 --- a/mm/madvise.c
87267 +++ b/mm/madvise.c
87268 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
87269 pgoff_t pgoff;
87270 unsigned long new_flags = vma->vm_flags;
87271
87272 +#ifdef CONFIG_PAX_SEGMEXEC
87273 + struct vm_area_struct *vma_m;
87274 +#endif
87275 +
87276 switch (behavior) {
87277 case MADV_NORMAL:
87278 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
87279 @@ -126,6 +130,13 @@ success:
87280 /*
87281 * vm_flags is protected by the mmap_sem held in write mode.
87282 */
87283 +
87284 +#ifdef CONFIG_PAX_SEGMEXEC
87285 + vma_m = pax_find_mirror_vma(vma);
87286 + if (vma_m)
87287 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
87288 +#endif
87289 +
87290 vma->vm_flags = new_flags;
87291
87292 out:
87293 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87294 struct vm_area_struct **prev,
87295 unsigned long start, unsigned long end)
87296 {
87297 +
87298 +#ifdef CONFIG_PAX_SEGMEXEC
87299 + struct vm_area_struct *vma_m;
87300 +#endif
87301 +
87302 *prev = vma;
87303 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
87304 return -EINVAL;
87305 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87306 zap_page_range(vma, start, end - start, &details);
87307 } else
87308 zap_page_range(vma, start, end - start, NULL);
87309 +
87310 +#ifdef CONFIG_PAX_SEGMEXEC
87311 + vma_m = pax_find_mirror_vma(vma);
87312 + if (vma_m) {
87313 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
87314 + struct zap_details details = {
87315 + .nonlinear_vma = vma_m,
87316 + .last_index = ULONG_MAX,
87317 + };
87318 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
87319 + } else
87320 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
87321 + }
87322 +#endif
87323 +
87324 return 0;
87325 }
87326
87327 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
87328 if (end < start)
87329 return error;
87330
87331 +#ifdef CONFIG_PAX_SEGMEXEC
87332 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
87333 + if (end > SEGMEXEC_TASK_SIZE)
87334 + return error;
87335 + } else
87336 +#endif
87337 +
87338 + if (end > TASK_SIZE)
87339 + return error;
87340 +
87341 error = 0;
87342 if (end == start)
87343 return error;
87344 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
87345 index bf3351b..aea800d 100644
87346 --- a/mm/memory-failure.c
87347 +++ b/mm/memory-failure.c
87348 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
87349
87350 int sysctl_memory_failure_recovery __read_mostly = 1;
87351
87352 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87353 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87354
87355 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
87356
87357 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
87358 pfn, t->comm, t->pid);
87359 si.si_signo = SIGBUS;
87360 si.si_errno = 0;
87361 - si.si_addr = (void *)addr;
87362 + si.si_addr = (void __user *)addr;
87363 #ifdef __ARCH_SI_TRAPNO
87364 si.si_trapno = trapno;
87365 #endif
87366 @@ -762,7 +762,7 @@ static struct page_state {
87367 unsigned long res;
87368 char *msg;
87369 int (*action)(struct page *p, unsigned long pfn);
87370 -} error_states[] = {
87371 +} __do_const error_states[] = {
87372 { reserved, reserved, "reserved kernel", me_kernel },
87373 /*
87374 * free pages are specially detected outside this table:
87375 @@ -1053,7 +1053,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87376 nr_pages = 1 << compound_order(hpage);
87377 else /* normal page or thp */
87378 nr_pages = 1;
87379 - atomic_long_add(nr_pages, &num_poisoned_pages);
87380 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
87381
87382 /*
87383 * We need/can do nothing about count=0 pages.
87384 @@ -1083,7 +1083,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87385 if (!PageHWPoison(hpage)
87386 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
87387 || (p != hpage && TestSetPageHWPoison(hpage))) {
87388 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87389 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87390 return 0;
87391 }
87392 set_page_hwpoison_huge_page(hpage);
87393 @@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87394 }
87395 if (hwpoison_filter(p)) {
87396 if (TestClearPageHWPoison(p))
87397 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87398 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87399 unlock_page(hpage);
87400 put_page(hpage);
87401 return 0;
87402 @@ -1370,7 +1370,7 @@ int unpoison_memory(unsigned long pfn)
87403 return 0;
87404 }
87405 if (TestClearPageHWPoison(p))
87406 - atomic_long_dec(&num_poisoned_pages);
87407 + atomic_long_dec_unchecked(&num_poisoned_pages);
87408 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
87409 return 0;
87410 }
87411 @@ -1384,7 +1384,7 @@ int unpoison_memory(unsigned long pfn)
87412 */
87413 if (TestClearPageHWPoison(page)) {
87414 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
87415 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87416 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87417 freeit = 1;
87418 if (PageHuge(page))
87419 clear_page_hwpoison_huge_page(page);
87420 @@ -1521,7 +1521,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
87421 } else {
87422 set_page_hwpoison_huge_page(hpage);
87423 dequeue_hwpoisoned_huge_page(hpage);
87424 - atomic_long_add(1 << compound_order(hpage),
87425 + atomic_long_add_unchecked(1 << compound_order(hpage),
87426 &num_poisoned_pages);
87427 }
87428 return ret;
87429 @@ -1560,7 +1560,7 @@ static int __soft_offline_page(struct page *page, int flags)
87430 put_page(page);
87431 pr_info("soft_offline: %#lx: invalidated\n", pfn);
87432 SetPageHWPoison(page);
87433 - atomic_long_inc(&num_poisoned_pages);
87434 + atomic_long_inc_unchecked(&num_poisoned_pages);
87435 return 0;
87436 }
87437
87438 @@ -1605,7 +1605,7 @@ static int __soft_offline_page(struct page *page, int flags)
87439 if (!is_free_buddy_page(page))
87440 pr_info("soft offline: %#lx: page leaked\n",
87441 pfn);
87442 - atomic_long_inc(&num_poisoned_pages);
87443 + atomic_long_inc_unchecked(&num_poisoned_pages);
87444 }
87445 } else {
87446 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
87447 @@ -1666,11 +1666,11 @@ int soft_offline_page(struct page *page, int flags)
87448 if (PageHuge(page)) {
87449 set_page_hwpoison_huge_page(hpage);
87450 dequeue_hwpoisoned_huge_page(hpage);
87451 - atomic_long_add(1 << compound_order(hpage),
87452 + atomic_long_add_unchecked(1 << compound_order(hpage),
87453 &num_poisoned_pages);
87454 } else {
87455 SetPageHWPoison(page);
87456 - atomic_long_inc(&num_poisoned_pages);
87457 + atomic_long_inc_unchecked(&num_poisoned_pages);
87458 }
87459 }
87460 unset:
87461 diff --git a/mm/memory.c b/mm/memory.c
87462 index d176154..cd1b387 100644
87463 --- a/mm/memory.c
87464 +++ b/mm/memory.c
87465 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87466 free_pte_range(tlb, pmd, addr);
87467 } while (pmd++, addr = next, addr != end);
87468
87469 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
87470 start &= PUD_MASK;
87471 if (start < floor)
87472 return;
87473 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87474 pmd = pmd_offset(pud, start);
87475 pud_clear(pud);
87476 pmd_free_tlb(tlb, pmd, start);
87477 +#endif
87478 +
87479 }
87480
87481 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87482 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87483 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
87484 } while (pud++, addr = next, addr != end);
87485
87486 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
87487 start &= PGDIR_MASK;
87488 if (start < floor)
87489 return;
87490 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87491 pud = pud_offset(pgd, start);
87492 pgd_clear(pgd);
87493 pud_free_tlb(tlb, pud, start);
87494 +#endif
87495 +
87496 }
87497
87498 /*
87499 @@ -1636,12 +1642,6 @@ no_page_table:
87500 return page;
87501 }
87502
87503 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
87504 -{
87505 - return stack_guard_page_start(vma, addr) ||
87506 - stack_guard_page_end(vma, addr+PAGE_SIZE);
87507 -}
87508 -
87509 /**
87510 * __get_user_pages() - pin user pages in memory
87511 * @tsk: task_struct of target task
87512 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87513
87514 i = 0;
87515
87516 - do {
87517 + while (nr_pages) {
87518 struct vm_area_struct *vma;
87519
87520 - vma = find_extend_vma(mm, start);
87521 + vma = find_vma(mm, start);
87522 if (!vma && in_gate_area(mm, start)) {
87523 unsigned long pg = start & PAGE_MASK;
87524 pgd_t *pgd;
87525 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87526 goto next_page;
87527 }
87528
87529 - if (!vma ||
87530 + if (!vma || start < vma->vm_start ||
87531 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
87532 !(vm_flags & vma->vm_flags))
87533 return i ? : -EFAULT;
87534 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87535 int ret;
87536 unsigned int fault_flags = 0;
87537
87538 - /* For mlock, just skip the stack guard page. */
87539 - if (foll_flags & FOLL_MLOCK) {
87540 - if (stack_guard_page(vma, start))
87541 - goto next_page;
87542 - }
87543 if (foll_flags & FOLL_WRITE)
87544 fault_flags |= FAULT_FLAG_WRITE;
87545 if (nonblocking)
87546 @@ -1893,7 +1888,7 @@ next_page:
87547 start += page_increm * PAGE_SIZE;
87548 nr_pages -= page_increm;
87549 } while (nr_pages && start < vma->vm_end);
87550 - } while (nr_pages);
87551 + }
87552 return i;
87553 }
87554 EXPORT_SYMBOL(__get_user_pages);
87555 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
87556 page_add_file_rmap(page);
87557 set_pte_at(mm, addr, pte, mk_pte(page, prot));
87558
87559 +#ifdef CONFIG_PAX_SEGMEXEC
87560 + pax_mirror_file_pte(vma, addr, page, ptl);
87561 +#endif
87562 +
87563 retval = 0;
87564 pte_unmap_unlock(pte, ptl);
87565 return retval;
87566 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
87567 if (!page_count(page))
87568 return -EINVAL;
87569 if (!(vma->vm_flags & VM_MIXEDMAP)) {
87570 +
87571 +#ifdef CONFIG_PAX_SEGMEXEC
87572 + struct vm_area_struct *vma_m;
87573 +#endif
87574 +
87575 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
87576 BUG_ON(vma->vm_flags & VM_PFNMAP);
87577 vma->vm_flags |= VM_MIXEDMAP;
87578 +
87579 +#ifdef CONFIG_PAX_SEGMEXEC
87580 + vma_m = pax_find_mirror_vma(vma);
87581 + if (vma_m)
87582 + vma_m->vm_flags |= VM_MIXEDMAP;
87583 +#endif
87584 +
87585 }
87586 return insert_page(vma, addr, page, vma->vm_page_prot);
87587 }
87588 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
87589 unsigned long pfn)
87590 {
87591 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
87592 + BUG_ON(vma->vm_mirror);
87593
87594 if (addr < vma->vm_start || addr >= vma->vm_end)
87595 return -EFAULT;
87596 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
87597
87598 BUG_ON(pud_huge(*pud));
87599
87600 - pmd = pmd_alloc(mm, pud, addr);
87601 + pmd = (mm == &init_mm) ?
87602 + pmd_alloc_kernel(mm, pud, addr) :
87603 + pmd_alloc(mm, pud, addr);
87604 if (!pmd)
87605 return -ENOMEM;
87606 do {
87607 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
87608 unsigned long next;
87609 int err;
87610
87611 - pud = pud_alloc(mm, pgd, addr);
87612 + pud = (mm == &init_mm) ?
87613 + pud_alloc_kernel(mm, pgd, addr) :
87614 + pud_alloc(mm, pgd, addr);
87615 if (!pud)
87616 return -ENOMEM;
87617 do {
87618 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
87619 copy_user_highpage(dst, src, va, vma);
87620 }
87621
87622 +#ifdef CONFIG_PAX_SEGMEXEC
87623 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
87624 +{
87625 + struct mm_struct *mm = vma->vm_mm;
87626 + spinlock_t *ptl;
87627 + pte_t *pte, entry;
87628 +
87629 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
87630 + entry = *pte;
87631 + if (!pte_present(entry)) {
87632 + if (!pte_none(entry)) {
87633 + BUG_ON(pte_file(entry));
87634 + free_swap_and_cache(pte_to_swp_entry(entry));
87635 + pte_clear_not_present_full(mm, address, pte, 0);
87636 + }
87637 + } else {
87638 + struct page *page;
87639 +
87640 + flush_cache_page(vma, address, pte_pfn(entry));
87641 + entry = ptep_clear_flush(vma, address, pte);
87642 + BUG_ON(pte_dirty(entry));
87643 + page = vm_normal_page(vma, address, entry);
87644 + if (page) {
87645 + update_hiwater_rss(mm);
87646 + if (PageAnon(page))
87647 + dec_mm_counter_fast(mm, MM_ANONPAGES);
87648 + else
87649 + dec_mm_counter_fast(mm, MM_FILEPAGES);
87650 + page_remove_rmap(page);
87651 + page_cache_release(page);
87652 + }
87653 + }
87654 + pte_unmap_unlock(pte, ptl);
87655 +}
87656 +
87657 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
87658 + *
87659 + * the ptl of the lower mapped page is held on entry and is not released on exit
87660 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
87661 + */
87662 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87663 +{
87664 + struct mm_struct *mm = vma->vm_mm;
87665 + unsigned long address_m;
87666 + spinlock_t *ptl_m;
87667 + struct vm_area_struct *vma_m;
87668 + pmd_t *pmd_m;
87669 + pte_t *pte_m, entry_m;
87670 +
87671 + BUG_ON(!page_m || !PageAnon(page_m));
87672 +
87673 + vma_m = pax_find_mirror_vma(vma);
87674 + if (!vma_m)
87675 + return;
87676 +
87677 + BUG_ON(!PageLocked(page_m));
87678 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87679 + address_m = address + SEGMEXEC_TASK_SIZE;
87680 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87681 + pte_m = pte_offset_map(pmd_m, address_m);
87682 + ptl_m = pte_lockptr(mm, pmd_m);
87683 + if (ptl != ptl_m) {
87684 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87685 + if (!pte_none(*pte_m))
87686 + goto out;
87687 + }
87688 +
87689 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87690 + page_cache_get(page_m);
87691 + page_add_anon_rmap(page_m, vma_m, address_m);
87692 + inc_mm_counter_fast(mm, MM_ANONPAGES);
87693 + set_pte_at(mm, address_m, pte_m, entry_m);
87694 + update_mmu_cache(vma_m, address_m, pte_m);
87695 +out:
87696 + if (ptl != ptl_m)
87697 + spin_unlock(ptl_m);
87698 + pte_unmap(pte_m);
87699 + unlock_page(page_m);
87700 +}
87701 +
87702 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87703 +{
87704 + struct mm_struct *mm = vma->vm_mm;
87705 + unsigned long address_m;
87706 + spinlock_t *ptl_m;
87707 + struct vm_area_struct *vma_m;
87708 + pmd_t *pmd_m;
87709 + pte_t *pte_m, entry_m;
87710 +
87711 + BUG_ON(!page_m || PageAnon(page_m));
87712 +
87713 + vma_m = pax_find_mirror_vma(vma);
87714 + if (!vma_m)
87715 + return;
87716 +
87717 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87718 + address_m = address + SEGMEXEC_TASK_SIZE;
87719 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87720 + pte_m = pte_offset_map(pmd_m, address_m);
87721 + ptl_m = pte_lockptr(mm, pmd_m);
87722 + if (ptl != ptl_m) {
87723 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87724 + if (!pte_none(*pte_m))
87725 + goto out;
87726 + }
87727 +
87728 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87729 + page_cache_get(page_m);
87730 + page_add_file_rmap(page_m);
87731 + inc_mm_counter_fast(mm, MM_FILEPAGES);
87732 + set_pte_at(mm, address_m, pte_m, entry_m);
87733 + update_mmu_cache(vma_m, address_m, pte_m);
87734 +out:
87735 + if (ptl != ptl_m)
87736 + spin_unlock(ptl_m);
87737 + pte_unmap(pte_m);
87738 +}
87739 +
87740 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
87741 +{
87742 + struct mm_struct *mm = vma->vm_mm;
87743 + unsigned long address_m;
87744 + spinlock_t *ptl_m;
87745 + struct vm_area_struct *vma_m;
87746 + pmd_t *pmd_m;
87747 + pte_t *pte_m, entry_m;
87748 +
87749 + vma_m = pax_find_mirror_vma(vma);
87750 + if (!vma_m)
87751 + return;
87752 +
87753 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87754 + address_m = address + SEGMEXEC_TASK_SIZE;
87755 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87756 + pte_m = pte_offset_map(pmd_m, address_m);
87757 + ptl_m = pte_lockptr(mm, pmd_m);
87758 + if (ptl != ptl_m) {
87759 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87760 + if (!pte_none(*pte_m))
87761 + goto out;
87762 + }
87763 +
87764 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
87765 + set_pte_at(mm, address_m, pte_m, entry_m);
87766 +out:
87767 + if (ptl != ptl_m)
87768 + spin_unlock(ptl_m);
87769 + pte_unmap(pte_m);
87770 +}
87771 +
87772 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
87773 +{
87774 + struct page *page_m;
87775 + pte_t entry;
87776 +
87777 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
87778 + goto out;
87779 +
87780 + entry = *pte;
87781 + page_m = vm_normal_page(vma, address, entry);
87782 + if (!page_m)
87783 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
87784 + else if (PageAnon(page_m)) {
87785 + if (pax_find_mirror_vma(vma)) {
87786 + pte_unmap_unlock(pte, ptl);
87787 + lock_page(page_m);
87788 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
87789 + if (pte_same(entry, *pte))
87790 + pax_mirror_anon_pte(vma, address, page_m, ptl);
87791 + else
87792 + unlock_page(page_m);
87793 + }
87794 + } else
87795 + pax_mirror_file_pte(vma, address, page_m, ptl);
87796 +
87797 +out:
87798 + pte_unmap_unlock(pte, ptl);
87799 +}
87800 +#endif
87801 +
87802 /*
87803 * This routine handles present pages, when users try to write
87804 * to a shared page. It is done by copying the page to a new address
87805 @@ -2800,6 +2996,12 @@ gotten:
87806 */
87807 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87808 if (likely(pte_same(*page_table, orig_pte))) {
87809 +
87810 +#ifdef CONFIG_PAX_SEGMEXEC
87811 + if (pax_find_mirror_vma(vma))
87812 + BUG_ON(!trylock_page(new_page));
87813 +#endif
87814 +
87815 if (old_page) {
87816 if (!PageAnon(old_page)) {
87817 dec_mm_counter_fast(mm, MM_FILEPAGES);
87818 @@ -2851,6 +3053,10 @@ gotten:
87819 page_remove_rmap(old_page);
87820 }
87821
87822 +#ifdef CONFIG_PAX_SEGMEXEC
87823 + pax_mirror_anon_pte(vma, address, new_page, ptl);
87824 +#endif
87825 +
87826 /* Free the old page.. */
87827 new_page = old_page;
87828 ret |= VM_FAULT_WRITE;
87829 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87830 swap_free(entry);
87831 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
87832 try_to_free_swap(page);
87833 +
87834 +#ifdef CONFIG_PAX_SEGMEXEC
87835 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
87836 +#endif
87837 +
87838 unlock_page(page);
87839 if (page != swapcache) {
87840 /*
87841 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87842
87843 /* No need to invalidate - it was non-present before */
87844 update_mmu_cache(vma, address, page_table);
87845 +
87846 +#ifdef CONFIG_PAX_SEGMEXEC
87847 + pax_mirror_anon_pte(vma, address, page, ptl);
87848 +#endif
87849 +
87850 unlock:
87851 pte_unmap_unlock(page_table, ptl);
87852 out:
87853 @@ -3170,40 +3386,6 @@ out_release:
87854 }
87855
87856 /*
87857 - * This is like a special single-page "expand_{down|up}wards()",
87858 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
87859 - * doesn't hit another vma.
87860 - */
87861 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
87862 -{
87863 - address &= PAGE_MASK;
87864 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
87865 - struct vm_area_struct *prev = vma->vm_prev;
87866 -
87867 - /*
87868 - * Is there a mapping abutting this one below?
87869 - *
87870 - * That's only ok if it's the same stack mapping
87871 - * that has gotten split..
87872 - */
87873 - if (prev && prev->vm_end == address)
87874 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
87875 -
87876 - expand_downwards(vma, address - PAGE_SIZE);
87877 - }
87878 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
87879 - struct vm_area_struct *next = vma->vm_next;
87880 -
87881 - /* As VM_GROWSDOWN but s/below/above/ */
87882 - if (next && next->vm_start == address + PAGE_SIZE)
87883 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
87884 -
87885 - expand_upwards(vma, address + PAGE_SIZE);
87886 - }
87887 - return 0;
87888 -}
87889 -
87890 -/*
87891 * We enter with non-exclusive mmap_sem (to exclude vma changes,
87892 * but allow concurrent faults), and pte mapped but not yet locked.
87893 * We return with mmap_sem still held, but pte unmapped and unlocked.
87894 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87895 unsigned long address, pte_t *page_table, pmd_t *pmd,
87896 unsigned int flags)
87897 {
87898 - struct page *page;
87899 + struct page *page = NULL;
87900 spinlock_t *ptl;
87901 pte_t entry;
87902
87903 - pte_unmap(page_table);
87904 -
87905 - /* Check if we need to add a guard page to the stack */
87906 - if (check_stack_guard_page(vma, address) < 0)
87907 - return VM_FAULT_SIGBUS;
87908 -
87909 - /* Use the zero-page for reads */
87910 if (!(flags & FAULT_FLAG_WRITE)) {
87911 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
87912 vma->vm_page_prot));
87913 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87914 + ptl = pte_lockptr(mm, pmd);
87915 + spin_lock(ptl);
87916 if (!pte_none(*page_table))
87917 goto unlock;
87918 goto setpte;
87919 }
87920
87921 /* Allocate our own private page. */
87922 + pte_unmap(page_table);
87923 +
87924 if (unlikely(anon_vma_prepare(vma)))
87925 goto oom;
87926 page = alloc_zeroed_user_highpage_movable(vma, address);
87927 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87928 if (!pte_none(*page_table))
87929 goto release;
87930
87931 +#ifdef CONFIG_PAX_SEGMEXEC
87932 + if (pax_find_mirror_vma(vma))
87933 + BUG_ON(!trylock_page(page));
87934 +#endif
87935 +
87936 inc_mm_counter_fast(mm, MM_ANONPAGES);
87937 page_add_new_anon_rmap(page, vma, address);
87938 setpte:
87939 @@ -3263,6 +3446,12 @@ setpte:
87940
87941 /* No need to invalidate - it was non-present before */
87942 update_mmu_cache(vma, address, page_table);
87943 +
87944 +#ifdef CONFIG_PAX_SEGMEXEC
87945 + if (page)
87946 + pax_mirror_anon_pte(vma, address, page, ptl);
87947 +#endif
87948 +
87949 unlock:
87950 pte_unmap_unlock(page_table, ptl);
87951 return 0;
87952 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87953 */
87954 /* Only go through if we didn't race with anybody else... */
87955 if (likely(pte_same(*page_table, orig_pte))) {
87956 +
87957 +#ifdef CONFIG_PAX_SEGMEXEC
87958 + if (anon && pax_find_mirror_vma(vma))
87959 + BUG_ON(!trylock_page(page));
87960 +#endif
87961 +
87962 flush_icache_page(vma, page);
87963 entry = mk_pte(page, vma->vm_page_prot);
87964 if (flags & FAULT_FLAG_WRITE)
87965 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87966
87967 /* no need to invalidate: a not-present page won't be cached */
87968 update_mmu_cache(vma, address, page_table);
87969 +
87970 +#ifdef CONFIG_PAX_SEGMEXEC
87971 + if (anon)
87972 + pax_mirror_anon_pte(vma, address, page, ptl);
87973 + else
87974 + pax_mirror_file_pte(vma, address, page, ptl);
87975 +#endif
87976 +
87977 } else {
87978 if (cow_page)
87979 mem_cgroup_uncharge_page(cow_page);
87980 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
87981 if (flags & FAULT_FLAG_WRITE)
87982 flush_tlb_fix_spurious_fault(vma, address);
87983 }
87984 +
87985 +#ifdef CONFIG_PAX_SEGMEXEC
87986 + pax_mirror_pte(vma, address, pte, pmd, ptl);
87987 + return 0;
87988 +#endif
87989 +
87990 unlock:
87991 pte_unmap_unlock(pte, ptl);
87992 return 0;
87993 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87994 pmd_t *pmd;
87995 pte_t *pte;
87996
87997 +#ifdef CONFIG_PAX_SEGMEXEC
87998 + struct vm_area_struct *vma_m;
87999 +#endif
88000 +
88001 if (unlikely(is_vm_hugetlb_page(vma)))
88002 return hugetlb_fault(mm, vma, address, flags);
88003
88004 +#ifdef CONFIG_PAX_SEGMEXEC
88005 + vma_m = pax_find_mirror_vma(vma);
88006 + if (vma_m) {
88007 + unsigned long address_m;
88008 + pgd_t *pgd_m;
88009 + pud_t *pud_m;
88010 + pmd_t *pmd_m;
88011 +
88012 + if (vma->vm_start > vma_m->vm_start) {
88013 + address_m = address;
88014 + address -= SEGMEXEC_TASK_SIZE;
88015 + vma = vma_m;
88016 + } else
88017 + address_m = address + SEGMEXEC_TASK_SIZE;
88018 +
88019 + pgd_m = pgd_offset(mm, address_m);
88020 + pud_m = pud_alloc(mm, pgd_m, address_m);
88021 + if (!pud_m)
88022 + return VM_FAULT_OOM;
88023 + pmd_m = pmd_alloc(mm, pud_m, address_m);
88024 + if (!pmd_m)
88025 + return VM_FAULT_OOM;
88026 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
88027 + return VM_FAULT_OOM;
88028 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
88029 + }
88030 +#endif
88031 +
88032 retry:
88033 pgd = pgd_offset(mm, address);
88034 pud = pud_alloc(mm, pgd, address);
88035 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88036 spin_unlock(&mm->page_table_lock);
88037 return 0;
88038 }
88039 +
88040 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88041 +{
88042 + pud_t *new = pud_alloc_one(mm, address);
88043 + if (!new)
88044 + return -ENOMEM;
88045 +
88046 + smp_wmb(); /* See comment in __pte_alloc */
88047 +
88048 + spin_lock(&mm->page_table_lock);
88049 + if (pgd_present(*pgd)) /* Another has populated it */
88050 + pud_free(mm, new);
88051 + else
88052 + pgd_populate_kernel(mm, pgd, new);
88053 + spin_unlock(&mm->page_table_lock);
88054 + return 0;
88055 +}
88056 #endif /* __PAGETABLE_PUD_FOLDED */
88057
88058 #ifndef __PAGETABLE_PMD_FOLDED
88059 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
88060 spin_unlock(&mm->page_table_lock);
88061 return 0;
88062 }
88063 +
88064 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
88065 +{
88066 + pmd_t *new = pmd_alloc_one(mm, address);
88067 + if (!new)
88068 + return -ENOMEM;
88069 +
88070 + smp_wmb(); /* See comment in __pte_alloc */
88071 +
88072 + spin_lock(&mm->page_table_lock);
88073 +#ifndef __ARCH_HAS_4LEVEL_HACK
88074 + if (pud_present(*pud)) /* Another has populated it */
88075 + pmd_free(mm, new);
88076 + else
88077 + pud_populate_kernel(mm, pud, new);
88078 +#else
88079 + if (pgd_present(*pud)) /* Another has populated it */
88080 + pmd_free(mm, new);
88081 + else
88082 + pgd_populate_kernel(mm, pud, new);
88083 +#endif /* __ARCH_HAS_4LEVEL_HACK */
88084 + spin_unlock(&mm->page_table_lock);
88085 + return 0;
88086 +}
88087 #endif /* __PAGETABLE_PMD_FOLDED */
88088
88089 #if !defined(__HAVE_ARCH_GATE_AREA)
88090 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
88091 gate_vma.vm_start = FIXADDR_USER_START;
88092 gate_vma.vm_end = FIXADDR_USER_END;
88093 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
88094 - gate_vma.vm_page_prot = __P101;
88095 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
88096
88097 return 0;
88098 }
88099 @@ -4071,8 +4353,8 @@ out:
88100 return ret;
88101 }
88102
88103 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88104 - void *buf, int len, int write)
88105 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88106 + void *buf, size_t len, int write)
88107 {
88108 resource_size_t phys_addr;
88109 unsigned long prot = 0;
88110 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
88111 * Access another process' address space as given in mm. If non-NULL, use the
88112 * given task for page fault accounting.
88113 */
88114 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88115 - unsigned long addr, void *buf, int len, int write)
88116 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88117 + unsigned long addr, void *buf, size_t len, int write)
88118 {
88119 struct vm_area_struct *vma;
88120 void *old_buf = buf;
88121 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88122 down_read(&mm->mmap_sem);
88123 /* ignore errors, just check how much was successfully transferred */
88124 while (len) {
88125 - int bytes, ret, offset;
88126 + ssize_t bytes, ret, offset;
88127 void *maddr;
88128 struct page *page = NULL;
88129
88130 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88131 *
88132 * The caller must hold a reference on @mm.
88133 */
88134 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88135 - void *buf, int len, int write)
88136 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88137 + void *buf, size_t len, int write)
88138 {
88139 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88140 }
88141 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88142 * Source/target buffer must be kernel space,
88143 * Do not walk the page table directly, use get_user_pages
88144 */
88145 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
88146 - void *buf, int len, int write)
88147 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
88148 + void *buf, size_t len, int write)
88149 {
88150 struct mm_struct *mm;
88151 - int ret;
88152 + ssize_t ret;
88153
88154 mm = get_task_mm(tsk);
88155 if (!mm)
88156 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
88157 index 0472964..7d5a0ea 100644
88158 --- a/mm/mempolicy.c
88159 +++ b/mm/mempolicy.c
88160 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88161 unsigned long vmstart;
88162 unsigned long vmend;
88163
88164 +#ifdef CONFIG_PAX_SEGMEXEC
88165 + struct vm_area_struct *vma_m;
88166 +#endif
88167 +
88168 vma = find_vma(mm, start);
88169 if (!vma || vma->vm_start > start)
88170 return -EFAULT;
88171 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88172 err = vma_replace_policy(vma, new_pol);
88173 if (err)
88174 goto out;
88175 +
88176 +#ifdef CONFIG_PAX_SEGMEXEC
88177 + vma_m = pax_find_mirror_vma(vma);
88178 + if (vma_m) {
88179 + err = vma_replace_policy(vma_m, new_pol);
88180 + if (err)
88181 + goto out;
88182 + }
88183 +#endif
88184 +
88185 }
88186
88187 out:
88188 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
88189
88190 if (end < start)
88191 return -EINVAL;
88192 +
88193 +#ifdef CONFIG_PAX_SEGMEXEC
88194 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88195 + if (end > SEGMEXEC_TASK_SIZE)
88196 + return -EINVAL;
88197 + } else
88198 +#endif
88199 +
88200 + if (end > TASK_SIZE)
88201 + return -EINVAL;
88202 +
88203 if (end == start)
88204 return 0;
88205
88206 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88207 */
88208 tcred = __task_cred(task);
88209 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88210 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88211 - !capable(CAP_SYS_NICE)) {
88212 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88213 rcu_read_unlock();
88214 err = -EPERM;
88215 goto out_put;
88216 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88217 goto out;
88218 }
88219
88220 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
88221 + if (mm != current->mm &&
88222 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
88223 + mmput(mm);
88224 + err = -EPERM;
88225 + goto out;
88226 + }
88227 +#endif
88228 +
88229 err = do_migrate_pages(mm, old, new,
88230 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
88231
88232 diff --git a/mm/migrate.c b/mm/migrate.c
88233 index c046927..6996b40 100644
88234 --- a/mm/migrate.c
88235 +++ b/mm/migrate.c
88236 @@ -1404,8 +1404,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
88237 */
88238 tcred = __task_cred(task);
88239 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88240 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88241 - !capable(CAP_SYS_NICE)) {
88242 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88243 rcu_read_unlock();
88244 err = -EPERM;
88245 goto out;
88246 diff --git a/mm/mlock.c b/mm/mlock.c
88247 index d480cd6..0f98458 100644
88248 --- a/mm/mlock.c
88249 +++ b/mm/mlock.c
88250 @@ -14,6 +14,7 @@
88251 #include <linux/pagevec.h>
88252 #include <linux/mempolicy.h>
88253 #include <linux/syscalls.h>
88254 +#include <linux/security.h>
88255 #include <linux/sched.h>
88256 #include <linux/export.h>
88257 #include <linux/rmap.h>
88258 @@ -568,7 +569,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
88259 {
88260 unsigned long nstart, end, tmp;
88261 struct vm_area_struct * vma, * prev;
88262 - int error;
88263 + int error = 0;
88264
88265 VM_BUG_ON(start & ~PAGE_MASK);
88266 VM_BUG_ON(len != PAGE_ALIGN(len));
88267 @@ -577,6 +578,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
88268 return -EINVAL;
88269 if (end == start)
88270 return 0;
88271 + if (end > TASK_SIZE)
88272 + return -EINVAL;
88273 +
88274 vma = find_vma(current->mm, start);
88275 if (!vma || vma->vm_start > start)
88276 return -ENOMEM;
88277 @@ -588,6 +592,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
88278 for (nstart = start ; ; ) {
88279 vm_flags_t newflags;
88280
88281 +#ifdef CONFIG_PAX_SEGMEXEC
88282 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88283 + break;
88284 +#endif
88285 +
88286 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
88287
88288 newflags = vma->vm_flags & ~VM_LOCKED;
88289 @@ -700,6 +709,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
88290 lock_limit >>= PAGE_SHIFT;
88291
88292 /* check against resource limits */
88293 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
88294 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
88295 error = do_mlock(start, len, 1);
88296 up_write(&current->mm->mmap_sem);
88297 @@ -734,6 +744,11 @@ static int do_mlockall(int flags)
88298 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
88299 vm_flags_t newflags;
88300
88301 +#ifdef CONFIG_PAX_SEGMEXEC
88302 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88303 + break;
88304 +#endif
88305 +
88306 newflags = vma->vm_flags & ~VM_LOCKED;
88307 if (flags & MCL_CURRENT)
88308 newflags |= VM_LOCKED;
88309 @@ -767,6 +782,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
88310 lock_limit >>= PAGE_SHIFT;
88311
88312 ret = -ENOMEM;
88313 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
88314 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
88315 capable(CAP_IPC_LOCK))
88316 ret = do_mlockall(flags);
88317 diff --git a/mm/mmap.c b/mm/mmap.c
88318 index 9d54851..e8c6035 100644
88319 --- a/mm/mmap.c
88320 +++ b/mm/mmap.c
88321 @@ -36,6 +36,7 @@
88322 #include <linux/sched/sysctl.h>
88323 #include <linux/notifier.h>
88324 #include <linux/memory.h>
88325 +#include <linux/random.h>
88326
88327 #include <asm/uaccess.h>
88328 #include <asm/cacheflush.h>
88329 @@ -52,6 +53,16 @@
88330 #define arch_rebalance_pgtables(addr, len) (addr)
88331 #endif
88332
88333 +static inline void verify_mm_writelocked(struct mm_struct *mm)
88334 +{
88335 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
88336 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88337 + up_read(&mm->mmap_sem);
88338 + BUG();
88339 + }
88340 +#endif
88341 +}
88342 +
88343 static void unmap_region(struct mm_struct *mm,
88344 struct vm_area_struct *vma, struct vm_area_struct *prev,
88345 unsigned long start, unsigned long end);
88346 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
88347 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
88348 *
88349 */
88350 -pgprot_t protection_map[16] = {
88351 +pgprot_t protection_map[16] __read_only = {
88352 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
88353 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
88354 };
88355
88356 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
88357 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
88358 {
88359 - return __pgprot(pgprot_val(protection_map[vm_flags &
88360 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
88361 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
88362 pgprot_val(arch_vm_get_page_prot(vm_flags)));
88363 +
88364 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88365 + if (!(__supported_pte_mask & _PAGE_NX) &&
88366 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
88367 + (vm_flags & (VM_READ | VM_WRITE)))
88368 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
88369 +#endif
88370 +
88371 + return prot;
88372 }
88373 EXPORT_SYMBOL(vm_get_page_prot);
88374
88375 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
88376 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
88377 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88378 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88379 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
88380 /*
88381 * Make sure vm_committed_as in one cacheline and not cacheline shared with
88382 * other variables. It can be updated by several CPUs frequently.
88383 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
88384 struct vm_area_struct *next = vma->vm_next;
88385
88386 might_sleep();
88387 + BUG_ON(vma->vm_mirror);
88388 if (vma->vm_ops && vma->vm_ops->close)
88389 vma->vm_ops->close(vma);
88390 if (vma->vm_file)
88391 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
88392 * not page aligned -Ram Gupta
88393 */
88394 rlim = rlimit(RLIMIT_DATA);
88395 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
88396 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
88397 (mm->end_data - mm->start_data) > rlim)
88398 goto out;
88399 @@ -933,6 +956,12 @@ static int
88400 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
88401 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88402 {
88403 +
88404 +#ifdef CONFIG_PAX_SEGMEXEC
88405 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
88406 + return 0;
88407 +#endif
88408 +
88409 if (is_mergeable_vma(vma, file, vm_flags) &&
88410 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88411 if (vma->vm_pgoff == vm_pgoff)
88412 @@ -952,6 +981,12 @@ static int
88413 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88414 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88415 {
88416 +
88417 +#ifdef CONFIG_PAX_SEGMEXEC
88418 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
88419 + return 0;
88420 +#endif
88421 +
88422 if (is_mergeable_vma(vma, file, vm_flags) &&
88423 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88424 pgoff_t vm_pglen;
88425 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88426 struct vm_area_struct *vma_merge(struct mm_struct *mm,
88427 struct vm_area_struct *prev, unsigned long addr,
88428 unsigned long end, unsigned long vm_flags,
88429 - struct anon_vma *anon_vma, struct file *file,
88430 + struct anon_vma *anon_vma, struct file *file,
88431 pgoff_t pgoff, struct mempolicy *policy)
88432 {
88433 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
88434 struct vm_area_struct *area, *next;
88435 int err;
88436
88437 +#ifdef CONFIG_PAX_SEGMEXEC
88438 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
88439 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
88440 +
88441 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
88442 +#endif
88443 +
88444 /*
88445 * We later require that vma->vm_flags == vm_flags,
88446 * so this tests vma->vm_flags & VM_SPECIAL, too.
88447 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88448 if (next && next->vm_end == end) /* cases 6, 7, 8 */
88449 next = next->vm_next;
88450
88451 +#ifdef CONFIG_PAX_SEGMEXEC
88452 + if (prev)
88453 + prev_m = pax_find_mirror_vma(prev);
88454 + if (area)
88455 + area_m = pax_find_mirror_vma(area);
88456 + if (next)
88457 + next_m = pax_find_mirror_vma(next);
88458 +#endif
88459 +
88460 /*
88461 * Can it merge with the predecessor?
88462 */
88463 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88464 /* cases 1, 6 */
88465 err = vma_adjust(prev, prev->vm_start,
88466 next->vm_end, prev->vm_pgoff, NULL);
88467 - } else /* cases 2, 5, 7 */
88468 +
88469 +#ifdef CONFIG_PAX_SEGMEXEC
88470 + if (!err && prev_m)
88471 + err = vma_adjust(prev_m, prev_m->vm_start,
88472 + next_m->vm_end, prev_m->vm_pgoff, NULL);
88473 +#endif
88474 +
88475 + } else { /* cases 2, 5, 7 */
88476 err = vma_adjust(prev, prev->vm_start,
88477 end, prev->vm_pgoff, NULL);
88478 +
88479 +#ifdef CONFIG_PAX_SEGMEXEC
88480 + if (!err && prev_m)
88481 + err = vma_adjust(prev_m, prev_m->vm_start,
88482 + end_m, prev_m->vm_pgoff, NULL);
88483 +#endif
88484 +
88485 + }
88486 if (err)
88487 return NULL;
88488 khugepaged_enter_vma_merge(prev);
88489 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88490 mpol_equal(policy, vma_policy(next)) &&
88491 can_vma_merge_before(next, vm_flags,
88492 anon_vma, file, pgoff+pglen)) {
88493 - if (prev && addr < prev->vm_end) /* case 4 */
88494 + if (prev && addr < prev->vm_end) { /* case 4 */
88495 err = vma_adjust(prev, prev->vm_start,
88496 addr, prev->vm_pgoff, NULL);
88497 - else /* cases 3, 8 */
88498 +
88499 +#ifdef CONFIG_PAX_SEGMEXEC
88500 + if (!err && prev_m)
88501 + err = vma_adjust(prev_m, prev_m->vm_start,
88502 + addr_m, prev_m->vm_pgoff, NULL);
88503 +#endif
88504 +
88505 + } else { /* cases 3, 8 */
88506 err = vma_adjust(area, addr, next->vm_end,
88507 next->vm_pgoff - pglen, NULL);
88508 +
88509 +#ifdef CONFIG_PAX_SEGMEXEC
88510 + if (!err && area_m)
88511 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
88512 + next_m->vm_pgoff - pglen, NULL);
88513 +#endif
88514 +
88515 + }
88516 if (err)
88517 return NULL;
88518 khugepaged_enter_vma_merge(area);
88519 @@ -1165,8 +1246,10 @@ none:
88520 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88521 struct file *file, long pages)
88522 {
88523 - const unsigned long stack_flags
88524 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
88525 +
88526 +#ifdef CONFIG_PAX_RANDMMAP
88527 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88528 +#endif
88529
88530 mm->total_vm += pages;
88531
88532 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88533 mm->shared_vm += pages;
88534 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
88535 mm->exec_vm += pages;
88536 - } else if (flags & stack_flags)
88537 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
88538 mm->stack_vm += pages;
88539 }
88540 #endif /* CONFIG_PROC_FS */
88541 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88542 * (the exception is when the underlying filesystem is noexec
88543 * mounted, in which case we dont add PROT_EXEC.)
88544 */
88545 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88546 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88547 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
88548 prot |= PROT_EXEC;
88549
88550 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88551 /* Obtain the address to map to. we verify (or select) it and ensure
88552 * that it represents a valid section of the address space.
88553 */
88554 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
88555 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
88556 if (addr & ~PAGE_MASK)
88557 return addr;
88558
88559 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88560 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
88561 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
88562
88563 +#ifdef CONFIG_PAX_MPROTECT
88564 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88565 +
88566 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
88567 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
88568 + mm->binfmt->handle_mmap)
88569 + mm->binfmt->handle_mmap(file);
88570 +#endif
88571 +
88572 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88573 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
88574 + gr_log_rwxmmap(file);
88575 +
88576 +#ifdef CONFIG_PAX_EMUPLT
88577 + vm_flags &= ~VM_EXEC;
88578 +#else
88579 + return -EPERM;
88580 +#endif
88581 +
88582 + }
88583 +
88584 + if (!(vm_flags & VM_EXEC))
88585 + vm_flags &= ~VM_MAYEXEC;
88586 +#else
88587 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88588 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88589 +#endif
88590 + else
88591 + vm_flags &= ~VM_MAYWRITE;
88592 + }
88593 +#endif
88594 +
88595 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88596 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
88597 + vm_flags &= ~VM_PAGEEXEC;
88598 +#endif
88599 +
88600 if (flags & MAP_LOCKED)
88601 if (!can_do_mlock())
88602 return -EPERM;
88603 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88604 locked += mm->locked_vm;
88605 lock_limit = rlimit(RLIMIT_MEMLOCK);
88606 lock_limit >>= PAGE_SHIFT;
88607 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88608 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
88609 return -EAGAIN;
88610 }
88611 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88612 vm_flags |= VM_NORESERVE;
88613 }
88614
88615 + if (!gr_acl_handle_mmap(file, prot))
88616 + return -EACCES;
88617 +
88618 addr = mmap_region(file, addr, len, vm_flags, pgoff);
88619 if (!IS_ERR_VALUE(addr) &&
88620 ((vm_flags & VM_LOCKED) ||
88621 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
88622 vm_flags_t vm_flags = vma->vm_flags;
88623
88624 /* If it was private or non-writable, the write bit is already clear */
88625 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
88626 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
88627 return 0;
88628
88629 /* The backer wishes to know when pages are first written to? */
88630 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88631 struct rb_node **rb_link, *rb_parent;
88632 unsigned long charged = 0;
88633
88634 +#ifdef CONFIG_PAX_SEGMEXEC
88635 + struct vm_area_struct *vma_m = NULL;
88636 +#endif
88637 +
88638 + /*
88639 + * mm->mmap_sem is required to protect against another thread
88640 + * changing the mappings in case we sleep.
88641 + */
88642 + verify_mm_writelocked(mm);
88643 +
88644 /* Check against address space limit. */
88645 +
88646 +#ifdef CONFIG_PAX_RANDMMAP
88647 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88648 +#endif
88649 +
88650 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
88651 unsigned long nr_pages;
88652
88653 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88654
88655 /* Clear old maps */
88656 error = -ENOMEM;
88657 -munmap_back:
88658 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88659 if (do_munmap(mm, addr, len))
88660 return -ENOMEM;
88661 - goto munmap_back;
88662 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88663 }
88664
88665 /*
88666 @@ -1537,6 +1675,16 @@ munmap_back:
88667 goto unacct_error;
88668 }
88669
88670 +#ifdef CONFIG_PAX_SEGMEXEC
88671 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
88672 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88673 + if (!vma_m) {
88674 + error = -ENOMEM;
88675 + goto free_vma;
88676 + }
88677 + }
88678 +#endif
88679 +
88680 vma->vm_mm = mm;
88681 vma->vm_start = addr;
88682 vma->vm_end = addr + len;
88683 @@ -1556,6 +1704,13 @@ munmap_back:
88684 if (error)
88685 goto unmap_and_free_vma;
88686
88687 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88688 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
88689 + vma->vm_flags |= VM_PAGEEXEC;
88690 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88691 + }
88692 +#endif
88693 +
88694 /* Can addr have changed??
88695 *
88696 * Answer: Yes, several device drivers can do it in their
88697 @@ -1589,6 +1744,12 @@ munmap_back:
88698 }
88699
88700 vma_link(mm, vma, prev, rb_link, rb_parent);
88701 +
88702 +#ifdef CONFIG_PAX_SEGMEXEC
88703 + if (vma_m)
88704 + BUG_ON(pax_mirror_vma(vma_m, vma));
88705 +#endif
88706 +
88707 /* Once vma denies write, undo our temporary denial count */
88708 if (vm_flags & VM_DENYWRITE)
88709 allow_write_access(file);
88710 @@ -1597,6 +1758,7 @@ out:
88711 perf_event_mmap(vma);
88712
88713 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
88714 + track_exec_limit(mm, addr, addr + len, vm_flags);
88715 if (vm_flags & VM_LOCKED) {
88716 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
88717 vma == get_gate_vma(current->mm)))
88718 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
88719 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
88720 charged = 0;
88721 free_vma:
88722 +
88723 +#ifdef CONFIG_PAX_SEGMEXEC
88724 + if (vma_m)
88725 + kmem_cache_free(vm_area_cachep, vma_m);
88726 +#endif
88727 +
88728 kmem_cache_free(vm_area_cachep, vma);
88729 unacct_error:
88730 if (charged)
88731 @@ -1636,7 +1804,63 @@ unacct_error:
88732 return error;
88733 }
88734
88735 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88736 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
88737 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
88738 +{
88739 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
88740 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
88741 +
88742 + return 0;
88743 +}
88744 +#endif
88745 +
88746 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
88747 +{
88748 + if (!vma) {
88749 +#ifdef CONFIG_STACK_GROWSUP
88750 + if (addr > sysctl_heap_stack_gap)
88751 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
88752 + else
88753 + vma = find_vma(current->mm, 0);
88754 + if (vma && (vma->vm_flags & VM_GROWSUP))
88755 + return false;
88756 +#endif
88757 + return true;
88758 + }
88759 +
88760 + if (addr + len > vma->vm_start)
88761 + return false;
88762 +
88763 + if (vma->vm_flags & VM_GROWSDOWN)
88764 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
88765 +#ifdef CONFIG_STACK_GROWSUP
88766 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
88767 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
88768 +#endif
88769 + else if (offset)
88770 + return offset <= vma->vm_start - addr - len;
88771 +
88772 + return true;
88773 +}
88774 +
88775 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
88776 +{
88777 + if (vma->vm_start < len)
88778 + return -ENOMEM;
88779 +
88780 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
88781 + if (offset <= vma->vm_start - len)
88782 + return vma->vm_start - len - offset;
88783 + else
88784 + return -ENOMEM;
88785 + }
88786 +
88787 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
88788 + return vma->vm_start - len - sysctl_heap_stack_gap;
88789 + return -ENOMEM;
88790 +}
88791 +
88792 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
88793 {
88794 /*
88795 * We implement the search by looking for an rbtree node that
88796 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88797 }
88798 }
88799
88800 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
88801 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
88802 check_current:
88803 /* Check if current node has a suitable gap */
88804 if (gap_start > high_limit)
88805 return -ENOMEM;
88806 +
88807 + if (gap_end - gap_start > info->threadstack_offset)
88808 + gap_start += info->threadstack_offset;
88809 + else
88810 + gap_start = gap_end;
88811 +
88812 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88813 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88814 + gap_start += sysctl_heap_stack_gap;
88815 + else
88816 + gap_start = gap_end;
88817 + }
88818 + if (vma->vm_flags & VM_GROWSDOWN) {
88819 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88820 + gap_end -= sysctl_heap_stack_gap;
88821 + else
88822 + gap_end = gap_start;
88823 + }
88824 if (gap_end >= low_limit && gap_end - gap_start >= length)
88825 goto found;
88826
88827 @@ -1738,7 +1980,7 @@ found:
88828 return gap_start;
88829 }
88830
88831 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
88832 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
88833 {
88834 struct mm_struct *mm = current->mm;
88835 struct vm_area_struct *vma;
88836 @@ -1792,6 +2034,24 @@ check_current:
88837 gap_end = vma->vm_start;
88838 if (gap_end < low_limit)
88839 return -ENOMEM;
88840 +
88841 + if (gap_end - gap_start > info->threadstack_offset)
88842 + gap_end -= info->threadstack_offset;
88843 + else
88844 + gap_end = gap_start;
88845 +
88846 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88847 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88848 + gap_start += sysctl_heap_stack_gap;
88849 + else
88850 + gap_start = gap_end;
88851 + }
88852 + if (vma->vm_flags & VM_GROWSDOWN) {
88853 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88854 + gap_end -= sysctl_heap_stack_gap;
88855 + else
88856 + gap_end = gap_start;
88857 + }
88858 if (gap_start <= high_limit && gap_end - gap_start >= length)
88859 goto found;
88860
88861 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88862 struct mm_struct *mm = current->mm;
88863 struct vm_area_struct *vma;
88864 struct vm_unmapped_area_info info;
88865 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88866
88867 if (len > TASK_SIZE)
88868 return -ENOMEM;
88869 @@ -1862,19 +2123,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88870 if (flags & MAP_FIXED)
88871 return addr;
88872
88873 +#ifdef CONFIG_PAX_RANDMMAP
88874 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88875 +#endif
88876 +
88877 if (addr) {
88878 addr = PAGE_ALIGN(addr);
88879 vma = find_vma(mm, addr);
88880 - if (TASK_SIZE - len >= addr &&
88881 - (!vma || addr + len <= vma->vm_start))
88882 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88883 return addr;
88884 }
88885
88886 info.flags = 0;
88887 info.length = len;
88888 info.low_limit = TASK_UNMAPPED_BASE;
88889 +
88890 +#ifdef CONFIG_PAX_RANDMMAP
88891 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88892 + info.low_limit += mm->delta_mmap;
88893 +#endif
88894 +
88895 info.high_limit = TASK_SIZE;
88896 info.align_mask = 0;
88897 + info.threadstack_offset = offset;
88898 return vm_unmapped_area(&info);
88899 }
88900 #endif
88901 @@ -1893,6 +2164,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88902 struct mm_struct *mm = current->mm;
88903 unsigned long addr = addr0;
88904 struct vm_unmapped_area_info info;
88905 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88906
88907 /* requested length too big for entire address space */
88908 if (len > TASK_SIZE)
88909 @@ -1901,12 +2173,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88910 if (flags & MAP_FIXED)
88911 return addr;
88912
88913 +#ifdef CONFIG_PAX_RANDMMAP
88914 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88915 +#endif
88916 +
88917 /* requesting a specific address */
88918 if (addr) {
88919 addr = PAGE_ALIGN(addr);
88920 vma = find_vma(mm, addr);
88921 - if (TASK_SIZE - len >= addr &&
88922 - (!vma || addr + len <= vma->vm_start))
88923 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88924 return addr;
88925 }
88926
88927 @@ -1915,6 +2190,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88928 info.low_limit = PAGE_SIZE;
88929 info.high_limit = mm->mmap_base;
88930 info.align_mask = 0;
88931 + info.threadstack_offset = offset;
88932 addr = vm_unmapped_area(&info);
88933
88934 /*
88935 @@ -1927,6 +2203,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88936 VM_BUG_ON(addr != -ENOMEM);
88937 info.flags = 0;
88938 info.low_limit = TASK_UNMAPPED_BASE;
88939 +
88940 +#ifdef CONFIG_PAX_RANDMMAP
88941 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88942 + info.low_limit += mm->delta_mmap;
88943 +#endif
88944 +
88945 info.high_limit = TASK_SIZE;
88946 addr = vm_unmapped_area(&info);
88947 }
88948 @@ -2028,6 +2310,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
88949 return vma;
88950 }
88951
88952 +#ifdef CONFIG_PAX_SEGMEXEC
88953 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
88954 +{
88955 + struct vm_area_struct *vma_m;
88956 +
88957 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
88958 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
88959 + BUG_ON(vma->vm_mirror);
88960 + return NULL;
88961 + }
88962 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
88963 + vma_m = vma->vm_mirror;
88964 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
88965 + BUG_ON(vma->vm_file != vma_m->vm_file);
88966 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
88967 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
88968 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
88969 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
88970 + return vma_m;
88971 +}
88972 +#endif
88973 +
88974 /*
88975 * Verify that the stack growth is acceptable and
88976 * update accounting. This is shared with both the
88977 @@ -2044,6 +2348,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88978 return -ENOMEM;
88979
88980 /* Stack limit test */
88981 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
88982 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
88983 return -ENOMEM;
88984
88985 @@ -2054,6 +2359,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88986 locked = mm->locked_vm + grow;
88987 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88988 limit >>= PAGE_SHIFT;
88989 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88990 if (locked > limit && !capable(CAP_IPC_LOCK))
88991 return -ENOMEM;
88992 }
88993 @@ -2083,37 +2389,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88994 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88995 * vma is the last one with address > vma->vm_end. Have to extend vma.
88996 */
88997 +#ifndef CONFIG_IA64
88998 +static
88999 +#endif
89000 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89001 {
89002 int error;
89003 + bool locknext;
89004
89005 if (!(vma->vm_flags & VM_GROWSUP))
89006 return -EFAULT;
89007
89008 + /* Also guard against wrapping around to address 0. */
89009 + if (address < PAGE_ALIGN(address+1))
89010 + address = PAGE_ALIGN(address+1);
89011 + else
89012 + return -ENOMEM;
89013 +
89014 /*
89015 * We must make sure the anon_vma is allocated
89016 * so that the anon_vma locking is not a noop.
89017 */
89018 if (unlikely(anon_vma_prepare(vma)))
89019 return -ENOMEM;
89020 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
89021 + if (locknext && anon_vma_prepare(vma->vm_next))
89022 + return -ENOMEM;
89023 vma_lock_anon_vma(vma);
89024 + if (locknext)
89025 + vma_lock_anon_vma(vma->vm_next);
89026
89027 /*
89028 * vma->vm_start/vm_end cannot change under us because the caller
89029 * is required to hold the mmap_sem in read mode. We need the
89030 - * anon_vma lock to serialize against concurrent expand_stacks.
89031 - * Also guard against wrapping around to address 0.
89032 + * anon_vma locks to serialize against concurrent expand_stacks
89033 + * and expand_upwards.
89034 */
89035 - if (address < PAGE_ALIGN(address+4))
89036 - address = PAGE_ALIGN(address+4);
89037 - else {
89038 - vma_unlock_anon_vma(vma);
89039 - return -ENOMEM;
89040 - }
89041 error = 0;
89042
89043 /* Somebody else might have raced and expanded it already */
89044 - if (address > vma->vm_end) {
89045 + 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)
89046 + error = -ENOMEM;
89047 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
89048 unsigned long size, grow;
89049
89050 size = address - vma->vm_start;
89051 @@ -2148,6 +2465,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89052 }
89053 }
89054 }
89055 + if (locknext)
89056 + vma_unlock_anon_vma(vma->vm_next);
89057 vma_unlock_anon_vma(vma);
89058 khugepaged_enter_vma_merge(vma);
89059 validate_mm(vma->vm_mm);
89060 @@ -2162,6 +2481,8 @@ int expand_downwards(struct vm_area_struct *vma,
89061 unsigned long address)
89062 {
89063 int error;
89064 + bool lockprev = false;
89065 + struct vm_area_struct *prev;
89066
89067 /*
89068 * We must make sure the anon_vma is allocated
89069 @@ -2175,6 +2496,15 @@ int expand_downwards(struct vm_area_struct *vma,
89070 if (error)
89071 return error;
89072
89073 + prev = vma->vm_prev;
89074 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
89075 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
89076 +#endif
89077 + if (lockprev && anon_vma_prepare(prev))
89078 + return -ENOMEM;
89079 + if (lockprev)
89080 + vma_lock_anon_vma(prev);
89081 +
89082 vma_lock_anon_vma(vma);
89083
89084 /*
89085 @@ -2184,9 +2514,17 @@ int expand_downwards(struct vm_area_struct *vma,
89086 */
89087
89088 /* Somebody else might have raced and expanded it already */
89089 - if (address < vma->vm_start) {
89090 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
89091 + error = -ENOMEM;
89092 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
89093 unsigned long size, grow;
89094
89095 +#ifdef CONFIG_PAX_SEGMEXEC
89096 + struct vm_area_struct *vma_m;
89097 +
89098 + vma_m = pax_find_mirror_vma(vma);
89099 +#endif
89100 +
89101 size = vma->vm_end - address;
89102 grow = (vma->vm_start - address) >> PAGE_SHIFT;
89103
89104 @@ -2211,13 +2549,27 @@ int expand_downwards(struct vm_area_struct *vma,
89105 vma->vm_pgoff -= grow;
89106 anon_vma_interval_tree_post_update_vma(vma);
89107 vma_gap_update(vma);
89108 +
89109 +#ifdef CONFIG_PAX_SEGMEXEC
89110 + if (vma_m) {
89111 + anon_vma_interval_tree_pre_update_vma(vma_m);
89112 + vma_m->vm_start -= grow << PAGE_SHIFT;
89113 + vma_m->vm_pgoff -= grow;
89114 + anon_vma_interval_tree_post_update_vma(vma_m);
89115 + vma_gap_update(vma_m);
89116 + }
89117 +#endif
89118 +
89119 spin_unlock(&vma->vm_mm->page_table_lock);
89120
89121 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
89122 perf_event_mmap(vma);
89123 }
89124 }
89125 }
89126 vma_unlock_anon_vma(vma);
89127 + if (lockprev)
89128 + vma_unlock_anon_vma(prev);
89129 khugepaged_enter_vma_merge(vma);
89130 validate_mm(vma->vm_mm);
89131 return error;
89132 @@ -2315,6 +2667,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
89133 do {
89134 long nrpages = vma_pages(vma);
89135
89136 +#ifdef CONFIG_PAX_SEGMEXEC
89137 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
89138 + vma = remove_vma(vma);
89139 + continue;
89140 + }
89141 +#endif
89142 +
89143 if (vma->vm_flags & VM_ACCOUNT)
89144 nr_accounted += nrpages;
89145 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
89146 @@ -2359,6 +2718,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
89147 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
89148 vma->vm_prev = NULL;
89149 do {
89150 +
89151 +#ifdef CONFIG_PAX_SEGMEXEC
89152 + if (vma->vm_mirror) {
89153 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
89154 + vma->vm_mirror->vm_mirror = NULL;
89155 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
89156 + vma->vm_mirror = NULL;
89157 + }
89158 +#endif
89159 +
89160 vma_rb_erase(vma, &mm->mm_rb);
89161 mm->map_count--;
89162 tail_vma = vma;
89163 @@ -2384,14 +2753,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89164 struct vm_area_struct *new;
89165 int err = -ENOMEM;
89166
89167 +#ifdef CONFIG_PAX_SEGMEXEC
89168 + struct vm_area_struct *vma_m, *new_m = NULL;
89169 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
89170 +#endif
89171 +
89172 if (is_vm_hugetlb_page(vma) && (addr &
89173 ~(huge_page_mask(hstate_vma(vma)))))
89174 return -EINVAL;
89175
89176 +#ifdef CONFIG_PAX_SEGMEXEC
89177 + vma_m = pax_find_mirror_vma(vma);
89178 +#endif
89179 +
89180 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89181 if (!new)
89182 goto out_err;
89183
89184 +#ifdef CONFIG_PAX_SEGMEXEC
89185 + if (vma_m) {
89186 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89187 + if (!new_m) {
89188 + kmem_cache_free(vm_area_cachep, new);
89189 + goto out_err;
89190 + }
89191 + }
89192 +#endif
89193 +
89194 /* most fields are the same, copy all, and then fixup */
89195 *new = *vma;
89196
89197 @@ -2404,6 +2792,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89198 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
89199 }
89200
89201 +#ifdef CONFIG_PAX_SEGMEXEC
89202 + if (vma_m) {
89203 + *new_m = *vma_m;
89204 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
89205 + new_m->vm_mirror = new;
89206 + new->vm_mirror = new_m;
89207 +
89208 + if (new_below)
89209 + new_m->vm_end = addr_m;
89210 + else {
89211 + new_m->vm_start = addr_m;
89212 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
89213 + }
89214 + }
89215 +#endif
89216 +
89217 err = vma_dup_policy(vma, new);
89218 if (err)
89219 goto out_free_vma;
89220 @@ -2423,6 +2827,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89221 else
89222 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
89223
89224 +#ifdef CONFIG_PAX_SEGMEXEC
89225 + if (!err && vma_m) {
89226 + struct mempolicy *pol = vma_policy(new);
89227 +
89228 + if (anon_vma_clone(new_m, vma_m))
89229 + goto out_free_mpol;
89230 +
89231 + mpol_get(pol);
89232 + set_vma_policy(new_m, pol);
89233 +
89234 + if (new_m->vm_file)
89235 + get_file(new_m->vm_file);
89236 +
89237 + if (new_m->vm_ops && new_m->vm_ops->open)
89238 + new_m->vm_ops->open(new_m);
89239 +
89240 + if (new_below)
89241 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
89242 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
89243 + else
89244 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
89245 +
89246 + if (err) {
89247 + if (new_m->vm_ops && new_m->vm_ops->close)
89248 + new_m->vm_ops->close(new_m);
89249 + if (new_m->vm_file)
89250 + fput(new_m->vm_file);
89251 + mpol_put(pol);
89252 + }
89253 + }
89254 +#endif
89255 +
89256 /* Success. */
89257 if (!err)
89258 return 0;
89259 @@ -2432,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89260 new->vm_ops->close(new);
89261 if (new->vm_file)
89262 fput(new->vm_file);
89263 - unlink_anon_vmas(new);
89264 out_free_mpol:
89265 mpol_put(vma_policy(new));
89266 out_free_vma:
89267 +
89268 +#ifdef CONFIG_PAX_SEGMEXEC
89269 + if (new_m) {
89270 + unlink_anon_vmas(new_m);
89271 + kmem_cache_free(vm_area_cachep, new_m);
89272 + }
89273 +#endif
89274 +
89275 + unlink_anon_vmas(new);
89276 kmem_cache_free(vm_area_cachep, new);
89277 out_err:
89278 return err;
89279 @@ -2448,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89280 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89281 unsigned long addr, int new_below)
89282 {
89283 +
89284 +#ifdef CONFIG_PAX_SEGMEXEC
89285 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89286 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
89287 + if (mm->map_count >= sysctl_max_map_count-1)
89288 + return -ENOMEM;
89289 + } else
89290 +#endif
89291 +
89292 if (mm->map_count >= sysctl_max_map_count)
89293 return -ENOMEM;
89294
89295 @@ -2459,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89296 * work. This now handles partial unmappings.
89297 * Jeremy Fitzhardinge <jeremy@goop.org>
89298 */
89299 +#ifdef CONFIG_PAX_SEGMEXEC
89300 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89301 {
89302 + int ret = __do_munmap(mm, start, len);
89303 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
89304 + return ret;
89305 +
89306 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
89307 +}
89308 +
89309 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89310 +#else
89311 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89312 +#endif
89313 +{
89314 unsigned long end;
89315 struct vm_area_struct *vma, *prev, *last;
89316
89317 + /*
89318 + * mm->mmap_sem is required to protect against another thread
89319 + * changing the mappings in case we sleep.
89320 + */
89321 + verify_mm_writelocked(mm);
89322 +
89323 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
89324 return -EINVAL;
89325
89326 @@ -2538,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89327 /* Fix up all other VM information */
89328 remove_vma_list(mm, vma);
89329
89330 + track_exec_limit(mm, start, end, 0UL);
89331 +
89332 return 0;
89333 }
89334
89335 @@ -2546,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
89336 int ret;
89337 struct mm_struct *mm = current->mm;
89338
89339 +
89340 +#ifdef CONFIG_PAX_SEGMEXEC
89341 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
89342 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
89343 + return -EINVAL;
89344 +#endif
89345 +
89346 down_write(&mm->mmap_sem);
89347 ret = do_munmap(mm, start, len);
89348 up_write(&mm->mmap_sem);
89349 @@ -2559,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
89350 return vm_munmap(addr, len);
89351 }
89352
89353 -static inline void verify_mm_writelocked(struct mm_struct *mm)
89354 -{
89355 -#ifdef CONFIG_DEBUG_VM
89356 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89357 - WARN_ON(1);
89358 - up_read(&mm->mmap_sem);
89359 - }
89360 -#endif
89361 -}
89362 -
89363 /*
89364 * this is really a simplified "do_mmap". it only handles
89365 * anonymous maps. eventually we may be able to do some
89366 @@ -2582,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89367 struct rb_node ** rb_link, * rb_parent;
89368 pgoff_t pgoff = addr >> PAGE_SHIFT;
89369 int error;
89370 + unsigned long charged;
89371
89372 len = PAGE_ALIGN(len);
89373 if (!len)
89374 @@ -2589,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89375
89376 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
89377
89378 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
89379 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
89380 + flags &= ~VM_EXEC;
89381 +
89382 +#ifdef CONFIG_PAX_MPROTECT
89383 + if (mm->pax_flags & MF_PAX_MPROTECT)
89384 + flags &= ~VM_MAYEXEC;
89385 +#endif
89386 +
89387 + }
89388 +#endif
89389 +
89390 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
89391 if (error & ~PAGE_MASK)
89392 return error;
89393
89394 + charged = len >> PAGE_SHIFT;
89395 +
89396 /*
89397 * mlock MCL_FUTURE?
89398 */
89399 if (mm->def_flags & VM_LOCKED) {
89400 unsigned long locked, lock_limit;
89401 - locked = len >> PAGE_SHIFT;
89402 + locked = charged;
89403 locked += mm->locked_vm;
89404 lock_limit = rlimit(RLIMIT_MEMLOCK);
89405 lock_limit >>= PAGE_SHIFT;
89406 @@ -2615,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89407 /*
89408 * Clear old maps. this also does some error checking for us
89409 */
89410 - munmap_back:
89411 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89412 if (do_munmap(mm, addr, len))
89413 return -ENOMEM;
89414 - goto munmap_back;
89415 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89416 }
89417
89418 /* Check against address space limits *after* clearing old maps... */
89419 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
89420 + if (!may_expand_vm(mm, charged))
89421 return -ENOMEM;
89422
89423 if (mm->map_count > sysctl_max_map_count)
89424 return -ENOMEM;
89425
89426 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
89427 + if (security_vm_enough_memory_mm(mm, charged))
89428 return -ENOMEM;
89429
89430 /* Can we just expand an old private anonymous mapping? */
89431 @@ -2643,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89432 */
89433 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89434 if (!vma) {
89435 - vm_unacct_memory(len >> PAGE_SHIFT);
89436 + vm_unacct_memory(charged);
89437 return -ENOMEM;
89438 }
89439
89440 @@ -2657,10 +3142,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89441 vma_link(mm, vma, prev, rb_link, rb_parent);
89442 out:
89443 perf_event_mmap(vma);
89444 - mm->total_vm += len >> PAGE_SHIFT;
89445 + mm->total_vm += charged;
89446 if (flags & VM_LOCKED)
89447 - mm->locked_vm += (len >> PAGE_SHIFT);
89448 + mm->locked_vm += charged;
89449 vma->vm_flags |= VM_SOFTDIRTY;
89450 + track_exec_limit(mm, addr, addr + len, flags);
89451 return addr;
89452 }
89453
89454 @@ -2722,6 +3208,7 @@ void exit_mmap(struct mm_struct *mm)
89455 while (vma) {
89456 if (vma->vm_flags & VM_ACCOUNT)
89457 nr_accounted += vma_pages(vma);
89458 + vma->vm_mirror = NULL;
89459 vma = remove_vma(vma);
89460 }
89461 vm_unacct_memory(nr_accounted);
89462 @@ -2738,6 +3225,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89463 struct vm_area_struct *prev;
89464 struct rb_node **rb_link, *rb_parent;
89465
89466 +#ifdef CONFIG_PAX_SEGMEXEC
89467 + struct vm_area_struct *vma_m = NULL;
89468 +#endif
89469 +
89470 + if (security_mmap_addr(vma->vm_start))
89471 + return -EPERM;
89472 +
89473 /*
89474 * The vm_pgoff of a purely anonymous vma should be irrelevant
89475 * until its first write fault, when page's anon_vma and index
89476 @@ -2761,7 +3255,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89477 security_vm_enough_memory_mm(mm, vma_pages(vma)))
89478 return -ENOMEM;
89479
89480 +#ifdef CONFIG_PAX_SEGMEXEC
89481 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
89482 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89483 + if (!vma_m)
89484 + return -ENOMEM;
89485 + }
89486 +#endif
89487 +
89488 vma_link(mm, vma, prev, rb_link, rb_parent);
89489 +
89490 +#ifdef CONFIG_PAX_SEGMEXEC
89491 + if (vma_m)
89492 + BUG_ON(pax_mirror_vma(vma_m, vma));
89493 +#endif
89494 +
89495 return 0;
89496 }
89497
89498 @@ -2780,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89499 struct rb_node **rb_link, *rb_parent;
89500 bool faulted_in_anon_vma = true;
89501
89502 + BUG_ON(vma->vm_mirror);
89503 +
89504 /*
89505 * If anonymous vma has not yet been faulted, update new pgoff
89506 * to match new location, to increase its chance of merging.
89507 @@ -2844,6 +3354,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89508 return NULL;
89509 }
89510
89511 +#ifdef CONFIG_PAX_SEGMEXEC
89512 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
89513 +{
89514 + struct vm_area_struct *prev_m;
89515 + struct rb_node **rb_link_m, *rb_parent_m;
89516 + struct mempolicy *pol_m;
89517 +
89518 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
89519 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
89520 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
89521 + *vma_m = *vma;
89522 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
89523 + if (anon_vma_clone(vma_m, vma))
89524 + return -ENOMEM;
89525 + pol_m = vma_policy(vma_m);
89526 + mpol_get(pol_m);
89527 + set_vma_policy(vma_m, pol_m);
89528 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
89529 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
89530 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
89531 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
89532 + if (vma_m->vm_file)
89533 + get_file(vma_m->vm_file);
89534 + if (vma_m->vm_ops && vma_m->vm_ops->open)
89535 + vma_m->vm_ops->open(vma_m);
89536 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
89537 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
89538 + vma_m->vm_mirror = vma;
89539 + vma->vm_mirror = vma_m;
89540 + return 0;
89541 +}
89542 +#endif
89543 +
89544 /*
89545 * Return true if the calling process may expand its vm space by the passed
89546 * number of pages
89547 @@ -2855,6 +3398,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
89548
89549 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
89550
89551 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
89552 if (cur + npages > lim)
89553 return 0;
89554 return 1;
89555 @@ -2925,6 +3469,22 @@ int install_special_mapping(struct mm_struct *mm,
89556 vma->vm_start = addr;
89557 vma->vm_end = addr + len;
89558
89559 +#ifdef CONFIG_PAX_MPROTECT
89560 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89561 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89562 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
89563 + return -EPERM;
89564 + if (!(vm_flags & VM_EXEC))
89565 + vm_flags &= ~VM_MAYEXEC;
89566 +#else
89567 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89568 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89569 +#endif
89570 + else
89571 + vm_flags &= ~VM_MAYWRITE;
89572 + }
89573 +#endif
89574 +
89575 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
89576 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89577
89578 diff --git a/mm/mprotect.c b/mm/mprotect.c
89579 index 412ba2b..cb41d42 100644
89580 --- a/mm/mprotect.c
89581 +++ b/mm/mprotect.c
89582 @@ -23,10 +23,18 @@
89583 #include <linux/mmu_notifier.h>
89584 #include <linux/migrate.h>
89585 #include <linux/perf_event.h>
89586 +#include <linux/sched/sysctl.h>
89587 +
89588 +#ifdef CONFIG_PAX_MPROTECT
89589 +#include <linux/elf.h>
89590 +#include <linux/binfmts.h>
89591 +#endif
89592 +
89593 #include <asm/uaccess.h>
89594 #include <asm/pgtable.h>
89595 #include <asm/cacheflush.h>
89596 #include <asm/tlbflush.h>
89597 +#include <asm/mmu_context.h>
89598
89599 #ifndef pgprot_modify
89600 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
89601 @@ -236,6 +244,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
89602 return pages;
89603 }
89604
89605 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89606 +/* called while holding the mmap semaphor for writing except stack expansion */
89607 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
89608 +{
89609 + unsigned long oldlimit, newlimit = 0UL;
89610 +
89611 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
89612 + return;
89613 +
89614 + spin_lock(&mm->page_table_lock);
89615 + oldlimit = mm->context.user_cs_limit;
89616 + if ((prot & VM_EXEC) && oldlimit < end)
89617 + /* USER_CS limit moved up */
89618 + newlimit = end;
89619 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
89620 + /* USER_CS limit moved down */
89621 + newlimit = start;
89622 +
89623 + if (newlimit) {
89624 + mm->context.user_cs_limit = newlimit;
89625 +
89626 +#ifdef CONFIG_SMP
89627 + wmb();
89628 + cpus_clear(mm->context.cpu_user_cs_mask);
89629 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
89630 +#endif
89631 +
89632 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
89633 + }
89634 + spin_unlock(&mm->page_table_lock);
89635 + if (newlimit == end) {
89636 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
89637 +
89638 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
89639 + if (is_vm_hugetlb_page(vma))
89640 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
89641 + else
89642 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
89643 + }
89644 +}
89645 +#endif
89646 +
89647 int
89648 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89649 unsigned long start, unsigned long end, unsigned long newflags)
89650 @@ -248,11 +298,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89651 int error;
89652 int dirty_accountable = 0;
89653
89654 +#ifdef CONFIG_PAX_SEGMEXEC
89655 + struct vm_area_struct *vma_m = NULL;
89656 + unsigned long start_m, end_m;
89657 +
89658 + start_m = start + SEGMEXEC_TASK_SIZE;
89659 + end_m = end + SEGMEXEC_TASK_SIZE;
89660 +#endif
89661 +
89662 if (newflags == oldflags) {
89663 *pprev = vma;
89664 return 0;
89665 }
89666
89667 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
89668 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
89669 +
89670 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
89671 + return -ENOMEM;
89672 +
89673 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
89674 + return -ENOMEM;
89675 + }
89676 +
89677 /*
89678 * If we make a private mapping writable we increase our commit;
89679 * but (without finer accounting) cannot reduce our commit if we
89680 @@ -269,6 +337,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89681 }
89682 }
89683
89684 +#ifdef CONFIG_PAX_SEGMEXEC
89685 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
89686 + if (start != vma->vm_start) {
89687 + error = split_vma(mm, vma, start, 1);
89688 + if (error)
89689 + goto fail;
89690 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
89691 + *pprev = (*pprev)->vm_next;
89692 + }
89693 +
89694 + if (end != vma->vm_end) {
89695 + error = split_vma(mm, vma, end, 0);
89696 + if (error)
89697 + goto fail;
89698 + }
89699 +
89700 + if (pax_find_mirror_vma(vma)) {
89701 + error = __do_munmap(mm, start_m, end_m - start_m);
89702 + if (error)
89703 + goto fail;
89704 + } else {
89705 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89706 + if (!vma_m) {
89707 + error = -ENOMEM;
89708 + goto fail;
89709 + }
89710 + vma->vm_flags = newflags;
89711 + error = pax_mirror_vma(vma_m, vma);
89712 + if (error) {
89713 + vma->vm_flags = oldflags;
89714 + goto fail;
89715 + }
89716 + }
89717 + }
89718 +#endif
89719 +
89720 /*
89721 * First try to merge with previous and/or next vma.
89722 */
89723 @@ -299,9 +403,21 @@ success:
89724 * vm_flags and vm_page_prot are protected by the mmap_sem
89725 * held in write mode.
89726 */
89727 +
89728 +#ifdef CONFIG_PAX_SEGMEXEC
89729 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
89730 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
89731 +#endif
89732 +
89733 vma->vm_flags = newflags;
89734 +
89735 +#ifdef CONFIG_PAX_MPROTECT
89736 + if (mm->binfmt && mm->binfmt->handle_mprotect)
89737 + mm->binfmt->handle_mprotect(vma, newflags);
89738 +#endif
89739 +
89740 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
89741 - vm_get_page_prot(newflags));
89742 + vm_get_page_prot(vma->vm_flags));
89743
89744 if (vma_wants_writenotify(vma)) {
89745 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
89746 @@ -340,6 +456,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89747 end = start + len;
89748 if (end <= start)
89749 return -ENOMEM;
89750 +
89751 +#ifdef CONFIG_PAX_SEGMEXEC
89752 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
89753 + if (end > SEGMEXEC_TASK_SIZE)
89754 + return -EINVAL;
89755 + } else
89756 +#endif
89757 +
89758 + if (end > TASK_SIZE)
89759 + return -EINVAL;
89760 +
89761 if (!arch_validate_prot(prot))
89762 return -EINVAL;
89763
89764 @@ -347,7 +474,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89765 /*
89766 * Does the application expect PROT_READ to imply PROT_EXEC:
89767 */
89768 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89769 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89770 prot |= PROT_EXEC;
89771
89772 vm_flags = calc_vm_prot_bits(prot);
89773 @@ -379,6 +506,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89774 if (start > vma->vm_start)
89775 prev = vma;
89776
89777 +#ifdef CONFIG_PAX_MPROTECT
89778 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
89779 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
89780 +#endif
89781 +
89782 for (nstart = start ; ; ) {
89783 unsigned long newflags;
89784
89785 @@ -389,6 +521,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89786
89787 /* newflags >> 4 shift VM_MAY% in place of VM_% */
89788 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
89789 + if (prot & (PROT_WRITE | PROT_EXEC))
89790 + gr_log_rwxmprotect(vma);
89791 +
89792 + error = -EACCES;
89793 + goto out;
89794 + }
89795 +
89796 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
89797 error = -EACCES;
89798 goto out;
89799 }
89800 @@ -403,6 +543,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89801 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
89802 if (error)
89803 goto out;
89804 +
89805 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
89806 +
89807 nstart = tmp;
89808
89809 if (nstart < prev->vm_end)
89810 diff --git a/mm/mremap.c b/mm/mremap.c
89811 index 0843feb..4f5b2e6 100644
89812 --- a/mm/mremap.c
89813 +++ b/mm/mremap.c
89814 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
89815 continue;
89816 pte = ptep_get_and_clear(mm, old_addr, old_pte);
89817 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
89818 +
89819 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89820 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
89821 + pte = pte_exprotect(pte);
89822 +#endif
89823 +
89824 pte = move_soft_dirty_pte(pte);
89825 set_pte_at(mm, new_addr, new_pte, pte);
89826 }
89827 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
89828 if (is_vm_hugetlb_page(vma))
89829 goto Einval;
89830
89831 +#ifdef CONFIG_PAX_SEGMEXEC
89832 + if (pax_find_mirror_vma(vma))
89833 + goto Einval;
89834 +#endif
89835 +
89836 /* We can't remap across vm area boundaries */
89837 if (old_len > vma->vm_end - addr)
89838 goto Efault;
89839 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
89840 unsigned long ret = -EINVAL;
89841 unsigned long charged = 0;
89842 unsigned long map_flags;
89843 + unsigned long pax_task_size = TASK_SIZE;
89844
89845 if (new_addr & ~PAGE_MASK)
89846 goto out;
89847
89848 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
89849 +#ifdef CONFIG_PAX_SEGMEXEC
89850 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89851 + pax_task_size = SEGMEXEC_TASK_SIZE;
89852 +#endif
89853 +
89854 + pax_task_size -= PAGE_SIZE;
89855 +
89856 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
89857 goto out;
89858
89859 /* Check if the location we're moving into overlaps the
89860 * old location at all, and fail if it does.
89861 */
89862 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
89863 - goto out;
89864 -
89865 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
89866 + if (addr + old_len > new_addr && new_addr + new_len > addr)
89867 goto out;
89868
89869 ret = do_munmap(mm, new_addr, new_len);
89870 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89871 unsigned long ret = -EINVAL;
89872 unsigned long charged = 0;
89873 bool locked = false;
89874 + unsigned long pax_task_size = TASK_SIZE;
89875
89876 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
89877 return ret;
89878 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89879 if (!new_len)
89880 return ret;
89881
89882 +#ifdef CONFIG_PAX_SEGMEXEC
89883 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89884 + pax_task_size = SEGMEXEC_TASK_SIZE;
89885 +#endif
89886 +
89887 + pax_task_size -= PAGE_SIZE;
89888 +
89889 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
89890 + old_len > pax_task_size || addr > pax_task_size-old_len)
89891 + return ret;
89892 +
89893 down_write(&current->mm->mmap_sem);
89894
89895 if (flags & MREMAP_FIXED) {
89896 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89897 new_addr = addr;
89898 }
89899 ret = addr;
89900 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
89901 goto out;
89902 }
89903 }
89904 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89905 goto out;
89906 }
89907
89908 + map_flags = vma->vm_flags;
89909 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
89910 + if (!(ret & ~PAGE_MASK)) {
89911 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
89912 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
89913 + }
89914 }
89915 out:
89916 if (ret & ~PAGE_MASK)
89917 diff --git a/mm/nommu.c b/mm/nommu.c
89918 index ecd1f15..77039bd 100644
89919 --- a/mm/nommu.c
89920 +++ b/mm/nommu.c
89921 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
89922 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
89923 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89924 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89925 -int heap_stack_gap = 0;
89926
89927 atomic_long_t mmap_pages_allocated;
89928
89929 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
89930 EXPORT_SYMBOL(find_vma);
89931
89932 /*
89933 - * find a VMA
89934 - * - we don't extend stack VMAs under NOMMU conditions
89935 - */
89936 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
89937 -{
89938 - return find_vma(mm, addr);
89939 -}
89940 -
89941 -/*
89942 * expand a stack to a given address
89943 * - not supported under NOMMU conditions
89944 */
89945 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89946
89947 /* most fields are the same, copy all, and then fixup */
89948 *new = *vma;
89949 + INIT_LIST_HEAD(&new->anon_vma_chain);
89950 *region = *vma->vm_region;
89951 new->vm_region = region;
89952
89953 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
89954 }
89955 EXPORT_SYMBOL(generic_file_remap_pages);
89956
89957 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89958 - unsigned long addr, void *buf, int len, int write)
89959 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89960 + unsigned long addr, void *buf, size_t len, int write)
89961 {
89962 struct vm_area_struct *vma;
89963
89964 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89965 *
89966 * The caller must hold a reference on @mm.
89967 */
89968 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89969 - void *buf, int len, int write)
89970 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89971 + void *buf, size_t len, int write)
89972 {
89973 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89974 }
89975 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89976 * Access another process' address space.
89977 * - source/target buffer must be kernel space
89978 */
89979 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
89980 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
89981 {
89982 struct mm_struct *mm;
89983
89984 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
89985 index 6380758..4064aec 100644
89986 --- a/mm/page-writeback.c
89987 +++ b/mm/page-writeback.c
89988 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
89989 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89990 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89991 */
89992 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89993 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89994 unsigned long thresh,
89995 unsigned long bg_thresh,
89996 unsigned long dirty,
89997 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89998 index dd886fa..7686339 100644
89999 --- a/mm/page_alloc.c
90000 +++ b/mm/page_alloc.c
90001 @@ -61,6 +61,7 @@
90002 #include <linux/page-debug-flags.h>
90003 #include <linux/hugetlb.h>
90004 #include <linux/sched/rt.h>
90005 +#include <linux/random.h>
90006
90007 #include <asm/sections.h>
90008 #include <asm/tlbflush.h>
90009 @@ -354,7 +355,7 @@ out:
90010 * This usage means that zero-order pages may not be compound.
90011 */
90012
90013 -static void free_compound_page(struct page *page)
90014 +void free_compound_page(struct page *page)
90015 {
90016 __free_pages_ok(page, compound_order(page));
90017 }
90018 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90019 int i;
90020 int bad = 0;
90021
90022 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90023 + unsigned long index = 1UL << order;
90024 +#endif
90025 +
90026 trace_mm_page_free(page, order);
90027 kmemcheck_free_shadow(page, order);
90028
90029 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90030 debug_check_no_obj_freed(page_address(page),
90031 PAGE_SIZE << order);
90032 }
90033 +
90034 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90035 + for (; index; --index)
90036 + sanitize_highpage(page + index - 1);
90037 +#endif
90038 +
90039 arch_free_page(page, order);
90040 kernel_map_pages(page, 1 << order, 0);
90041
90042 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
90043 local_irq_restore(flags);
90044 }
90045
90046 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90047 +bool __meminitdata extra_latent_entropy;
90048 +
90049 +static int __init setup_pax_extra_latent_entropy(char *str)
90050 +{
90051 + extra_latent_entropy = true;
90052 + return 0;
90053 +}
90054 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
90055 +
90056 +volatile u64 latent_entropy __latent_entropy;
90057 +EXPORT_SYMBOL(latent_entropy);
90058 +#endif
90059 +
90060 void __init __free_pages_bootmem(struct page *page, unsigned int order)
90061 {
90062 unsigned int nr_pages = 1 << order;
90063 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
90064 __ClearPageReserved(p);
90065 set_page_count(p, 0);
90066
90067 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90068 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
90069 + u64 hash = 0;
90070 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
90071 + const u64 *data = lowmem_page_address(page);
90072 +
90073 + for (index = 0; index < end; index++)
90074 + hash ^= hash + data[index];
90075 + latent_entropy ^= hash;
90076 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
90077 + }
90078 +#endif
90079 +
90080 page_zone(page)->managed_pages += nr_pages;
90081 set_page_refcounted(page);
90082 __free_pages(page, order);
90083 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
90084 arch_alloc_page(page, order);
90085 kernel_map_pages(page, 1 << order, 1);
90086
90087 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
90088 if (gfp_flags & __GFP_ZERO)
90089 prep_zero_page(page, order, gfp_flags);
90090 +#endif
90091
90092 if (order && (gfp_flags & __GFP_COMP))
90093 prep_compound_page(page, order);
90094 diff --git a/mm/page_io.c b/mm/page_io.c
90095 index 8c79a47..a689e0d 100644
90096 --- a/mm/page_io.c
90097 +++ b/mm/page_io.c
90098 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
90099 struct file *swap_file = sis->swap_file;
90100 struct address_space *mapping = swap_file->f_mapping;
90101 struct iovec iov = {
90102 - .iov_base = kmap(page),
90103 + .iov_base = (void __force_user *)kmap(page),
90104 .iov_len = PAGE_SIZE,
90105 };
90106
90107 diff --git a/mm/percpu.c b/mm/percpu.c
90108 index 8c8e08f..73a5cda 100644
90109 --- a/mm/percpu.c
90110 +++ b/mm/percpu.c
90111 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
90112 static unsigned int pcpu_high_unit_cpu __read_mostly;
90113
90114 /* the address of the first chunk which starts with the kernel static area */
90115 -void *pcpu_base_addr __read_mostly;
90116 +void *pcpu_base_addr __read_only;
90117 EXPORT_SYMBOL_GPL(pcpu_base_addr);
90118
90119 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
90120 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
90121 index fd26d04..0cea1b0 100644
90122 --- a/mm/process_vm_access.c
90123 +++ b/mm/process_vm_access.c
90124 @@ -13,6 +13,7 @@
90125 #include <linux/uio.h>
90126 #include <linux/sched.h>
90127 #include <linux/highmem.h>
90128 +#include <linux/security.h>
90129 #include <linux/ptrace.h>
90130 #include <linux/slab.h>
90131 #include <linux/syscalls.h>
90132 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90133 size_t iov_l_curr_offset = 0;
90134 ssize_t iov_len;
90135
90136 + return -ENOSYS; // PaX: until properly audited
90137 +
90138 /*
90139 * Work out how many pages of struct pages we're going to need
90140 * when eventually calling get_user_pages
90141 */
90142 for (i = 0; i < riovcnt; i++) {
90143 iov_len = rvec[i].iov_len;
90144 - if (iov_len > 0) {
90145 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
90146 - + iov_len)
90147 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
90148 - / PAGE_SIZE + 1;
90149 - nr_pages = max(nr_pages, nr_pages_iov);
90150 - }
90151 + if (iov_len <= 0)
90152 + continue;
90153 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
90154 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
90155 + nr_pages = max(nr_pages, nr_pages_iov);
90156 }
90157
90158 if (nr_pages == 0)
90159 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90160 goto free_proc_pages;
90161 }
90162
90163 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
90164 + rc = -EPERM;
90165 + goto put_task_struct;
90166 + }
90167 +
90168 mm = mm_access(task, PTRACE_MODE_ATTACH);
90169 if (!mm || IS_ERR(mm)) {
90170 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
90171 diff --git a/mm/rmap.c b/mm/rmap.c
90172 index fd3ee7a..3613079 100644
90173 --- a/mm/rmap.c
90174 +++ b/mm/rmap.c
90175 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90176 struct anon_vma *anon_vma = vma->anon_vma;
90177 struct anon_vma_chain *avc;
90178
90179 +#ifdef CONFIG_PAX_SEGMEXEC
90180 + struct anon_vma_chain *avc_m = NULL;
90181 +#endif
90182 +
90183 might_sleep();
90184 if (unlikely(!anon_vma)) {
90185 struct mm_struct *mm = vma->vm_mm;
90186 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90187 if (!avc)
90188 goto out_enomem;
90189
90190 +#ifdef CONFIG_PAX_SEGMEXEC
90191 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
90192 + if (!avc_m)
90193 + goto out_enomem_free_avc;
90194 +#endif
90195 +
90196 anon_vma = find_mergeable_anon_vma(vma);
90197 allocated = NULL;
90198 if (!anon_vma) {
90199 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90200 /* page_table_lock to protect against threads */
90201 spin_lock(&mm->page_table_lock);
90202 if (likely(!vma->anon_vma)) {
90203 +
90204 +#ifdef CONFIG_PAX_SEGMEXEC
90205 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
90206 +
90207 + if (vma_m) {
90208 + BUG_ON(vma_m->anon_vma);
90209 + vma_m->anon_vma = anon_vma;
90210 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
90211 + avc_m = NULL;
90212 + }
90213 +#endif
90214 +
90215 vma->anon_vma = anon_vma;
90216 anon_vma_chain_link(vma, avc, anon_vma);
90217 allocated = NULL;
90218 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90219
90220 if (unlikely(allocated))
90221 put_anon_vma(allocated);
90222 +
90223 +#ifdef CONFIG_PAX_SEGMEXEC
90224 + if (unlikely(avc_m))
90225 + anon_vma_chain_free(avc_m);
90226 +#endif
90227 +
90228 if (unlikely(avc))
90229 anon_vma_chain_free(avc);
90230 }
90231 return 0;
90232
90233 out_enomem_free_avc:
90234 +
90235 +#ifdef CONFIG_PAX_SEGMEXEC
90236 + if (avc_m)
90237 + anon_vma_chain_free(avc_m);
90238 +#endif
90239 +
90240 anon_vma_chain_free(avc);
90241 out_enomem:
90242 return -ENOMEM;
90243 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
90244 * Attach the anon_vmas from src to dst.
90245 * Returns 0 on success, -ENOMEM on failure.
90246 */
90247 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90248 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
90249 {
90250 struct anon_vma_chain *avc, *pavc;
90251 struct anon_vma *root = NULL;
90252 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90253 * the corresponding VMA in the parent process is attached to.
90254 * Returns 0 on success, non-zero on failure.
90255 */
90256 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
90257 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
90258 {
90259 struct anon_vma_chain *avc;
90260 struct anon_vma *anon_vma;
90261 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
90262 void __init anon_vma_init(void)
90263 {
90264 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
90265 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
90266 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
90267 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
90268 + anon_vma_ctor);
90269 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
90270 + SLAB_PANIC|SLAB_NO_SANITIZE);
90271 }
90272
90273 /*
90274 diff --git a/mm/shmem.c b/mm/shmem.c
90275 index 8297623..6b9dfe9 100644
90276 --- a/mm/shmem.c
90277 +++ b/mm/shmem.c
90278 @@ -33,7 +33,7 @@
90279 #include <linux/swap.h>
90280 #include <linux/aio.h>
90281
90282 -static struct vfsmount *shm_mnt;
90283 +struct vfsmount *shm_mnt;
90284
90285 #ifdef CONFIG_SHMEM
90286 /*
90287 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
90288 #define BOGO_DIRENT_SIZE 20
90289
90290 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
90291 -#define SHORT_SYMLINK_LEN 128
90292 +#define SHORT_SYMLINK_LEN 64
90293
90294 /*
90295 * shmem_fallocate and shmem_writepage communicate via inode->i_private
90296 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
90297 static int shmem_xattr_validate(const char *name)
90298 {
90299 struct { const char *prefix; size_t len; } arr[] = {
90300 +
90301 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90302 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
90303 +#endif
90304 +
90305 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
90306 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
90307 };
90308 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
90309 if (err)
90310 return err;
90311
90312 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90313 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
90314 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
90315 + return -EOPNOTSUPP;
90316 + if (size > 8)
90317 + return -EINVAL;
90318 + }
90319 +#endif
90320 +
90321 return simple_xattr_set(&info->xattrs, name, value, size, flags);
90322 }
90323
90324 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
90325 int err = -ENOMEM;
90326
90327 /* Round up to L1_CACHE_BYTES to resist false sharing */
90328 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
90329 - L1_CACHE_BYTES), GFP_KERNEL);
90330 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
90331 if (!sbinfo)
90332 return -ENOMEM;
90333
90334 diff --git a/mm/slab.c b/mm/slab.c
90335 index 2580db0..0523956 100644
90336 --- a/mm/slab.c
90337 +++ b/mm/slab.c
90338 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90339 if ((x)->max_freeable < i) \
90340 (x)->max_freeable = i; \
90341 } while (0)
90342 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
90343 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
90344 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
90345 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
90346 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
90347 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
90348 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
90349 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
90350 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
90351 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
90352 #else
90353 #define STATS_INC_ACTIVE(x) do { } while (0)
90354 #define STATS_DEC_ACTIVE(x) do { } while (0)
90355 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90356 #define STATS_INC_ALLOCMISS(x) do { } while (0)
90357 #define STATS_INC_FREEHIT(x) do { } while (0)
90358 #define STATS_INC_FREEMISS(x) do { } while (0)
90359 +#define STATS_INC_SANITIZED(x) do { } while (0)
90360 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
90361 #endif
90362
90363 #if DEBUG
90364 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
90365 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
90366 */
90367 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
90368 - const struct slab *slab, void *obj)
90369 + const struct slab *slab, const void *obj)
90370 {
90371 u32 offset = (obj - slab->s_mem);
90372 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
90373 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
90374 */
90375
90376 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
90377 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
90378 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90379
90380 if (INDEX_AC != INDEX_NODE)
90381 kmalloc_caches[INDEX_NODE] =
90382 create_kmalloc_cache("kmalloc-node",
90383 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
90384 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90385
90386 slab_early_init = 0;
90387
90388 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
90389 struct array_cache *ac = cpu_cache_get(cachep);
90390
90391 check_irq_off();
90392 +
90393 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90394 + if (pax_sanitize_slab) {
90395 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
90396 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
90397 +
90398 + if (cachep->ctor)
90399 + cachep->ctor(objp);
90400 +
90401 + STATS_INC_SANITIZED(cachep);
90402 + } else
90403 + STATS_INC_NOT_SANITIZED(cachep);
90404 + }
90405 +#endif
90406 +
90407 kmemleak_free_recursive(objp, cachep->flags);
90408 objp = cache_free_debugcheck(cachep, objp, caller);
90409
90410 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
90411
90412 if (unlikely(ZERO_OR_NULL_PTR(objp)))
90413 return;
90414 + VM_BUG_ON(!virt_addr_valid(objp));
90415 local_irq_save(flags);
90416 kfree_debugcheck(objp);
90417 c = virt_to_cache(objp);
90418 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
90419 }
90420 /* cpu stats */
90421 {
90422 - unsigned long allochit = atomic_read(&cachep->allochit);
90423 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
90424 - unsigned long freehit = atomic_read(&cachep->freehit);
90425 - unsigned long freemiss = atomic_read(&cachep->freemiss);
90426 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
90427 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
90428 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
90429 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
90430
90431 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
90432 allochit, allocmiss, freehit, freemiss);
90433 }
90434 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90435 + {
90436 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
90437 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
90438 +
90439 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
90440 + }
90441 +#endif
90442 #endif
90443 }
90444
90445 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
90446 static int __init slab_proc_init(void)
90447 {
90448 #ifdef CONFIG_DEBUG_SLAB_LEAK
90449 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
90450 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
90451 #endif
90452 return 0;
90453 }
90454 module_init(slab_proc_init);
90455 #endif
90456
90457 +bool is_usercopy_object(const void *ptr)
90458 +{
90459 + struct page *page;
90460 + struct kmem_cache *cachep;
90461 +
90462 + if (ZERO_OR_NULL_PTR(ptr))
90463 + return false;
90464 +
90465 + if (!slab_is_available())
90466 + return false;
90467 +
90468 + if (!virt_addr_valid(ptr))
90469 + return false;
90470 +
90471 + page = virt_to_head_page(ptr);
90472 +
90473 + if (!PageSlab(page))
90474 + return false;
90475 +
90476 + cachep = page->slab_cache;
90477 + return cachep->flags & SLAB_USERCOPY;
90478 +}
90479 +
90480 +#ifdef CONFIG_PAX_USERCOPY
90481 +const char *check_heap_object(const void *ptr, unsigned long n)
90482 +{
90483 + struct page *page;
90484 + struct kmem_cache *cachep;
90485 + struct slab *slabp;
90486 + unsigned int objnr;
90487 + unsigned long offset;
90488 +
90489 + if (ZERO_OR_NULL_PTR(ptr))
90490 + return "<null>";
90491 +
90492 + if (!virt_addr_valid(ptr))
90493 + return NULL;
90494 +
90495 + page = virt_to_head_page(ptr);
90496 +
90497 + if (!PageSlab(page))
90498 + return NULL;
90499 +
90500 + cachep = page->slab_cache;
90501 + if (!(cachep->flags & SLAB_USERCOPY))
90502 + return cachep->name;
90503 +
90504 + slabp = page->slab_page;
90505 + objnr = obj_to_index(cachep, slabp, ptr);
90506 + BUG_ON(objnr >= cachep->num);
90507 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
90508 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
90509 + return NULL;
90510 +
90511 + return cachep->name;
90512 +}
90513 +#endif
90514 +
90515 /**
90516 * ksize - get the actual amount of memory allocated for a given object
90517 * @objp: Pointer to the object
90518 diff --git a/mm/slab.h b/mm/slab.h
90519 index a535033..2f98fe5 100644
90520 --- a/mm/slab.h
90521 +++ b/mm/slab.h
90522 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
90523 /* The slab cache that manages slab cache information */
90524 extern struct kmem_cache *kmem_cache;
90525
90526 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90527 +#ifdef CONFIG_X86_64
90528 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
90529 +#else
90530 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
90531 +#endif
90532 +extern bool pax_sanitize_slab;
90533 +#endif
90534 +
90535 unsigned long calculate_alignment(unsigned long flags,
90536 unsigned long align, unsigned long size);
90537
90538 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90539
90540 /* Legal flag mask for kmem_cache_create(), for various configurations */
90541 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
90542 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
90543 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
90544 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
90545
90546 #if defined(CONFIG_DEBUG_SLAB)
90547 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
90548 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
90549 return s;
90550
90551 page = virt_to_head_page(x);
90552 +
90553 + BUG_ON(!PageSlab(page));
90554 +
90555 cachep = page->slab_cache;
90556 if (slab_equal_or_root(cachep, s))
90557 return cachep;
90558 diff --git a/mm/slab_common.c b/mm/slab_common.c
90559 index e2e98af..3b1a163 100644
90560 --- a/mm/slab_common.c
90561 +++ b/mm/slab_common.c
90562 @@ -23,11 +23,22 @@
90563
90564 #include "slab.h"
90565
90566 -enum slab_state slab_state;
90567 +enum slab_state slab_state __read_only;
90568 LIST_HEAD(slab_caches);
90569 DEFINE_MUTEX(slab_mutex);
90570 struct kmem_cache *kmem_cache;
90571
90572 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90573 +bool pax_sanitize_slab __read_only = true;
90574 +static int __init pax_sanitize_slab_setup(char *str)
90575 +{
90576 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
90577 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
90578 + return 1;
90579 +}
90580 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
90581 +#endif
90582 +
90583 #ifdef CONFIG_DEBUG_VM
90584 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
90585 size_t size)
90586 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
90587
90588 err = __kmem_cache_create(s, flags);
90589 if (!err) {
90590 - s->refcount = 1;
90591 + atomic_set(&s->refcount, 1);
90592 list_add(&s->list, &slab_caches);
90593 memcg_cache_list_add(memcg, s);
90594 } else {
90595 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
90596
90597 get_online_cpus();
90598 mutex_lock(&slab_mutex);
90599 - s->refcount--;
90600 - if (!s->refcount) {
90601 + if (atomic_dec_and_test(&s->refcount)) {
90602 list_del(&s->list);
90603
90604 if (!__kmem_cache_shutdown(s)) {
90605 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
90606 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
90607 name, size, err);
90608
90609 - s->refcount = -1; /* Exempt from merging for now */
90610 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
90611 }
90612
90613 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90614 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90615
90616 create_boot_cache(s, name, size, flags);
90617 list_add(&s->list, &slab_caches);
90618 - s->refcount = 1;
90619 + atomic_set(&s->refcount, 1);
90620 return s;
90621 }
90622
90623 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
90624 EXPORT_SYMBOL(kmalloc_dma_caches);
90625 #endif
90626
90627 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90628 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
90629 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
90630 +#endif
90631 +
90632 /*
90633 * Conversion table for small slabs sizes / 8 to the index in the
90634 * kmalloc array. This is necessary for slabs < 192 since we have non power
90635 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
90636 return kmalloc_dma_caches[index];
90637
90638 #endif
90639 +
90640 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90641 + if (unlikely((flags & GFP_USERCOPY)))
90642 + return kmalloc_usercopy_caches[index];
90643 +
90644 +#endif
90645 +
90646 return kmalloc_caches[index];
90647 }
90648
90649 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
90650 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
90651 if (!kmalloc_caches[i]) {
90652 kmalloc_caches[i] = create_kmalloc_cache(NULL,
90653 - 1 << i, flags);
90654 + 1 << i, SLAB_USERCOPY | flags);
90655 }
90656
90657 /*
90658 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
90659 * earlier power of two caches
90660 */
90661 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
90662 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
90663 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
90664
90665 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
90666 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
90667 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
90668 }
90669
90670 /* Kmalloc array is now usable */
90671 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
90672 }
90673 }
90674 #endif
90675 +
90676 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90677 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
90678 + struct kmem_cache *s = kmalloc_caches[i];
90679 +
90680 + if (s) {
90681 + int size = kmalloc_size(i);
90682 + char *n = kasprintf(GFP_NOWAIT,
90683 + "usercopy-kmalloc-%d", size);
90684 +
90685 + BUG_ON(!n);
90686 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
90687 + size, SLAB_USERCOPY | flags);
90688 + }
90689 + }
90690 +#endif
90691 +
90692 }
90693 #endif /* !CONFIG_SLOB */
90694
90695 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
90696 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
90697 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
90698 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
90699 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90700 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
90701 +#endif
90702 #endif
90703 seq_putc(m, '\n');
90704 }
90705 diff --git a/mm/slob.c b/mm/slob.c
90706 index 4bf8809..98a6914 100644
90707 --- a/mm/slob.c
90708 +++ b/mm/slob.c
90709 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
90710 /*
90711 * Return the size of a slob block.
90712 */
90713 -static slobidx_t slob_units(slob_t *s)
90714 +static slobidx_t slob_units(const slob_t *s)
90715 {
90716 if (s->units > 0)
90717 return s->units;
90718 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
90719 /*
90720 * Return the next free slob block pointer after this one.
90721 */
90722 -static slob_t *slob_next(slob_t *s)
90723 +static slob_t *slob_next(const slob_t *s)
90724 {
90725 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
90726 slobidx_t next;
90727 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
90728 /*
90729 * Returns true if s is the last free block in its page.
90730 */
90731 -static int slob_last(slob_t *s)
90732 +static int slob_last(const slob_t *s)
90733 {
90734 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
90735 }
90736
90737 -static void *slob_new_pages(gfp_t gfp, int order, int node)
90738 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
90739 {
90740 - void *page;
90741 + struct page *page;
90742
90743 #ifdef CONFIG_NUMA
90744 if (node != NUMA_NO_NODE)
90745 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
90746 if (!page)
90747 return NULL;
90748
90749 - return page_address(page);
90750 + __SetPageSlab(page);
90751 + return page;
90752 }
90753
90754 -static void slob_free_pages(void *b, int order)
90755 +static void slob_free_pages(struct page *sp, int order)
90756 {
90757 if (current->reclaim_state)
90758 current->reclaim_state->reclaimed_slab += 1 << order;
90759 - free_pages((unsigned long)b, order);
90760 + __ClearPageSlab(sp);
90761 + page_mapcount_reset(sp);
90762 + sp->private = 0;
90763 + __free_pages(sp, order);
90764 }
90765
90766 /*
90767 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
90768
90769 /* Not enough space: must allocate a new page */
90770 if (!b) {
90771 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90772 - if (!b)
90773 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90774 + if (!sp)
90775 return NULL;
90776 - sp = virt_to_page(b);
90777 - __SetPageSlab(sp);
90778 + b = page_address(sp);
90779
90780 spin_lock_irqsave(&slob_lock, flags);
90781 sp->units = SLOB_UNITS(PAGE_SIZE);
90782 sp->freelist = b;
90783 + sp->private = 0;
90784 INIT_LIST_HEAD(&sp->list);
90785 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
90786 set_slob_page_free(sp, slob_list);
90787 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
90788 if (slob_page_free(sp))
90789 clear_slob_page_free(sp);
90790 spin_unlock_irqrestore(&slob_lock, flags);
90791 - __ClearPageSlab(sp);
90792 - page_mapcount_reset(sp);
90793 - slob_free_pages(b, 0);
90794 + slob_free_pages(sp, 0);
90795 return;
90796 }
90797
90798 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90799 + if (pax_sanitize_slab)
90800 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
90801 +#endif
90802 +
90803 if (!slob_page_free(sp)) {
90804 /* This slob page is about to become partially free. Easy! */
90805 sp->units = units;
90806 @@ -424,11 +431,10 @@ out:
90807 */
90808
90809 static __always_inline void *
90810 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90811 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
90812 {
90813 - unsigned int *m;
90814 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90815 - void *ret;
90816 + slob_t *m;
90817 + void *ret = NULL;
90818
90819 gfp &= gfp_allowed_mask;
90820
90821 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90822
90823 if (!m)
90824 return NULL;
90825 - *m = size;
90826 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
90827 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
90828 + m[0].units = size;
90829 + m[1].units = align;
90830 ret = (void *)m + align;
90831
90832 trace_kmalloc_node(caller, ret,
90833 size, size + align, gfp, node);
90834 } else {
90835 unsigned int order = get_order(size);
90836 + struct page *page;
90837
90838 if (likely(order))
90839 gfp |= __GFP_COMP;
90840 - ret = slob_new_pages(gfp, order, node);
90841 + page = slob_new_pages(gfp, order, node);
90842 + if (page) {
90843 + ret = page_address(page);
90844 + page->private = size;
90845 + }
90846
90847 trace_kmalloc_node(caller, ret,
90848 size, PAGE_SIZE << order, gfp, node);
90849 }
90850
90851 - kmemleak_alloc(ret, size, 1, gfp);
90852 + return ret;
90853 +}
90854 +
90855 +static __always_inline void *
90856 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90857 +{
90858 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90859 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
90860 +
90861 + if (!ZERO_OR_NULL_PTR(ret))
90862 + kmemleak_alloc(ret, size, 1, gfp);
90863 return ret;
90864 }
90865
90866 @@ -493,34 +517,112 @@ void kfree(const void *block)
90867 return;
90868 kmemleak_free(block);
90869
90870 + VM_BUG_ON(!virt_addr_valid(block));
90871 sp = virt_to_page(block);
90872 - if (PageSlab(sp)) {
90873 + VM_BUG_ON(!PageSlab(sp));
90874 + if (!sp->private) {
90875 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90876 - unsigned int *m = (unsigned int *)(block - align);
90877 - slob_free(m, *m + align);
90878 - } else
90879 + slob_t *m = (slob_t *)(block - align);
90880 + slob_free(m, m[0].units + align);
90881 + } else {
90882 + __ClearPageSlab(sp);
90883 + page_mapcount_reset(sp);
90884 + sp->private = 0;
90885 __free_pages(sp, compound_order(sp));
90886 + }
90887 }
90888 EXPORT_SYMBOL(kfree);
90889
90890 +bool is_usercopy_object(const void *ptr)
90891 +{
90892 + if (!slab_is_available())
90893 + return false;
90894 +
90895 + // PAX: TODO
90896 +
90897 + return false;
90898 +}
90899 +
90900 +#ifdef CONFIG_PAX_USERCOPY
90901 +const char *check_heap_object(const void *ptr, unsigned long n)
90902 +{
90903 + struct page *page;
90904 + const slob_t *free;
90905 + const void *base;
90906 + unsigned long flags;
90907 +
90908 + if (ZERO_OR_NULL_PTR(ptr))
90909 + return "<null>";
90910 +
90911 + if (!virt_addr_valid(ptr))
90912 + return NULL;
90913 +
90914 + page = virt_to_head_page(ptr);
90915 + if (!PageSlab(page))
90916 + return NULL;
90917 +
90918 + if (page->private) {
90919 + base = page;
90920 + if (base <= ptr && n <= page->private - (ptr - base))
90921 + return NULL;
90922 + return "<slob>";
90923 + }
90924 +
90925 + /* some tricky double walking to find the chunk */
90926 + spin_lock_irqsave(&slob_lock, flags);
90927 + base = (void *)((unsigned long)ptr & PAGE_MASK);
90928 + free = page->freelist;
90929 +
90930 + while (!slob_last(free) && (void *)free <= ptr) {
90931 + base = free + slob_units(free);
90932 + free = slob_next(free);
90933 + }
90934 +
90935 + while (base < (void *)free) {
90936 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
90937 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
90938 + int offset;
90939 +
90940 + if (ptr < base + align)
90941 + break;
90942 +
90943 + offset = ptr - base - align;
90944 + if (offset >= m) {
90945 + base += size;
90946 + continue;
90947 + }
90948 +
90949 + if (n > m - offset)
90950 + break;
90951 +
90952 + spin_unlock_irqrestore(&slob_lock, flags);
90953 + return NULL;
90954 + }
90955 +
90956 + spin_unlock_irqrestore(&slob_lock, flags);
90957 + return "<slob>";
90958 +}
90959 +#endif
90960 +
90961 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
90962 size_t ksize(const void *block)
90963 {
90964 struct page *sp;
90965 int align;
90966 - unsigned int *m;
90967 + slob_t *m;
90968
90969 BUG_ON(!block);
90970 if (unlikely(block == ZERO_SIZE_PTR))
90971 return 0;
90972
90973 sp = virt_to_page(block);
90974 - if (unlikely(!PageSlab(sp)))
90975 - return PAGE_SIZE << compound_order(sp);
90976 + VM_BUG_ON(!PageSlab(sp));
90977 + if (sp->private)
90978 + return sp->private;
90979
90980 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90981 - m = (unsigned int *)(block - align);
90982 - return SLOB_UNITS(*m) * SLOB_UNIT;
90983 + m = (slob_t *)(block - align);
90984 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
90985 }
90986 EXPORT_SYMBOL(ksize);
90987
90988 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90989
90990 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90991 {
90992 - void *b;
90993 + void *b = NULL;
90994
90995 flags &= gfp_allowed_mask;
90996
90997 lockdep_trace_alloc(flags);
90998
90999 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91000 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
91001 +#else
91002 if (c->size < PAGE_SIZE) {
91003 b = slob_alloc(c->size, flags, c->align, node);
91004 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91005 SLOB_UNITS(c->size) * SLOB_UNIT,
91006 flags, node);
91007 } else {
91008 - b = slob_new_pages(flags, get_order(c->size), node);
91009 + struct page *sp;
91010 +
91011 + sp = slob_new_pages(flags, get_order(c->size), node);
91012 + if (sp) {
91013 + b = page_address(sp);
91014 + sp->private = c->size;
91015 + }
91016 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91017 PAGE_SIZE << get_order(c->size),
91018 flags, node);
91019 }
91020 +#endif
91021
91022 if (b && c->ctor)
91023 c->ctor(b);
91024 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
91025
91026 static void __kmem_cache_free(void *b, int size)
91027 {
91028 - if (size < PAGE_SIZE)
91029 + struct page *sp;
91030 +
91031 + sp = virt_to_page(b);
91032 + BUG_ON(!PageSlab(sp));
91033 + if (!sp->private)
91034 slob_free(b, size);
91035 else
91036 - slob_free_pages(b, get_order(size));
91037 + slob_free_pages(sp, get_order(size));
91038 }
91039
91040 static void kmem_rcu_free(struct rcu_head *head)
91041 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
91042
91043 void kmem_cache_free(struct kmem_cache *c, void *b)
91044 {
91045 + int size = c->size;
91046 +
91047 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91048 + if (size + c->align < PAGE_SIZE) {
91049 + size += c->align;
91050 + b -= c->align;
91051 + }
91052 +#endif
91053 +
91054 kmemleak_free_recursive(b, c->flags);
91055 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
91056 struct slob_rcu *slob_rcu;
91057 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
91058 - slob_rcu->size = c->size;
91059 + slob_rcu = b + (size - sizeof(struct slob_rcu));
91060 + slob_rcu->size = size;
91061 call_rcu(&slob_rcu->head, kmem_rcu_free);
91062 } else {
91063 - __kmem_cache_free(b, c->size);
91064 + __kmem_cache_free(b, size);
91065 }
91066
91067 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91068 + trace_kfree(_RET_IP_, b);
91069 +#else
91070 trace_kmem_cache_free(_RET_IP_, b);
91071 +#endif
91072 +
91073 }
91074 EXPORT_SYMBOL(kmem_cache_free);
91075
91076 diff --git a/mm/slub.c b/mm/slub.c
91077 index c3eb3d3..022c9fa 100644
91078 --- a/mm/slub.c
91079 +++ b/mm/slub.c
91080 @@ -207,7 +207,7 @@ struct track {
91081
91082 enum track_item { TRACK_ALLOC, TRACK_FREE };
91083
91084 -#ifdef CONFIG_SYSFS
91085 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91086 static int sysfs_slab_add(struct kmem_cache *);
91087 static int sysfs_slab_alias(struct kmem_cache *, const char *);
91088 static void sysfs_slab_remove(struct kmem_cache *);
91089 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
91090 if (!t->addr)
91091 return;
91092
91093 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
91094 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
91095 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
91096 #ifdef CONFIG_STACKTRACE
91097 {
91098 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
91099
91100 slab_free_hook(s, x);
91101
91102 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91103 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
91104 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
91105 + if (s->ctor)
91106 + s->ctor(x);
91107 + }
91108 +#endif
91109 +
91110 redo:
91111 /*
91112 * Determine the currently cpus per cpu slab.
91113 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
91114 * Merge control. If this is set then no merging of slab caches will occur.
91115 * (Could be removed. This was introduced to pacify the merge skeptics.)
91116 */
91117 -static int slub_nomerge;
91118 +static int slub_nomerge = 1;
91119
91120 /*
91121 * Calculate the order of allocation given an slab object size.
91122 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
91123 s->inuse = size;
91124
91125 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
91126 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91127 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
91128 +#endif
91129 s->ctor)) {
91130 /*
91131 * Relocate free pointer after the object if it is not
91132 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
91133 EXPORT_SYMBOL(__kmalloc_node);
91134 #endif
91135
91136 +bool is_usercopy_object(const void *ptr)
91137 +{
91138 + struct page *page;
91139 + struct kmem_cache *s;
91140 +
91141 + if (ZERO_OR_NULL_PTR(ptr))
91142 + return false;
91143 +
91144 + if (!slab_is_available())
91145 + return false;
91146 +
91147 + if (!virt_addr_valid(ptr))
91148 + return false;
91149 +
91150 + page = virt_to_head_page(ptr);
91151 +
91152 + if (!PageSlab(page))
91153 + return false;
91154 +
91155 + s = page->slab_cache;
91156 + return s->flags & SLAB_USERCOPY;
91157 +}
91158 +
91159 +#ifdef CONFIG_PAX_USERCOPY
91160 +const char *check_heap_object(const void *ptr, unsigned long n)
91161 +{
91162 + struct page *page;
91163 + struct kmem_cache *s;
91164 + unsigned long offset;
91165 +
91166 + if (ZERO_OR_NULL_PTR(ptr))
91167 + return "<null>";
91168 +
91169 + if (!virt_addr_valid(ptr))
91170 + return NULL;
91171 +
91172 + page = virt_to_head_page(ptr);
91173 +
91174 + if (!PageSlab(page))
91175 + return NULL;
91176 +
91177 + s = page->slab_cache;
91178 + if (!(s->flags & SLAB_USERCOPY))
91179 + return s->name;
91180 +
91181 + offset = (ptr - page_address(page)) % s->size;
91182 + if (offset <= s->object_size && n <= s->object_size - offset)
91183 + return NULL;
91184 +
91185 + return s->name;
91186 +}
91187 +#endif
91188 +
91189 size_t ksize(const void *object)
91190 {
91191 struct page *page;
91192 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
91193 if (unlikely(ZERO_OR_NULL_PTR(x)))
91194 return;
91195
91196 + VM_BUG_ON(!virt_addr_valid(x));
91197 page = virt_to_head_page(x);
91198 if (unlikely(!PageSlab(page))) {
91199 BUG_ON(!PageCompound(page));
91200 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
91201 /*
91202 * We may have set a slab to be unmergeable during bootstrap.
91203 */
91204 - if (s->refcount < 0)
91205 + if (atomic_read(&s->refcount) < 0)
91206 return 1;
91207
91208 return 0;
91209 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91210
91211 s = find_mergeable(memcg, size, align, flags, name, ctor);
91212 if (s) {
91213 - s->refcount++;
91214 + atomic_inc(&s->refcount);
91215 /*
91216 * Adjust the object sizes so that we clear
91217 * the complete object on kzalloc.
91218 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91219 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
91220
91221 if (sysfs_slab_alias(s, name)) {
91222 - s->refcount--;
91223 + atomic_dec(&s->refcount);
91224 s = NULL;
91225 }
91226 }
91227 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
91228 }
91229 #endif
91230
91231 -#ifdef CONFIG_SYSFS
91232 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91233 static int count_inuse(struct page *page)
91234 {
91235 return page->inuse;
91236 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
91237 validate_slab_cache(kmalloc_caches[9]);
91238 }
91239 #else
91240 -#ifdef CONFIG_SYSFS
91241 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91242 static void resiliency_test(void) {};
91243 #endif
91244 #endif
91245
91246 -#ifdef CONFIG_SYSFS
91247 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91248 enum slab_stat_type {
91249 SL_ALL, /* All slabs */
91250 SL_PARTIAL, /* Only partially allocated slabs */
91251 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
91252
91253 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
91254 {
91255 - return sprintf(buf, "%d\n", s->refcount - 1);
91256 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
91257 }
91258 SLAB_ATTR_RO(aliases);
91259
91260 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
91261 SLAB_ATTR_RO(cache_dma);
91262 #endif
91263
91264 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91265 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
91266 +{
91267 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
91268 +}
91269 +SLAB_ATTR_RO(usercopy);
91270 +#endif
91271 +
91272 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
91273 {
91274 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
91275 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
91276 #ifdef CONFIG_ZONE_DMA
91277 &cache_dma_attr.attr,
91278 #endif
91279 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91280 + &usercopy_attr.attr,
91281 +#endif
91282 #ifdef CONFIG_NUMA
91283 &remote_node_defrag_ratio_attr.attr,
91284 #endif
91285 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
91286 return name;
91287 }
91288
91289 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91290 static int sysfs_slab_add(struct kmem_cache *s)
91291 {
91292 int err;
91293 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
91294 }
91295
91296 s->kobj.kset = slab_kset;
91297 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
91298 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
91299 if (err) {
91300 kobject_put(&s->kobj);
91301 return err;
91302 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
91303 kobject_del(&s->kobj);
91304 kobject_put(&s->kobj);
91305 }
91306 +#endif
91307
91308 /*
91309 * Need to buffer aliases during bootup until sysfs becomes
91310 @@ -5183,6 +5261,7 @@ struct saved_alias {
91311
91312 static struct saved_alias *alias_list;
91313
91314 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91315 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91316 {
91317 struct saved_alias *al;
91318 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91319 alias_list = al;
91320 return 0;
91321 }
91322 +#endif
91323
91324 static int __init slab_sysfs_init(void)
91325 {
91326 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
91327 index 27eeab3..7c3f7f2 100644
91328 --- a/mm/sparse-vmemmap.c
91329 +++ b/mm/sparse-vmemmap.c
91330 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
91331 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91332 if (!p)
91333 return NULL;
91334 - pud_populate(&init_mm, pud, p);
91335 + pud_populate_kernel(&init_mm, pud, p);
91336 }
91337 return pud;
91338 }
91339 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
91340 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91341 if (!p)
91342 return NULL;
91343 - pgd_populate(&init_mm, pgd, p);
91344 + pgd_populate_kernel(&init_mm, pgd, p);
91345 }
91346 return pgd;
91347 }
91348 diff --git a/mm/sparse.c b/mm/sparse.c
91349 index 4ac1d7e..bbfcb1f 100644
91350 --- a/mm/sparse.c
91351 +++ b/mm/sparse.c
91352 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
91353
91354 for (i = 0; i < PAGES_PER_SECTION; i++) {
91355 if (PageHWPoison(&memmap[i])) {
91356 - atomic_long_sub(1, &num_poisoned_pages);
91357 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
91358 ClearPageHWPoison(&memmap[i]);
91359 }
91360 }
91361 diff --git a/mm/swap.c b/mm/swap.c
91362 index 759c3ca..7c1a5b4 100644
91363 --- a/mm/swap.c
91364 +++ b/mm/swap.c
91365 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
91366
91367 __page_cache_release(page);
91368 dtor = get_compound_page_dtor(page);
91369 + if (!PageHuge(page))
91370 + BUG_ON(dtor != free_compound_page);
91371 (*dtor)(page);
91372 }
91373
91374 diff --git a/mm/swapfile.c b/mm/swapfile.c
91375 index de7c904..c84bf11 100644
91376 --- a/mm/swapfile.c
91377 +++ b/mm/swapfile.c
91378 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
91379
91380 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
91381 /* Activity counter to indicate that a swapon or swapoff has occurred */
91382 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
91383 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
91384
91385 static inline unsigned char swap_count(unsigned char ent)
91386 {
91387 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
91388 }
91389 filp_close(swap_file, NULL);
91390 err = 0;
91391 - atomic_inc(&proc_poll_event);
91392 + atomic_inc_unchecked(&proc_poll_event);
91393 wake_up_interruptible(&proc_poll_wait);
91394
91395 out_dput:
91396 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
91397
91398 poll_wait(file, &proc_poll_wait, wait);
91399
91400 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
91401 - seq->poll_event = atomic_read(&proc_poll_event);
91402 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
91403 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91404 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
91405 }
91406
91407 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
91408 return ret;
91409
91410 seq = file->private_data;
91411 - seq->poll_event = atomic_read(&proc_poll_event);
91412 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91413 return 0;
91414 }
91415
91416 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
91417 (frontswap_map) ? "FS" : "");
91418
91419 mutex_unlock(&swapon_mutex);
91420 - atomic_inc(&proc_poll_event);
91421 + atomic_inc_unchecked(&proc_poll_event);
91422 wake_up_interruptible(&proc_poll_wait);
91423
91424 if (S_ISREG(inode->i_mode))
91425 diff --git a/mm/util.c b/mm/util.c
91426 index eaf63fc2..32b2629 100644
91427 --- a/mm/util.c
91428 +++ b/mm/util.c
91429 @@ -294,6 +294,12 @@ done:
91430 void arch_pick_mmap_layout(struct mm_struct *mm)
91431 {
91432 mm->mmap_base = TASK_UNMAPPED_BASE;
91433 +
91434 +#ifdef CONFIG_PAX_RANDMMAP
91435 + if (mm->pax_flags & MF_PAX_RANDMMAP)
91436 + mm->mmap_base += mm->delta_mmap;
91437 +#endif
91438 +
91439 mm->get_unmapped_area = arch_get_unmapped_area;
91440 }
91441 #endif
91442 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
91443 index 1074543..136dbe0 100644
91444 --- a/mm/vmalloc.c
91445 +++ b/mm/vmalloc.c
91446 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
91447
91448 pte = pte_offset_kernel(pmd, addr);
91449 do {
91450 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91451 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91452 +
91453 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91454 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
91455 + BUG_ON(!pte_exec(*pte));
91456 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
91457 + continue;
91458 + }
91459 +#endif
91460 +
91461 + {
91462 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91463 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91464 + }
91465 } while (pte++, addr += PAGE_SIZE, addr != end);
91466 }
91467
91468 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
91469 pte = pte_alloc_kernel(pmd, addr);
91470 if (!pte)
91471 return -ENOMEM;
91472 +
91473 + pax_open_kernel();
91474 do {
91475 struct page *page = pages[*nr];
91476
91477 - if (WARN_ON(!pte_none(*pte)))
91478 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91479 + if (pgprot_val(prot) & _PAGE_NX)
91480 +#endif
91481 +
91482 + if (!pte_none(*pte)) {
91483 + pax_close_kernel();
91484 + WARN_ON(1);
91485 return -EBUSY;
91486 - if (WARN_ON(!page))
91487 + }
91488 + if (!page) {
91489 + pax_close_kernel();
91490 + WARN_ON(1);
91491 return -ENOMEM;
91492 + }
91493 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
91494 (*nr)++;
91495 } while (pte++, addr += PAGE_SIZE, addr != end);
91496 + pax_close_kernel();
91497 return 0;
91498 }
91499
91500 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
91501 pmd_t *pmd;
91502 unsigned long next;
91503
91504 - pmd = pmd_alloc(&init_mm, pud, addr);
91505 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
91506 if (!pmd)
91507 return -ENOMEM;
91508 do {
91509 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
91510 pud_t *pud;
91511 unsigned long next;
91512
91513 - pud = pud_alloc(&init_mm, pgd, addr);
91514 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
91515 if (!pud)
91516 return -ENOMEM;
91517 do {
91518 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
91519 if (addr >= MODULES_VADDR && addr < MODULES_END)
91520 return 1;
91521 #endif
91522 +
91523 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91524 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
91525 + return 1;
91526 +#endif
91527 +
91528 return is_vmalloc_addr(x);
91529 }
91530
91531 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
91532
91533 if (!pgd_none(*pgd)) {
91534 pud_t *pud = pud_offset(pgd, addr);
91535 +#ifdef CONFIG_X86
91536 + if (!pud_large(*pud))
91537 +#endif
91538 if (!pud_none(*pud)) {
91539 pmd_t *pmd = pmd_offset(pud, addr);
91540 +#ifdef CONFIG_X86
91541 + if (!pmd_large(*pmd))
91542 +#endif
91543 if (!pmd_none(*pmd)) {
91544 pte_t *ptep, pte;
91545
91546 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
91547 struct vm_struct *area;
91548
91549 BUG_ON(in_interrupt());
91550 +
91551 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91552 + if (flags & VM_KERNEXEC) {
91553 + if (start != VMALLOC_START || end != VMALLOC_END)
91554 + return NULL;
91555 + start = (unsigned long)MODULES_EXEC_VADDR;
91556 + end = (unsigned long)MODULES_EXEC_END;
91557 + }
91558 +#endif
91559 +
91560 if (flags & VM_IOREMAP)
91561 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
91562
91563 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
91564 if (count > totalram_pages)
91565 return NULL;
91566
91567 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91568 + if (!(pgprot_val(prot) & _PAGE_NX))
91569 + flags |= VM_KERNEXEC;
91570 +#endif
91571 +
91572 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
91573 __builtin_return_address(0));
91574 if (!area)
91575 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
91576 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
91577 goto fail;
91578
91579 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91580 + if (!(pgprot_val(prot) & _PAGE_NX))
91581 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
91582 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
91583 + else
91584 +#endif
91585 +
91586 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
91587 start, end, node, gfp_mask, caller);
91588 if (!area)
91589 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
91590 * For tight control over page level allocator and protection flags
91591 * use __vmalloc() instead.
91592 */
91593 -
91594 void *vmalloc_exec(unsigned long size)
91595 {
91596 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
91597 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
91598 NUMA_NO_NODE, __builtin_return_address(0));
91599 }
91600
91601 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
91602 {
91603 struct vm_struct *area;
91604
91605 + BUG_ON(vma->vm_mirror);
91606 +
91607 size = PAGE_ALIGN(size);
91608
91609 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
91610 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
91611 v->addr, v->addr + v->size, v->size);
91612
91613 if (v->caller)
91614 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91615 + seq_printf(m, " %pK", v->caller);
91616 +#else
91617 seq_printf(m, " %pS", v->caller);
91618 +#endif
91619
91620 if (v->nr_pages)
91621 seq_printf(m, " pages=%d", v->nr_pages);
91622 diff --git a/mm/vmstat.c b/mm/vmstat.c
91623 index 9bb3145..98e5f68 100644
91624 --- a/mm/vmstat.c
91625 +++ b/mm/vmstat.c
91626 @@ -79,7 +79,7 @@ void vm_events_fold_cpu(int cpu)
91627 *
91628 * vm_stat contains the global counters
91629 */
91630 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91631 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91632 EXPORT_SYMBOL(vm_stat);
91633
91634 #ifdef CONFIG_SMP
91635 @@ -423,7 +423,7 @@ static inline void fold_diff(int *diff)
91636
91637 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
91638 if (diff[i])
91639 - atomic_long_add(diff[i], &vm_stat[i]);
91640 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
91641 }
91642
91643 /*
91644 @@ -455,7 +455,7 @@ static void refresh_cpu_vm_stats(void)
91645 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
91646 if (v) {
91647
91648 - atomic_long_add(v, &zone->vm_stat[i]);
91649 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91650 global_diff[i] += v;
91651 #ifdef CONFIG_NUMA
91652 /* 3 seconds idle till flush */
91653 @@ -517,7 +517,7 @@ void cpu_vm_stats_fold(int cpu)
91654
91655 v = p->vm_stat_diff[i];
91656 p->vm_stat_diff[i] = 0;
91657 - atomic_long_add(v, &zone->vm_stat[i]);
91658 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91659 global_diff[i] += v;
91660 }
91661 }
91662 @@ -537,8 +537,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
91663 if (pset->vm_stat_diff[i]) {
91664 int v = pset->vm_stat_diff[i];
91665 pset->vm_stat_diff[i] = 0;
91666 - atomic_long_add(v, &zone->vm_stat[i]);
91667 - atomic_long_add(v, &vm_stat[i]);
91668 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91669 + atomic_long_add_unchecked(v, &vm_stat[i]);
91670 }
91671 }
91672 #endif
91673 @@ -1280,10 +1280,20 @@ static int __init setup_vmstat(void)
91674 start_cpu_timer(cpu);
91675 #endif
91676 #ifdef CONFIG_PROC_FS
91677 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
91678 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
91679 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
91680 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
91681 + {
91682 + mode_t gr_mode = S_IRUGO;
91683 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
91684 + gr_mode = S_IRUSR;
91685 +#endif
91686 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
91687 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
91688 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
91689 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
91690 +#else
91691 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
91692 +#endif
91693 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
91694 + }
91695 #endif
91696 return 0;
91697 }
91698 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
91699 index 61fc573..b5e47d0 100644
91700 --- a/net/8021q/vlan.c
91701 +++ b/net/8021q/vlan.c
91702 @@ -472,7 +472,7 @@ out:
91703 return NOTIFY_DONE;
91704 }
91705
91706 -static struct notifier_block vlan_notifier_block __read_mostly = {
91707 +static struct notifier_block vlan_notifier_block = {
91708 .notifier_call = vlan_device_event,
91709 };
91710
91711 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
91712 err = -EPERM;
91713 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
91714 break;
91715 - if ((args.u.name_type >= 0) &&
91716 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
91717 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
91718 struct vlan_net *vn;
91719
91720 vn = net_generic(net, vlan_net_id);
91721 diff --git a/net/9p/mod.c b/net/9p/mod.c
91722 index 6ab36ae..6f1841b 100644
91723 --- a/net/9p/mod.c
91724 +++ b/net/9p/mod.c
91725 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
91726 void v9fs_register_trans(struct p9_trans_module *m)
91727 {
91728 spin_lock(&v9fs_trans_lock);
91729 - list_add_tail(&m->list, &v9fs_trans_list);
91730 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
91731 spin_unlock(&v9fs_trans_lock);
91732 }
91733 EXPORT_SYMBOL(v9fs_register_trans);
91734 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
91735 void v9fs_unregister_trans(struct p9_trans_module *m)
91736 {
91737 spin_lock(&v9fs_trans_lock);
91738 - list_del_init(&m->list);
91739 + pax_list_del_init((struct list_head *)&m->list);
91740 spin_unlock(&v9fs_trans_lock);
91741 }
91742 EXPORT_SYMBOL(v9fs_unregister_trans);
91743 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
91744 index 3ffda1b..fceac96 100644
91745 --- a/net/9p/trans_fd.c
91746 +++ b/net/9p/trans_fd.c
91747 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
91748 oldfs = get_fs();
91749 set_fs(get_ds());
91750 /* The cast to a user pointer is valid due to the set_fs() */
91751 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
91752 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
91753 set_fs(oldfs);
91754
91755 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
91756 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
91757 index 876fbe8..8bbea9f 100644
91758 --- a/net/atm/atm_misc.c
91759 +++ b/net/atm/atm_misc.c
91760 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
91761 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
91762 return 1;
91763 atm_return(vcc, truesize);
91764 - atomic_inc(&vcc->stats->rx_drop);
91765 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91766 return 0;
91767 }
91768 EXPORT_SYMBOL(atm_charge);
91769 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
91770 }
91771 }
91772 atm_return(vcc, guess);
91773 - atomic_inc(&vcc->stats->rx_drop);
91774 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91775 return NULL;
91776 }
91777 EXPORT_SYMBOL(atm_alloc_charge);
91778 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
91779
91780 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91781 {
91782 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91783 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91784 __SONET_ITEMS
91785 #undef __HANDLE_ITEM
91786 }
91787 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
91788
91789 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91790 {
91791 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91792 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
91793 __SONET_ITEMS
91794 #undef __HANDLE_ITEM
91795 }
91796 diff --git a/net/atm/lec.h b/net/atm/lec.h
91797 index 4149db1..f2ab682 100644
91798 --- a/net/atm/lec.h
91799 +++ b/net/atm/lec.h
91800 @@ -48,7 +48,7 @@ struct lane2_ops {
91801 const u8 *tlvs, u32 sizeoftlvs);
91802 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
91803 const u8 *tlvs, u32 sizeoftlvs);
91804 -};
91805 +} __no_const;
91806
91807 /*
91808 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
91809 diff --git a/net/atm/proc.c b/net/atm/proc.c
91810 index bbb6461..cf04016 100644
91811 --- a/net/atm/proc.c
91812 +++ b/net/atm/proc.c
91813 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
91814 const struct k_atm_aal_stats *stats)
91815 {
91816 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
91817 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
91818 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
91819 - atomic_read(&stats->rx_drop));
91820 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
91821 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
91822 + atomic_read_unchecked(&stats->rx_drop));
91823 }
91824
91825 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
91826 diff --git a/net/atm/resources.c b/net/atm/resources.c
91827 index 0447d5d..3cf4728 100644
91828 --- a/net/atm/resources.c
91829 +++ b/net/atm/resources.c
91830 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
91831 static void copy_aal_stats(struct k_atm_aal_stats *from,
91832 struct atm_aal_stats *to)
91833 {
91834 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91835 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91836 __AAL_STAT_ITEMS
91837 #undef __HANDLE_ITEM
91838 }
91839 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
91840 static void subtract_aal_stats(struct k_atm_aal_stats *from,
91841 struct atm_aal_stats *to)
91842 {
91843 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91844 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
91845 __AAL_STAT_ITEMS
91846 #undef __HANDLE_ITEM
91847 }
91848 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
91849 index 919a5ce..cc6b444 100644
91850 --- a/net/ax25/sysctl_net_ax25.c
91851 +++ b/net/ax25/sysctl_net_ax25.c
91852 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
91853 {
91854 char path[sizeof("net/ax25/") + IFNAMSIZ];
91855 int k;
91856 - struct ctl_table *table;
91857 + ctl_table_no_const *table;
91858
91859 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
91860 if (!table)
91861 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
91862 index 0a8a80c..f7e89aa 100644
91863 --- a/net/batman-adv/bat_iv_ogm.c
91864 +++ b/net/batman-adv/bat_iv_ogm.c
91865 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
91866
91867 /* randomize initial seqno to avoid collision */
91868 get_random_bytes(&random_seqno, sizeof(random_seqno));
91869 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91870 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91871
91872 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
91873 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
91874 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
91875 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
91876
91877 /* change sequence number to network order */
91878 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
91879 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
91880 batadv_ogm_packet->seqno = htonl(seqno);
91881 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
91882 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
91883
91884 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
91885 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
91886 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
91887 return;
91888
91889 /* could be changed by schedule_own_packet() */
91890 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
91891 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
91892
91893 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
91894 has_directlink_flag = 1;
91895 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
91896 index c478e6b..469fd2f 100644
91897 --- a/net/batman-adv/hard-interface.c
91898 +++ b/net/batman-adv/hard-interface.c
91899 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
91900 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
91901 dev_add_pack(&hard_iface->batman_adv_ptype);
91902
91903 - atomic_set(&hard_iface->frag_seqno, 1);
91904 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
91905 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
91906 hard_iface->net_dev->name);
91907
91908 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
91909 index 813db4e..847edac 100644
91910 --- a/net/batman-adv/soft-interface.c
91911 +++ b/net/batman-adv/soft-interface.c
91912 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
91913 primary_if->net_dev->dev_addr, ETH_ALEN);
91914
91915 /* set broadcast sequence number */
91916 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
91917 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
91918 bcast_packet->seqno = htonl(seqno);
91919
91920 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
91921 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
91922 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
91923
91924 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
91925 - atomic_set(&bat_priv->bcast_seqno, 1);
91926 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
91927 atomic_set(&bat_priv->tt.vn, 0);
91928 atomic_set(&bat_priv->tt.local_changes, 0);
91929 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
91930 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
91931 index b2c94e1..3d47e07 100644
91932 --- a/net/batman-adv/types.h
91933 +++ b/net/batman-adv/types.h
91934 @@ -51,7 +51,7 @@
91935 struct batadv_hard_iface_bat_iv {
91936 unsigned char *ogm_buff;
91937 int ogm_buff_len;
91938 - atomic_t ogm_seqno;
91939 + atomic_unchecked_t ogm_seqno;
91940 };
91941
91942 /**
91943 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
91944 int16_t if_num;
91945 char if_status;
91946 struct net_device *net_dev;
91947 - atomic_t frag_seqno;
91948 + atomic_unchecked_t frag_seqno;
91949 uint8_t num_bcasts;
91950 struct kobject *hardif_obj;
91951 atomic_t refcount;
91952 @@ -560,7 +560,7 @@ struct batadv_priv {
91953 #ifdef CONFIG_BATMAN_ADV_DEBUG
91954 atomic_t log_level;
91955 #endif
91956 - atomic_t bcast_seqno;
91957 + atomic_unchecked_t bcast_seqno;
91958 atomic_t bcast_queue_left;
91959 atomic_t batman_queue_left;
91960 char num_ifaces;
91961 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
91962 index 48b31d3..62a0bcb 100644
91963 --- a/net/batman-adv/unicast.c
91964 +++ b/net/batman-adv/unicast.c
91965 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
91966 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
91967 frag2->flags = large_tail;
91968
91969 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91970 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91971 frag1->seqno = htons(seqno - 1);
91972 frag2->seqno = htons(seqno);
91973
91974 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
91975 index 9bd7d95..6c4884f 100644
91976 --- a/net/bluetooth/hci_sock.c
91977 +++ b/net/bluetooth/hci_sock.c
91978 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
91979 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
91980 }
91981
91982 - len = min_t(unsigned int, len, sizeof(uf));
91983 + len = min((size_t)len, sizeof(uf));
91984 if (copy_from_user(&uf, optval, len)) {
91985 err = -EFAULT;
91986 break;
91987 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91988 index 63fa111..b166ec6 100644
91989 --- a/net/bluetooth/l2cap_core.c
91990 +++ b/net/bluetooth/l2cap_core.c
91991 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91992 break;
91993
91994 case L2CAP_CONF_RFC:
91995 - if (olen == sizeof(rfc))
91996 - memcpy(&rfc, (void *)val, olen);
91997 + if (olen != sizeof(rfc))
91998 + break;
91999 +
92000 + memcpy(&rfc, (void *)val, olen);
92001
92002 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
92003 rfc.mode != chan->mode)
92004 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
92005 index 0098af8..fb5a31f 100644
92006 --- a/net/bluetooth/l2cap_sock.c
92007 +++ b/net/bluetooth/l2cap_sock.c
92008 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92009 struct sock *sk = sock->sk;
92010 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
92011 struct l2cap_options opts;
92012 - int len, err = 0;
92013 + int err = 0;
92014 + size_t len = optlen;
92015 u32 opt;
92016
92017 BT_DBG("sk %p", sk);
92018 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92019 opts.max_tx = chan->max_tx;
92020 opts.txwin_size = chan->tx_win;
92021
92022 - len = min_t(unsigned int, sizeof(opts), optlen);
92023 + len = min(sizeof(opts), len);
92024 if (copy_from_user((char *) &opts, optval, len)) {
92025 err = -EFAULT;
92026 break;
92027 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92028 struct bt_security sec;
92029 struct bt_power pwr;
92030 struct l2cap_conn *conn;
92031 - int len, err = 0;
92032 + int err = 0;
92033 + size_t len = optlen;
92034 u32 opt;
92035
92036 BT_DBG("sk %p", sk);
92037 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92038
92039 sec.level = BT_SECURITY_LOW;
92040
92041 - len = min_t(unsigned int, sizeof(sec), optlen);
92042 + len = min(sizeof(sec), len);
92043 if (copy_from_user((char *) &sec, optval, len)) {
92044 err = -EFAULT;
92045 break;
92046 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92047
92048 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
92049
92050 - len = min_t(unsigned int, sizeof(pwr), optlen);
92051 + len = min(sizeof(pwr), len);
92052 if (copy_from_user((char *) &pwr, optval, len)) {
92053 err = -EFAULT;
92054 break;
92055 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
92056 index 30b3721..c1bd0a0 100644
92057 --- a/net/bluetooth/rfcomm/sock.c
92058 +++ b/net/bluetooth/rfcomm/sock.c
92059 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92060 struct sock *sk = sock->sk;
92061 struct bt_security sec;
92062 int err = 0;
92063 - size_t len;
92064 + size_t len = optlen;
92065 u32 opt;
92066
92067 BT_DBG("sk %p", sk);
92068 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92069
92070 sec.level = BT_SECURITY_LOW;
92071
92072 - len = min_t(unsigned int, sizeof(sec), optlen);
92073 + len = min(sizeof(sec), len);
92074 if (copy_from_user((char *) &sec, optval, len)) {
92075 err = -EFAULT;
92076 break;
92077 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
92078 index 84fcf9f..e389b27 100644
92079 --- a/net/bluetooth/rfcomm/tty.c
92080 +++ b/net/bluetooth/rfcomm/tty.c
92081 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
92082 BT_DBG("tty %p id %d", tty, tty->index);
92083
92084 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
92085 - dev->channel, dev->port.count);
92086 + dev->channel, atomic_read(&dev->port.count));
92087
92088 err = tty_port_open(&dev->port, tty, filp);
92089 if (err)
92090 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
92091 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
92092
92093 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
92094 - dev->port.count);
92095 + atomic_read(&dev->port.count));
92096
92097 tty_port_close(&dev->port, tty, filp);
92098 }
92099 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
92100 index 5180938..7c470c3 100644
92101 --- a/net/bridge/netfilter/ebt_ulog.c
92102 +++ b/net/bridge/netfilter/ebt_ulog.c
92103 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92104 ub->qlen++;
92105
92106 pm = nlmsg_data(nlh);
92107 + memset(pm, 0, sizeof(*pm));
92108
92109 /* Fill in the ulog data */
92110 pm->version = EBT_ULOG_VERSION;
92111 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92112 pm->hook = hooknr;
92113 if (uloginfo->prefix != NULL)
92114 strcpy(pm->prefix, uloginfo->prefix);
92115 - else
92116 - *(pm->prefix) = '\0';
92117
92118 if (in) {
92119 strcpy(pm->physindev, in->name);
92120 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92121 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
92122 else
92123 strcpy(pm->indev, in->name);
92124 - } else
92125 - pm->indev[0] = pm->physindev[0] = '\0';
92126 + }
92127
92128 if (out) {
92129 /* If out exists, then out is a bridge port */
92130 strcpy(pm->physoutdev, out->name);
92131 /* rcu_read_lock()ed by nf_hook_slow */
92132 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
92133 - } else
92134 - pm->outdev[0] = pm->physoutdev[0] = '\0';
92135 + }
92136
92137 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
92138 BUG();
92139 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
92140 index ac78024..161a80c 100644
92141 --- a/net/bridge/netfilter/ebtables.c
92142 +++ b/net/bridge/netfilter/ebtables.c
92143 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92144 tmp.valid_hooks = t->table->valid_hooks;
92145 }
92146 mutex_unlock(&ebt_mutex);
92147 - if (copy_to_user(user, &tmp, *len) != 0){
92148 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
92149 BUGPRINT("c2u Didn't work\n");
92150 ret = -EFAULT;
92151 break;
92152 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92153 goto out;
92154 tmp.valid_hooks = t->valid_hooks;
92155
92156 - if (copy_to_user(user, &tmp, *len) != 0) {
92157 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92158 ret = -EFAULT;
92159 break;
92160 }
92161 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92162 tmp.entries_size = t->table->entries_size;
92163 tmp.valid_hooks = t->table->valid_hooks;
92164
92165 - if (copy_to_user(user, &tmp, *len) != 0) {
92166 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92167 ret = -EFAULT;
92168 break;
92169 }
92170 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
92171 index 0f45522..dab651f 100644
92172 --- a/net/caif/cfctrl.c
92173 +++ b/net/caif/cfctrl.c
92174 @@ -10,6 +10,7 @@
92175 #include <linux/spinlock.h>
92176 #include <linux/slab.h>
92177 #include <linux/pkt_sched.h>
92178 +#include <linux/sched.h>
92179 #include <net/caif/caif_layer.h>
92180 #include <net/caif/cfpkt.h>
92181 #include <net/caif/cfctrl.h>
92182 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
92183 memset(&dev_info, 0, sizeof(dev_info));
92184 dev_info.id = 0xff;
92185 cfsrvl_init(&this->serv, 0, &dev_info, false);
92186 - atomic_set(&this->req_seq_no, 1);
92187 - atomic_set(&this->rsp_seq_no, 1);
92188 + atomic_set_unchecked(&this->req_seq_no, 1);
92189 + atomic_set_unchecked(&this->rsp_seq_no, 1);
92190 this->serv.layer.receive = cfctrl_recv;
92191 sprintf(this->serv.layer.name, "ctrl");
92192 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
92193 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
92194 struct cfctrl_request_info *req)
92195 {
92196 spin_lock_bh(&ctrl->info_list_lock);
92197 - atomic_inc(&ctrl->req_seq_no);
92198 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
92199 + atomic_inc_unchecked(&ctrl->req_seq_no);
92200 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
92201 list_add_tail(&req->list, &ctrl->list);
92202 spin_unlock_bh(&ctrl->info_list_lock);
92203 }
92204 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
92205 if (p != first)
92206 pr_warn("Requests are not received in order\n");
92207
92208 - atomic_set(&ctrl->rsp_seq_no,
92209 + atomic_set_unchecked(&ctrl->rsp_seq_no,
92210 p->sequence_no);
92211 list_del(&p->list);
92212 goto out;
92213 diff --git a/net/can/af_can.c b/net/can/af_can.c
92214 index 3ab8dd2..b9aef13 100644
92215 --- a/net/can/af_can.c
92216 +++ b/net/can/af_can.c
92217 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
92218 };
92219
92220 /* notifier block for netdevice event */
92221 -static struct notifier_block can_netdev_notifier __read_mostly = {
92222 +static struct notifier_block can_netdev_notifier = {
92223 .notifier_call = can_notifier,
92224 };
92225
92226 diff --git a/net/can/gw.c b/net/can/gw.c
92227 index 3f9b0f3..fc6d4fa 100644
92228 --- a/net/can/gw.c
92229 +++ b/net/can/gw.c
92230 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
92231 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
92232
92233 static HLIST_HEAD(cgw_list);
92234 -static struct notifier_block notifier;
92235
92236 static struct kmem_cache *cgw_cache __read_mostly;
92237
92238 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
92239 return err;
92240 }
92241
92242 +static struct notifier_block notifier = {
92243 + .notifier_call = cgw_notifier
92244 +};
92245 +
92246 static __init int cgw_module_init(void)
92247 {
92248 /* sanitize given module parameter */
92249 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
92250 return -ENOMEM;
92251
92252 /* set notifier */
92253 - notifier.notifier_call = cgw_notifier;
92254 register_netdevice_notifier(&notifier);
92255
92256 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
92257 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
92258 index 4a5df7b..9ad1f1d 100644
92259 --- a/net/ceph/messenger.c
92260 +++ b/net/ceph/messenger.c
92261 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
92262 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
92263
92264 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
92265 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
92266 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
92267
92268 static struct page *zero_page; /* used in certain error cases */
92269
92270 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
92271 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
92272 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
92273
92274 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92275 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92276 s = addr_str[i];
92277
92278 switch (ss->ss_family) {
92279 diff --git a/net/compat.c b/net/compat.c
92280 index 8903258..24e30e5 100644
92281 --- a/net/compat.c
92282 +++ b/net/compat.c
92283 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
92284 return -EFAULT;
92285 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
92286 return -EINVAL;
92287 - kmsg->msg_name = compat_ptr(tmp1);
92288 - kmsg->msg_iov = compat_ptr(tmp2);
92289 - kmsg->msg_control = compat_ptr(tmp3);
92290 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
92291 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
92292 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
92293 return 0;
92294 }
92295
92296 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92297
92298 if (kern_msg->msg_namelen) {
92299 if (mode == VERIFY_READ) {
92300 - int err = move_addr_to_kernel(kern_msg->msg_name,
92301 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
92302 kern_msg->msg_namelen,
92303 kern_address);
92304 if (err < 0)
92305 @@ -98,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92306 kern_msg->msg_name = NULL;
92307
92308 tot_len = iov_from_user_compat_to_kern(kern_iov,
92309 - (struct compat_iovec __user *)kern_msg->msg_iov,
92310 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
92311 kern_msg->msg_iovlen);
92312 if (tot_len >= 0)
92313 kern_msg->msg_iov = kern_iov;
92314 @@ -118,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92315
92316 #define CMSG_COMPAT_FIRSTHDR(msg) \
92317 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
92318 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
92319 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
92320 (struct compat_cmsghdr __user *)NULL)
92321
92322 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
92323 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
92324 (ucmlen) <= (unsigned long) \
92325 ((mhdr)->msg_controllen - \
92326 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
92327 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
92328
92329 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
92330 struct compat_cmsghdr __user *cmsg, int cmsg_len)
92331 {
92332 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
92333 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
92334 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
92335 msg->msg_controllen)
92336 return NULL;
92337 return (struct compat_cmsghdr __user *)ptr;
92338 @@ -221,7 +221,7 @@ Efault:
92339
92340 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
92341 {
92342 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92343 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92344 struct compat_cmsghdr cmhdr;
92345 struct compat_timeval ctv;
92346 struct compat_timespec cts[3];
92347 @@ -277,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
92348
92349 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
92350 {
92351 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92352 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92353 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
92354 int fdnum = scm->fp->count;
92355 struct file **fp = scm->fp->fp;
92356 @@ -365,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
92357 return -EFAULT;
92358 old_fs = get_fs();
92359 set_fs(KERNEL_DS);
92360 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
92361 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
92362 set_fs(old_fs);
92363
92364 return err;
92365 @@ -426,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
92366 len = sizeof(ktime);
92367 old_fs = get_fs();
92368 set_fs(KERNEL_DS);
92369 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
92370 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
92371 set_fs(old_fs);
92372
92373 if (!err) {
92374 @@ -569,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92375 case MCAST_JOIN_GROUP:
92376 case MCAST_LEAVE_GROUP:
92377 {
92378 - struct compat_group_req __user *gr32 = (void *)optval;
92379 + struct compat_group_req __user *gr32 = (void __user *)optval;
92380 struct group_req __user *kgr =
92381 compat_alloc_user_space(sizeof(struct group_req));
92382 u32 interface;
92383 @@ -590,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92384 case MCAST_BLOCK_SOURCE:
92385 case MCAST_UNBLOCK_SOURCE:
92386 {
92387 - struct compat_group_source_req __user *gsr32 = (void *)optval;
92388 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
92389 struct group_source_req __user *kgsr = compat_alloc_user_space(
92390 sizeof(struct group_source_req));
92391 u32 interface;
92392 @@ -611,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92393 }
92394 case MCAST_MSFILTER:
92395 {
92396 - struct compat_group_filter __user *gf32 = (void *)optval;
92397 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92398 struct group_filter __user *kgf;
92399 u32 interface, fmode, numsrc;
92400
92401 @@ -649,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
92402 char __user *optval, int __user *optlen,
92403 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
92404 {
92405 - struct compat_group_filter __user *gf32 = (void *)optval;
92406 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92407 struct group_filter __user *kgf;
92408 int __user *koptlen;
92409 u32 interface, fmode, numsrc;
92410 @@ -807,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
92411
92412 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
92413 return -EINVAL;
92414 - if (copy_from_user(a, args, nas[call]))
92415 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
92416 return -EFAULT;
92417 a0 = a[0];
92418 a1 = a[1];
92419 diff --git a/net/core/datagram.c b/net/core/datagram.c
92420 index af814e7..3d761de 100644
92421 --- a/net/core/datagram.c
92422 +++ b/net/core/datagram.c
92423 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
92424 }
92425
92426 kfree_skb(skb);
92427 - atomic_inc(&sk->sk_drops);
92428 + atomic_inc_unchecked(&sk->sk_drops);
92429 sk_mem_reclaim_partial(sk);
92430
92431 return err;
92432 diff --git a/net/core/dev.c b/net/core/dev.c
92433 index 3430b1e..d6453ad 100644
92434 --- a/net/core/dev.c
92435 +++ b/net/core/dev.c
92436 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
92437 {
92438 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
92439 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
92440 - atomic_long_inc(&dev->rx_dropped);
92441 + atomic_long_inc_unchecked(&dev->rx_dropped);
92442 kfree_skb(skb);
92443 return NET_RX_DROP;
92444 }
92445 }
92446
92447 if (unlikely(!is_skb_forwardable(dev, skb))) {
92448 - atomic_long_inc(&dev->rx_dropped);
92449 + atomic_long_inc_unchecked(&dev->rx_dropped);
92450 kfree_skb(skb);
92451 return NET_RX_DROP;
92452 }
92453 @@ -2432,7 +2432,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
92454
92455 struct dev_gso_cb {
92456 void (*destructor)(struct sk_buff *skb);
92457 -};
92458 +} __no_const;
92459
92460 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
92461
92462 @@ -3207,7 +3207,7 @@ enqueue:
92463
92464 local_irq_restore(flags);
92465
92466 - atomic_long_inc(&skb->dev->rx_dropped);
92467 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92468 kfree_skb(skb);
92469 return NET_RX_DROP;
92470 }
92471 @@ -3279,7 +3279,7 @@ int netif_rx_ni(struct sk_buff *skb)
92472 }
92473 EXPORT_SYMBOL(netif_rx_ni);
92474
92475 -static void net_tx_action(struct softirq_action *h)
92476 +static __latent_entropy void net_tx_action(void)
92477 {
92478 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92479
92480 @@ -3613,7 +3613,7 @@ ncls:
92481 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
92482 } else {
92483 drop:
92484 - atomic_long_inc(&skb->dev->rx_dropped);
92485 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92486 kfree_skb(skb);
92487 /* Jamal, now you will not able to escape explaining
92488 * me how you were going to use this. :-)
92489 @@ -4273,7 +4273,7 @@ void netif_napi_del(struct napi_struct *napi)
92490 }
92491 EXPORT_SYMBOL(netif_napi_del);
92492
92493 -static void net_rx_action(struct softirq_action *h)
92494 +static __latent_entropy void net_rx_action(void)
92495 {
92496 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92497 unsigned long time_limit = jiffies + 2;
92498 @@ -5977,7 +5977,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
92499 } else {
92500 netdev_stats_to_stats64(storage, &dev->stats);
92501 }
92502 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
92503 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
92504 return storage;
92505 }
92506 EXPORT_SYMBOL(dev_get_stats);
92507 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
92508 index 5b7d0e1..cb960fc 100644
92509 --- a/net/core/dev_ioctl.c
92510 +++ b/net/core/dev_ioctl.c
92511 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
92512 if (no_module && capable(CAP_NET_ADMIN))
92513 no_module = request_module("netdev-%s", name);
92514 if (no_module && capable(CAP_SYS_MODULE)) {
92515 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
92516 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
92517 +#else
92518 if (!request_module("%s", name))
92519 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
92520 name);
92521 +#endif
92522 }
92523 }
92524 EXPORT_SYMBOL(dev_load);
92525 diff --git a/net/core/flow.c b/net/core/flow.c
92526 index dfa602c..3103d88 100644
92527 --- a/net/core/flow.c
92528 +++ b/net/core/flow.c
92529 @@ -61,7 +61,7 @@ struct flow_cache {
92530 struct timer_list rnd_timer;
92531 };
92532
92533 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
92534 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
92535 EXPORT_SYMBOL(flow_cache_genid);
92536 static struct flow_cache flow_cache_global;
92537 static struct kmem_cache *flow_cachep __read_mostly;
92538 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
92539
92540 static int flow_entry_valid(struct flow_cache_entry *fle)
92541 {
92542 - if (atomic_read(&flow_cache_genid) != fle->genid)
92543 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
92544 return 0;
92545 if (fle->object && !fle->object->ops->check(fle->object))
92546 return 0;
92547 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
92548 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
92549 fcp->hash_count++;
92550 }
92551 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
92552 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
92553 flo = fle->object;
92554 if (!flo)
92555 goto ret_object;
92556 @@ -279,7 +279,7 @@ nocache:
92557 }
92558 flo = resolver(net, key, family, dir, flo, ctx);
92559 if (fle) {
92560 - fle->genid = atomic_read(&flow_cache_genid);
92561 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
92562 if (!IS_ERR(flo))
92563 fle->object = flo;
92564 else
92565 diff --git a/net/core/iovec.c b/net/core/iovec.c
92566 index b77eeec..2890aca 100644
92567 --- a/net/core/iovec.c
92568 +++ b/net/core/iovec.c
92569 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92570 if (m->msg_namelen) {
92571 if (mode == VERIFY_READ) {
92572 void __user *namep;
92573 - namep = (void __user __force *) m->msg_name;
92574 + namep = (void __force_user *) m->msg_name;
92575 err = move_addr_to_kernel(namep, m->msg_namelen,
92576 address);
92577 if (err < 0)
92578 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92579 }
92580
92581 size = m->msg_iovlen * sizeof(struct iovec);
92582 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
92583 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
92584 return -EFAULT;
92585
92586 m->msg_iov = iov;
92587 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
92588 index 6072610..7374c18 100644
92589 --- a/net/core/neighbour.c
92590 +++ b/net/core/neighbour.c
92591 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
92592 void __user *buffer, size_t *lenp, loff_t *ppos)
92593 {
92594 int size, ret;
92595 - struct ctl_table tmp = *ctl;
92596 + ctl_table_no_const tmp = *ctl;
92597
92598 tmp.extra1 = &zero;
92599 tmp.extra2 = &unres_qlen_max;
92600 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
92601 index 2bf8329..7960607 100644
92602 --- a/net/core/net-procfs.c
92603 +++ b/net/core/net-procfs.c
92604 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
92605 else
92606 seq_printf(seq, "%04x", ntohs(pt->type));
92607
92608 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92609 + seq_printf(seq, " %-8s %pf\n",
92610 + pt->dev ? pt->dev->name : "", NULL);
92611 +#else
92612 seq_printf(seq, " %-8s %pf\n",
92613 pt->dev ? pt->dev->name : "", pt->func);
92614 +#endif
92615 }
92616
92617 return 0;
92618 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
92619 index d954b56..b0a0f7a 100644
92620 --- a/net/core/net-sysfs.c
92621 +++ b/net/core/net-sysfs.c
92622 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
92623 }
92624 EXPORT_SYMBOL(netdev_class_remove_file);
92625
92626 -int netdev_kobject_init(void)
92627 +int __init netdev_kobject_init(void)
92628 {
92629 kobj_ns_type_register(&net_ns_type_operations);
92630 return class_register(&net_class);
92631 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
92632 index 81d3a9a..a0bd7a8 100644
92633 --- a/net/core/net_namespace.c
92634 +++ b/net/core/net_namespace.c
92635 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
92636 int error;
92637 LIST_HEAD(net_exit_list);
92638
92639 - list_add_tail(&ops->list, list);
92640 + pax_list_add_tail((struct list_head *)&ops->list, list);
92641 if (ops->init || (ops->id && ops->size)) {
92642 for_each_net(net) {
92643 error = ops_init(ops, net);
92644 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
92645
92646 out_undo:
92647 /* If I have an error cleanup all namespaces I initialized */
92648 - list_del(&ops->list);
92649 + pax_list_del((struct list_head *)&ops->list);
92650 ops_exit_list(ops, &net_exit_list);
92651 ops_free_list(ops, &net_exit_list);
92652 return error;
92653 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
92654 struct net *net;
92655 LIST_HEAD(net_exit_list);
92656
92657 - list_del(&ops->list);
92658 + pax_list_del((struct list_head *)&ops->list);
92659 for_each_net(net)
92660 list_add_tail(&net->exit_list, &net_exit_list);
92661 ops_exit_list(ops, &net_exit_list);
92662 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
92663 mutex_lock(&net_mutex);
92664 error = register_pernet_operations(&pernet_list, ops);
92665 if (!error && (first_device == &pernet_list))
92666 - first_device = &ops->list;
92667 + first_device = (struct list_head *)&ops->list;
92668 mutex_unlock(&net_mutex);
92669 return error;
92670 }
92671 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
92672 index fc75c9e..8c8e9be 100644
92673 --- a/net/core/netpoll.c
92674 +++ b/net/core/netpoll.c
92675 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92676 struct udphdr *udph;
92677 struct iphdr *iph;
92678 struct ethhdr *eth;
92679 - static atomic_t ip_ident;
92680 + static atomic_unchecked_t ip_ident;
92681 struct ipv6hdr *ip6h;
92682
92683 udp_len = len + sizeof(*udph);
92684 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92685 put_unaligned(0x45, (unsigned char *)iph);
92686 iph->tos = 0;
92687 put_unaligned(htons(ip_len), &(iph->tot_len));
92688 - iph->id = htons(atomic_inc_return(&ip_ident));
92689 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
92690 iph->frag_off = 0;
92691 iph->ttl = 64;
92692 iph->protocol = IPPROTO_UDP;
92693 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
92694 index 2a0e21d..6ad7642 100644
92695 --- a/net/core/rtnetlink.c
92696 +++ b/net/core/rtnetlink.c
92697 @@ -58,7 +58,7 @@ struct rtnl_link {
92698 rtnl_doit_func doit;
92699 rtnl_dumpit_func dumpit;
92700 rtnl_calcit_func calcit;
92701 -};
92702 +} __no_const;
92703
92704 static DEFINE_MUTEX(rtnl_mutex);
92705
92706 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
92707 if (rtnl_link_ops_get(ops->kind))
92708 return -EEXIST;
92709
92710 - if (!ops->dellink)
92711 - ops->dellink = unregister_netdevice_queue;
92712 + if (!ops->dellink) {
92713 + pax_open_kernel();
92714 + *(void **)&ops->dellink = unregister_netdevice_queue;
92715 + pax_close_kernel();
92716 + }
92717
92718 - list_add_tail(&ops->list, &link_ops);
92719 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
92720 return 0;
92721 }
92722 EXPORT_SYMBOL_GPL(__rtnl_link_register);
92723 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
92724 for_each_net(net) {
92725 __rtnl_kill_links(net, ops);
92726 }
92727 - list_del(&ops->list);
92728 + pax_list_del((struct list_head *)&ops->list);
92729 }
92730 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
92731
92732 diff --git a/net/core/scm.c b/net/core/scm.c
92733 index b442e7e..6f5b5a2 100644
92734 --- a/net/core/scm.c
92735 +++ b/net/core/scm.c
92736 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
92737 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92738 {
92739 struct cmsghdr __user *cm
92740 - = (__force struct cmsghdr __user *)msg->msg_control;
92741 + = (struct cmsghdr __force_user *)msg->msg_control;
92742 struct cmsghdr cmhdr;
92743 int cmlen = CMSG_LEN(len);
92744 int err;
92745 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92746 err = -EFAULT;
92747 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
92748 goto out;
92749 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
92750 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
92751 goto out;
92752 cmlen = CMSG_SPACE(len);
92753 if (msg->msg_controllen < cmlen)
92754 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
92755 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92756 {
92757 struct cmsghdr __user *cm
92758 - = (__force struct cmsghdr __user*)msg->msg_control;
92759 + = (struct cmsghdr __force_user *)msg->msg_control;
92760
92761 int fdmax = 0;
92762 int fdnum = scm->fp->count;
92763 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92764 if (fdnum < fdmax)
92765 fdmax = fdnum;
92766
92767 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
92768 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
92769 i++, cmfptr++)
92770 {
92771 struct socket *sock;
92772 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
92773 index d81cff1..e31f952 100644
92774 --- a/net/core/skbuff.c
92775 +++ b/net/core/skbuff.c
92776 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
92777 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
92778 sizeof(struct sk_buff),
92779 0,
92780 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92781 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92782 + SLAB_NO_SANITIZE,
92783 NULL);
92784 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
92785 (2*sizeof(struct sk_buff)) +
92786 sizeof(atomic_t),
92787 0,
92788 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92789 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92790 + SLAB_NO_SANITIZE,
92791 NULL);
92792 }
92793
92794 diff --git a/net/core/sock.c b/net/core/sock.c
92795 index 0b39e7a..5e9f91e 100644
92796 --- a/net/core/sock.c
92797 +++ b/net/core/sock.c
92798 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92799 struct sk_buff_head *list = &sk->sk_receive_queue;
92800
92801 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
92802 - atomic_inc(&sk->sk_drops);
92803 + atomic_inc_unchecked(&sk->sk_drops);
92804 trace_sock_rcvqueue_full(sk, skb);
92805 return -ENOMEM;
92806 }
92807 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92808 return err;
92809
92810 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
92811 - atomic_inc(&sk->sk_drops);
92812 + atomic_inc_unchecked(&sk->sk_drops);
92813 return -ENOBUFS;
92814 }
92815
92816 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92817 skb_dst_force(skb);
92818
92819 spin_lock_irqsave(&list->lock, flags);
92820 - skb->dropcount = atomic_read(&sk->sk_drops);
92821 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
92822 __skb_queue_tail(list, skb);
92823 spin_unlock_irqrestore(&list->lock, flags);
92824
92825 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92826 skb->dev = NULL;
92827
92828 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
92829 - atomic_inc(&sk->sk_drops);
92830 + atomic_inc_unchecked(&sk->sk_drops);
92831 goto discard_and_relse;
92832 }
92833 if (nested)
92834 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92835 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
92836 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
92837 bh_unlock_sock(sk);
92838 - atomic_inc(&sk->sk_drops);
92839 + atomic_inc_unchecked(&sk->sk_drops);
92840 goto discard_and_relse;
92841 }
92842
92843 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92844 struct timeval tm;
92845 } v;
92846
92847 - int lv = sizeof(int);
92848 - int len;
92849 + unsigned int lv = sizeof(int);
92850 + unsigned int len;
92851
92852 if (get_user(len, optlen))
92853 return -EFAULT;
92854 - if (len < 0)
92855 + if (len > INT_MAX)
92856 return -EINVAL;
92857
92858 memset(&v, 0, sizeof(v));
92859 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92860
92861 case SO_PEERNAME:
92862 {
92863 - char address[128];
92864 + char address[_K_SS_MAXSIZE];
92865
92866 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
92867 return -ENOTCONN;
92868 - if (lv < len)
92869 + if (lv < len || sizeof address < len)
92870 return -EINVAL;
92871 if (copy_to_user(optval, address, len))
92872 return -EFAULT;
92873 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92874
92875 if (len > lv)
92876 len = lv;
92877 - if (copy_to_user(optval, &v, len))
92878 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
92879 return -EFAULT;
92880 lenout:
92881 if (put_user(len, optlen))
92882 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
92883 */
92884 smp_wmb();
92885 atomic_set(&sk->sk_refcnt, 1);
92886 - atomic_set(&sk->sk_drops, 0);
92887 + atomic_set_unchecked(&sk->sk_drops, 0);
92888 }
92889 EXPORT_SYMBOL(sock_init_data);
92890
92891 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
92892 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
92893 int level, int type)
92894 {
92895 + struct sock_extended_err ee;
92896 struct sock_exterr_skb *serr;
92897 struct sk_buff *skb, *skb2;
92898 int copied, err;
92899 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
92900 sock_recv_timestamp(msg, sk, skb);
92901
92902 serr = SKB_EXT_ERR(skb);
92903 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
92904 + ee = serr->ee;
92905 + put_cmsg(msg, level, type, sizeof ee, &ee);
92906
92907 msg->msg_flags |= MSG_ERRQUEUE;
92908 err = copied;
92909 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
92910 index a0e9cf6..ef7f9ed 100644
92911 --- a/net/core/sock_diag.c
92912 +++ b/net/core/sock_diag.c
92913 @@ -9,26 +9,33 @@
92914 #include <linux/inet_diag.h>
92915 #include <linux/sock_diag.h>
92916
92917 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
92918 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
92919 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
92920 static DEFINE_MUTEX(sock_diag_table_mutex);
92921
92922 int sock_diag_check_cookie(void *sk, __u32 *cookie)
92923 {
92924 +#ifndef CONFIG_GRKERNSEC_HIDESYM
92925 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
92926 cookie[1] != INET_DIAG_NOCOOKIE) &&
92927 ((u32)(unsigned long)sk != cookie[0] ||
92928 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
92929 return -ESTALE;
92930 else
92931 +#endif
92932 return 0;
92933 }
92934 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
92935
92936 void sock_diag_save_cookie(void *sk, __u32 *cookie)
92937 {
92938 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92939 + cookie[0] = 0;
92940 + cookie[1] = 0;
92941 +#else
92942 cookie[0] = (u32)(unsigned long)sk;
92943 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
92944 +#endif
92945 }
92946 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
92947
92948 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
92949 mutex_lock(&sock_diag_table_mutex);
92950 if (sock_diag_handlers[hndl->family])
92951 err = -EBUSY;
92952 - else
92953 + else {
92954 + pax_open_kernel();
92955 sock_diag_handlers[hndl->family] = hndl;
92956 + pax_close_kernel();
92957 + }
92958 mutex_unlock(&sock_diag_table_mutex);
92959
92960 return err;
92961 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
92962
92963 mutex_lock(&sock_diag_table_mutex);
92964 BUG_ON(sock_diag_handlers[family] != hnld);
92965 + pax_open_kernel();
92966 sock_diag_handlers[family] = NULL;
92967 + pax_close_kernel();
92968 mutex_unlock(&sock_diag_table_mutex);
92969 }
92970 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92971 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92972 index cca4441..5e616de 100644
92973 --- a/net/core/sysctl_net_core.c
92974 +++ b/net/core/sysctl_net_core.c
92975 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92976 {
92977 unsigned int orig_size, size;
92978 int ret, i;
92979 - struct ctl_table tmp = {
92980 + ctl_table_no_const tmp = {
92981 .data = &size,
92982 .maxlen = sizeof(size),
92983 .mode = table->mode
92984 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
92985 void __user *buffer, size_t *lenp, loff_t *ppos)
92986 {
92987 char id[IFNAMSIZ];
92988 - struct ctl_table tbl = {
92989 + ctl_table_no_const tbl = {
92990 .data = id,
92991 .maxlen = IFNAMSIZ,
92992 };
92993 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
92994
92995 static __net_init int sysctl_core_net_init(struct net *net)
92996 {
92997 - struct ctl_table *tbl;
92998 + ctl_table_no_const *tbl = NULL;
92999
93000 net->core.sysctl_somaxconn = SOMAXCONN;
93001
93002 - tbl = netns_core_table;
93003 if (!net_eq(net, &init_net)) {
93004 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
93005 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
93006 if (tbl == NULL)
93007 goto err_dup;
93008
93009 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
93010 if (net->user_ns != &init_user_ns) {
93011 tbl[0].procname = NULL;
93012 }
93013 - }
93014 -
93015 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93016 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93017 + } else
93018 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
93019 if (net->core.sysctl_hdr == NULL)
93020 goto err_reg;
93021
93022 return 0;
93023
93024 err_reg:
93025 - if (tbl != netns_core_table)
93026 - kfree(tbl);
93027 + kfree(tbl);
93028 err_dup:
93029 return -ENOMEM;
93030 }
93031 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
93032 kfree(tbl);
93033 }
93034
93035 -static __net_initdata struct pernet_operations sysctl_core_ops = {
93036 +static __net_initconst struct pernet_operations sysctl_core_ops = {
93037 .init = sysctl_core_net_init,
93038 .exit = sysctl_core_net_exit,
93039 };
93040 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
93041 index dd4d506..fb2fb87 100644
93042 --- a/net/decnet/af_decnet.c
93043 +++ b/net/decnet/af_decnet.c
93044 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
93045 .sysctl_rmem = sysctl_decnet_rmem,
93046 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
93047 .obj_size = sizeof(struct dn_sock),
93048 + .slab_flags = SLAB_USERCOPY,
93049 };
93050
93051 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
93052 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
93053 index 5325b54..a0d4d69 100644
93054 --- a/net/decnet/sysctl_net_decnet.c
93055 +++ b/net/decnet/sysctl_net_decnet.c
93056 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
93057
93058 if (len > *lenp) len = *lenp;
93059
93060 - if (copy_to_user(buffer, addr, len))
93061 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
93062 return -EFAULT;
93063
93064 *lenp = len;
93065 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
93066
93067 if (len > *lenp) len = *lenp;
93068
93069 - if (copy_to_user(buffer, devname, len))
93070 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
93071 return -EFAULT;
93072
93073 *lenp = len;
93074 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
93075 index ff41b4d6..6125050 100644
93076 --- a/net/ieee802154/6lowpan.c
93077 +++ b/net/ieee802154/6lowpan.c
93078 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
93079 hc06_ptr += 3;
93080 } else {
93081 /* compress nothing */
93082 - memcpy(hc06_ptr, &hdr, 4);
93083 + memcpy(hc06_ptr, hdr, 4);
93084 /* replace the top byte with new ECN | DSCP format */
93085 *hc06_ptr = tmp;
93086 hc06_ptr += 4;
93087 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
93088 index cfeb85c..385989a 100644
93089 --- a/net/ipv4/af_inet.c
93090 +++ b/net/ipv4/af_inet.c
93091 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
93092
93093 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
93094
93095 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
93096 - if (!sysctl_local_reserved_ports)
93097 - goto out;
93098 -
93099 rc = proto_register(&tcp_prot, 1);
93100 if (rc)
93101 - goto out_free_reserved_ports;
93102 + goto out;
93103
93104 rc = proto_register(&udp_prot, 1);
93105 if (rc)
93106 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
93107 proto_unregister(&udp_prot);
93108 out_unregister_tcp_proto:
93109 proto_unregister(&tcp_prot);
93110 -out_free_reserved_ports:
93111 - kfree(sysctl_local_reserved_ports);
93112 goto out;
93113 }
93114
93115 diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
93116 index b28e863..19e3637 100644
93117 --- a/net/ipv4/datagram.c
93118 +++ b/net/ipv4/datagram.c
93119 @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
93120 if (IS_ERR(rt)) {
93121 err = PTR_ERR(rt);
93122 if (err == -ENETUNREACH)
93123 - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
93124 + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
93125 goto out;
93126 }
93127
93128 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
93129 index a1b5bcb..62ec5c6 100644
93130 --- a/net/ipv4/devinet.c
93131 +++ b/net/ipv4/devinet.c
93132 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
93133 idx = 0;
93134 head = &net->dev_index_head[h];
93135 rcu_read_lock();
93136 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93137 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93138 net->dev_base_seq;
93139 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93140 if (idx < s_idx)
93141 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
93142 idx = 0;
93143 head = &net->dev_index_head[h];
93144 rcu_read_lock();
93145 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93146 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93147 net->dev_base_seq;
93148 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93149 if (idx < s_idx)
93150 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
93151 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
93152 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
93153
93154 -static struct devinet_sysctl_table {
93155 +static const struct devinet_sysctl_table {
93156 struct ctl_table_header *sysctl_header;
93157 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
93158 } devinet_sysctl = {
93159 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
93160 int err;
93161 struct ipv4_devconf *all, *dflt;
93162 #ifdef CONFIG_SYSCTL
93163 - struct ctl_table *tbl = ctl_forward_entry;
93164 + ctl_table_no_const *tbl = NULL;
93165 struct ctl_table_header *forw_hdr;
93166 #endif
93167
93168 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
93169 goto err_alloc_dflt;
93170
93171 #ifdef CONFIG_SYSCTL
93172 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
93173 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
93174 if (tbl == NULL)
93175 goto err_alloc_ctl;
93176
93177 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
93178 goto err_reg_dflt;
93179
93180 err = -ENOMEM;
93181 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93182 + if (!net_eq(net, &init_net))
93183 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93184 + else
93185 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
93186 if (forw_hdr == NULL)
93187 goto err_reg_ctl;
93188 net->ipv4.forw_hdr = forw_hdr;
93189 @@ -2245,8 +2248,7 @@ err_reg_ctl:
93190 err_reg_dflt:
93191 __devinet_sysctl_unregister(all);
93192 err_reg_all:
93193 - if (tbl != ctl_forward_entry)
93194 - kfree(tbl);
93195 + kfree(tbl);
93196 err_alloc_ctl:
93197 #endif
93198 if (dflt != &ipv4_devconf_dflt)
93199 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
93200 index b3f627a..b0f3e99 100644
93201 --- a/net/ipv4/fib_frontend.c
93202 +++ b/net/ipv4/fib_frontend.c
93203 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
93204 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93205 fib_sync_up(dev);
93206 #endif
93207 - atomic_inc(&net->ipv4.dev_addr_genid);
93208 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93209 rt_cache_flush(dev_net(dev));
93210 break;
93211 case NETDEV_DOWN:
93212 fib_del_ifaddr(ifa, NULL);
93213 - atomic_inc(&net->ipv4.dev_addr_genid);
93214 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93215 if (ifa->ifa_dev->ifa_list == NULL) {
93216 /* Last address was deleted from this interface.
93217 * Disable IP.
93218 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
93219 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93220 fib_sync_up(dev);
93221 #endif
93222 - atomic_inc(&net->ipv4.dev_addr_genid);
93223 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93224 rt_cache_flush(net);
93225 break;
93226 case NETDEV_DOWN:
93227 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
93228 index d5dbca5..6251d5f 100644
93229 --- a/net/ipv4/fib_semantics.c
93230 +++ b/net/ipv4/fib_semantics.c
93231 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
93232 nh->nh_saddr = inet_select_addr(nh->nh_dev,
93233 nh->nh_gw,
93234 nh->nh_parent->fib_scope);
93235 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
93236 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
93237
93238 return nh->nh_saddr;
93239 }
93240 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
93241 index 6acb541..9ea617d 100644
93242 --- a/net/ipv4/inet_connection_sock.c
93243 +++ b/net/ipv4/inet_connection_sock.c
93244 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
93245 .range = { 32768, 61000 },
93246 };
93247
93248 -unsigned long *sysctl_local_reserved_ports;
93249 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
93250 EXPORT_SYMBOL(sysctl_local_reserved_ports);
93251
93252 void inet_get_local_port_range(int *low, int *high)
93253 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
93254 index 96da9c7..b956690 100644
93255 --- a/net/ipv4/inet_hashtables.c
93256 +++ b/net/ipv4/inet_hashtables.c
93257 @@ -18,12 +18,15 @@
93258 #include <linux/sched.h>
93259 #include <linux/slab.h>
93260 #include <linux/wait.h>
93261 +#include <linux/security.h>
93262
93263 #include <net/inet_connection_sock.h>
93264 #include <net/inet_hashtables.h>
93265 #include <net/secure_seq.h>
93266 #include <net/ip.h>
93267
93268 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
93269 +
93270 /*
93271 * Allocate and initialize a new local port bind bucket.
93272 * The bindhash mutex for snum's hash chain must be held here.
93273 @@ -554,6 +557,8 @@ ok:
93274 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
93275 spin_unlock(&head->lock);
93276
93277 + gr_update_task_in_ip_table(current, inet_sk(sk));
93278 +
93279 if (tw) {
93280 inet_twsk_deschedule(tw, death_row);
93281 while (twrefcnt) {
93282 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
93283 index 33d5537..da337a4 100644
93284 --- a/net/ipv4/inetpeer.c
93285 +++ b/net/ipv4/inetpeer.c
93286 @@ -503,8 +503,8 @@ relookup:
93287 if (p) {
93288 p->daddr = *daddr;
93289 atomic_set(&p->refcnt, 1);
93290 - atomic_set(&p->rid, 0);
93291 - atomic_set(&p->ip_id_count,
93292 + atomic_set_unchecked(&p->rid, 0);
93293 + atomic_set_unchecked(&p->ip_id_count,
93294 (daddr->family == AF_INET) ?
93295 secure_ip_id(daddr->addr.a4) :
93296 secure_ipv6_id(daddr->addr.a6));
93297 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
93298 index b66910a..cfe416e 100644
93299 --- a/net/ipv4/ip_fragment.c
93300 +++ b/net/ipv4/ip_fragment.c
93301 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
93302 return 0;
93303
93304 start = qp->rid;
93305 - end = atomic_inc_return(&peer->rid);
93306 + end = atomic_inc_return_unchecked(&peer->rid);
93307 qp->rid = end;
93308
93309 rc = qp->q.fragments && (end - start) > max;
93310 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
93311
93312 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93313 {
93314 - struct ctl_table *table;
93315 + ctl_table_no_const *table = NULL;
93316 struct ctl_table_header *hdr;
93317
93318 - table = ip4_frags_ns_ctl_table;
93319 if (!net_eq(net, &init_net)) {
93320 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93321 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93322 if (table == NULL)
93323 goto err_alloc;
93324
93325 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93326 /* Don't export sysctls to unprivileged users */
93327 if (net->user_ns != &init_user_ns)
93328 table[0].procname = NULL;
93329 - }
93330 + hdr = register_net_sysctl(net, "net/ipv4", table);
93331 + } else
93332 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
93333
93334 - hdr = register_net_sysctl(net, "net/ipv4", table);
93335 if (hdr == NULL)
93336 goto err_reg;
93337
93338 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93339 return 0;
93340
93341 err_reg:
93342 - if (!net_eq(net, &init_net))
93343 - kfree(table);
93344 + kfree(table);
93345 err_alloc:
93346 return -ENOMEM;
93347 }
93348 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
93349 index d7aea4c..a8ee872 100644
93350 --- a/net/ipv4/ip_gre.c
93351 +++ b/net/ipv4/ip_gre.c
93352 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
93353 module_param(log_ecn_error, bool, 0644);
93354 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93355
93356 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
93357 +static struct rtnl_link_ops ipgre_link_ops;
93358 static int ipgre_tunnel_init(struct net_device *dev);
93359
93360 static int ipgre_net_id __read_mostly;
93361 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
93362 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
93363 };
93364
93365 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93366 +static struct rtnl_link_ops ipgre_link_ops = {
93367 .kind = "gre",
93368 .maxtype = IFLA_GRE_MAX,
93369 .policy = ipgre_policy,
93370 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93371 .fill_info = ipgre_fill_info,
93372 };
93373
93374 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
93375 +static struct rtnl_link_ops ipgre_tap_ops = {
93376 .kind = "gretap",
93377 .maxtype = IFLA_GRE_MAX,
93378 .policy = ipgre_policy,
93379 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
93380 index d9c4f11..02b82dbc 100644
93381 --- a/net/ipv4/ip_sockglue.c
93382 +++ b/net/ipv4/ip_sockglue.c
93383 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93384 len = min_t(unsigned int, len, opt->optlen);
93385 if (put_user(len, optlen))
93386 return -EFAULT;
93387 - if (copy_to_user(optval, opt->__data, len))
93388 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
93389 + copy_to_user(optval, opt->__data, len))
93390 return -EFAULT;
93391 return 0;
93392 }
93393 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93394 if (sk->sk_type != SOCK_STREAM)
93395 return -ENOPROTOOPT;
93396
93397 - msg.msg_control = optval;
93398 + msg.msg_control = (void __force_kernel *)optval;
93399 msg.msg_controllen = len;
93400 msg.msg_flags = flags;
93401
93402 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
93403 index 6e87f85..2c28e240 100644
93404 --- a/net/ipv4/ip_vti.c
93405 +++ b/net/ipv4/ip_vti.c
93406 @@ -44,7 +44,7 @@
93407 #include <net/net_namespace.h>
93408 #include <net/netns/generic.h>
93409
93410 -static struct rtnl_link_ops vti_link_ops __read_mostly;
93411 +static struct rtnl_link_ops vti_link_ops;
93412
93413 static int vti_net_id __read_mostly;
93414 static int vti_tunnel_init(struct net_device *dev);
93415 @@ -424,7 +424,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
93416 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
93417 };
93418
93419 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
93420 +static struct rtnl_link_ops vti_link_ops = {
93421 .kind = "vti",
93422 .maxtype = IFLA_VTI_MAX,
93423 .policy = vti_policy,
93424 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
93425 index efa1138..20dbba0 100644
93426 --- a/net/ipv4/ipconfig.c
93427 +++ b/net/ipv4/ipconfig.c
93428 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
93429
93430 mm_segment_t oldfs = get_fs();
93431 set_fs(get_ds());
93432 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93433 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93434 set_fs(oldfs);
93435 return res;
93436 }
93437 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
93438
93439 mm_segment_t oldfs = get_fs();
93440 set_fs(get_ds());
93441 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93442 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93443 set_fs(oldfs);
93444 return res;
93445 }
93446 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
93447
93448 mm_segment_t oldfs = get_fs();
93449 set_fs(get_ds());
93450 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
93451 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
93452 set_fs(oldfs);
93453 return res;
93454 }
93455 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
93456 index 7f80fb4..b0328f6 100644
93457 --- a/net/ipv4/ipip.c
93458 +++ b/net/ipv4/ipip.c
93459 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93460 static int ipip_net_id __read_mostly;
93461
93462 static int ipip_tunnel_init(struct net_device *dev);
93463 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
93464 +static struct rtnl_link_ops ipip_link_ops;
93465
93466 static int ipip_err(struct sk_buff *skb, u32 info)
93467 {
93468 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
93469 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
93470 };
93471
93472 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
93473 +static struct rtnl_link_ops ipip_link_ops = {
93474 .kind = "ipip",
93475 .maxtype = IFLA_IPTUN_MAX,
93476 .policy = ipip_policy,
93477 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
93478 index 85a4f21..1beb1f5 100644
93479 --- a/net/ipv4/netfilter/arp_tables.c
93480 +++ b/net/ipv4/netfilter/arp_tables.c
93481 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
93482 #endif
93483
93484 static int get_info(struct net *net, void __user *user,
93485 - const int *len, int compat)
93486 + int len, int compat)
93487 {
93488 char name[XT_TABLE_MAXNAMELEN];
93489 struct xt_table *t;
93490 int ret;
93491
93492 - if (*len != sizeof(struct arpt_getinfo)) {
93493 - duprintf("length %u != %Zu\n", *len,
93494 + if (len != sizeof(struct arpt_getinfo)) {
93495 + duprintf("length %u != %Zu\n", len,
93496 sizeof(struct arpt_getinfo));
93497 return -EINVAL;
93498 }
93499 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
93500 info.size = private->size;
93501 strcpy(info.name, name);
93502
93503 - if (copy_to_user(user, &info, *len) != 0)
93504 + if (copy_to_user(user, &info, len) != 0)
93505 ret = -EFAULT;
93506 else
93507 ret = 0;
93508 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
93509
93510 switch (cmd) {
93511 case ARPT_SO_GET_INFO:
93512 - ret = get_info(sock_net(sk), user, len, 1);
93513 + ret = get_info(sock_net(sk), user, *len, 1);
93514 break;
93515 case ARPT_SO_GET_ENTRIES:
93516 ret = compat_get_entries(sock_net(sk), user, len);
93517 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
93518
93519 switch (cmd) {
93520 case ARPT_SO_GET_INFO:
93521 - ret = get_info(sock_net(sk), user, len, 0);
93522 + ret = get_info(sock_net(sk), user, *len, 0);
93523 break;
93524
93525 case ARPT_SO_GET_ENTRIES:
93526 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
93527 index d23118d..6ad7277 100644
93528 --- a/net/ipv4/netfilter/ip_tables.c
93529 +++ b/net/ipv4/netfilter/ip_tables.c
93530 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
93531 #endif
93532
93533 static int get_info(struct net *net, void __user *user,
93534 - const int *len, int compat)
93535 + int len, int compat)
93536 {
93537 char name[XT_TABLE_MAXNAMELEN];
93538 struct xt_table *t;
93539 int ret;
93540
93541 - if (*len != sizeof(struct ipt_getinfo)) {
93542 - duprintf("length %u != %zu\n", *len,
93543 + if (len != sizeof(struct ipt_getinfo)) {
93544 + duprintf("length %u != %zu\n", len,
93545 sizeof(struct ipt_getinfo));
93546 return -EINVAL;
93547 }
93548 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
93549 info.size = private->size;
93550 strcpy(info.name, name);
93551
93552 - if (copy_to_user(user, &info, *len) != 0)
93553 + if (copy_to_user(user, &info, len) != 0)
93554 ret = -EFAULT;
93555 else
93556 ret = 0;
93557 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93558
93559 switch (cmd) {
93560 case IPT_SO_GET_INFO:
93561 - ret = get_info(sock_net(sk), user, len, 1);
93562 + ret = get_info(sock_net(sk), user, *len, 1);
93563 break;
93564 case IPT_SO_GET_ENTRIES:
93565 ret = compat_get_entries(sock_net(sk), user, len);
93566 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93567
93568 switch (cmd) {
93569 case IPT_SO_GET_INFO:
93570 - ret = get_info(sock_net(sk), user, len, 0);
93571 + ret = get_info(sock_net(sk), user, *len, 0);
93572 break;
93573
93574 case IPT_SO_GET_ENTRIES:
93575 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
93576 index cbc2215..9cb993c 100644
93577 --- a/net/ipv4/netfilter/ipt_ULOG.c
93578 +++ b/net/ipv4/netfilter/ipt_ULOG.c
93579 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
93580 ub->qlen++;
93581
93582 pm = nlmsg_data(nlh);
93583 + memset(pm, 0, sizeof(*pm));
93584
93585 /* We might not have a timestamp, get one */
93586 if (skb->tstamp.tv64 == 0)
93587 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
93588 }
93589 else if (loginfo->prefix[0] != '\0')
93590 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
93591 - else
93592 - *(pm->prefix) = '\0';
93593
93594 if (in && in->hard_header_len > 0 &&
93595 skb->mac_header != skb->network_header &&
93596 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
93597
93598 if (in)
93599 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
93600 - else
93601 - pm->indev_name[0] = '\0';
93602
93603 if (out)
93604 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
93605 - else
93606 - pm->outdev_name[0] = '\0';
93607
93608 /* copy_len <= skb->len, so can't fail. */
93609 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
93610 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
93611 index d7d9882..d700c68 100644
93612 --- a/net/ipv4/ping.c
93613 +++ b/net/ipv4/ping.c
93614 @@ -55,7 +55,7 @@
93615
93616
93617 struct ping_table ping_table;
93618 -struct pingv6_ops pingv6_ops;
93619 +struct pingv6_ops *pingv6_ops;
93620 EXPORT_SYMBOL_GPL(pingv6_ops);
93621
93622 static u16 ping_port_rover;
93623 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
93624 return -ENODEV;
93625 }
93626 }
93627 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
93628 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
93629 scoped);
93630 rcu_read_unlock();
93631
93632 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93633 }
93634 #if IS_ENABLED(CONFIG_IPV6)
93635 } else if (skb->protocol == htons(ETH_P_IPV6)) {
93636 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
93637 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
93638 #endif
93639 }
93640
93641 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93642 info, (u8 *)icmph);
93643 #if IS_ENABLED(CONFIG_IPV6)
93644 } else if (family == AF_INET6) {
93645 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
93646 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
93647 info, (u8 *)icmph);
93648 #endif
93649 }
93650 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93651 return ip_recv_error(sk, msg, len);
93652 #if IS_ENABLED(CONFIG_IPV6)
93653 } else if (family == AF_INET6) {
93654 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
93655 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
93656 #endif
93657 }
93658 }
93659 @@ -874,11 +874,14 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93660
93661 /* Copy the address and add cmsg data. */
93662 if (family == AF_INET) {
93663 - sin = (struct sockaddr_in *) msg->msg_name;
93664 - sin->sin_family = AF_INET;
93665 - sin->sin_port = 0 /* skb->h.uh->source */;
93666 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93667 - memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93668 + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
93669 +
93670 + if (sin) {
93671 + sin->sin_family = AF_INET;
93672 + sin->sin_port = 0 /* skb->h.uh->source */;
93673 + sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93674 + memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93675 + }
93676
93677 if (isk->cmsg_flags)
93678 ip_cmsg_recv(msg, skb);
93679 @@ -887,20 +890,23 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93680 } else if (family == AF_INET6) {
93681 struct ipv6_pinfo *np = inet6_sk(sk);
93682 struct ipv6hdr *ip6 = ipv6_hdr(skb);
93683 - sin6 = (struct sockaddr_in6 *) msg->msg_name;
93684 - sin6->sin6_family = AF_INET6;
93685 - sin6->sin6_port = 0;
93686 - sin6->sin6_addr = ip6->saddr;
93687 + struct sockaddr_in6 *sin6 =
93688 + (struct sockaddr_in6 *)msg->msg_name;
93689
93690 - sin6->sin6_flowinfo = 0;
93691 - if (np->sndflow)
93692 - sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93693 -
93694 - sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
93695 - IP6CB(skb)->iif);
93696 + if (sin6) {
93697 + sin6->sin6_family = AF_INET6;
93698 + sin6->sin6_port = 0;
93699 + sin6->sin6_addr = ip6->saddr;
93700 + sin6->sin6_flowinfo = 0;
93701 + if (np->sndflow)
93702 + sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93703 + sin6->sin6_scope_id =
93704 + ipv6_iface_scope_id(&sin6->sin6_addr,
93705 + IP6CB(skb)->iif);
93706 + }
93707
93708 if (inet6_sk(sk)->rxopt.all)
93709 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
93710 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
93711 #endif
93712 } else {
93713 BUG();
93714 @@ -1090,7 +1096,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
93715 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93716 0, sock_i_ino(sp),
93717 atomic_read(&sp->sk_refcnt), sp,
93718 - atomic_read(&sp->sk_drops), len);
93719 + atomic_read_unchecked(&sp->sk_drops), len);
93720 }
93721
93722 static int ping_v4_seq_show(struct seq_file *seq, void *v)
93723 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
93724 index 193db03..05ba36c 100644
93725 --- a/net/ipv4/raw.c
93726 +++ b/net/ipv4/raw.c
93727 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
93728 int raw_rcv(struct sock *sk, struct sk_buff *skb)
93729 {
93730 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
93731 - atomic_inc(&sk->sk_drops);
93732 + atomic_inc_unchecked(&sk->sk_drops);
93733 kfree_skb(skb);
93734 return NET_RX_DROP;
93735 }
93736 @@ -748,16 +748,20 @@ static int raw_init(struct sock *sk)
93737
93738 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
93739 {
93740 + struct icmp_filter filter;
93741 +
93742 if (optlen > sizeof(struct icmp_filter))
93743 optlen = sizeof(struct icmp_filter);
93744 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
93745 + if (copy_from_user(&filter, optval, optlen))
93746 return -EFAULT;
93747 + raw_sk(sk)->filter = filter;
93748 return 0;
93749 }
93750
93751 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
93752 {
93753 int len, ret = -EFAULT;
93754 + struct icmp_filter filter;
93755
93756 if (get_user(len, optlen))
93757 goto out;
93758 @@ -767,8 +771,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
93759 if (len > sizeof(struct icmp_filter))
93760 len = sizeof(struct icmp_filter);
93761 ret = -EFAULT;
93762 - if (put_user(len, optlen) ||
93763 - copy_to_user(optval, &raw_sk(sk)->filter, len))
93764 + filter = raw_sk(sk)->filter;
93765 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
93766 goto out;
93767 ret = 0;
93768 out: return ret;
93769 @@ -997,7 +1001,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
93770 0, 0L, 0,
93771 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
93772 0, sock_i_ino(sp),
93773 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
93774 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
93775 }
93776
93777 static int raw_seq_show(struct seq_file *seq, void *v)
93778 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
93779 index 6011615..f418576 100644
93780 --- a/net/ipv4/route.c
93781 +++ b/net/ipv4/route.c
93782 @@ -2613,34 +2613,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
93783 .maxlen = sizeof(int),
93784 .mode = 0200,
93785 .proc_handler = ipv4_sysctl_rtcache_flush,
93786 + .extra1 = &init_net,
93787 },
93788 { },
93789 };
93790
93791 static __net_init int sysctl_route_net_init(struct net *net)
93792 {
93793 - struct ctl_table *tbl;
93794 + ctl_table_no_const *tbl = NULL;
93795
93796 - tbl = ipv4_route_flush_table;
93797 if (!net_eq(net, &init_net)) {
93798 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93799 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93800 if (tbl == NULL)
93801 goto err_dup;
93802
93803 /* Don't export sysctls to unprivileged users */
93804 if (net->user_ns != &init_user_ns)
93805 tbl[0].procname = NULL;
93806 - }
93807 - tbl[0].extra1 = net;
93808 + tbl[0].extra1 = net;
93809 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93810 + } else
93811 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
93812
93813 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93814 if (net->ipv4.route_hdr == NULL)
93815 goto err_reg;
93816 return 0;
93817
93818 err_reg:
93819 - if (tbl != ipv4_route_flush_table)
93820 - kfree(tbl);
93821 + kfree(tbl);
93822 err_dup:
93823 return -ENOMEM;
93824 }
93825 @@ -2663,8 +2663,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
93826
93827 static __net_init int rt_genid_init(struct net *net)
93828 {
93829 - atomic_set(&net->ipv4.rt_genid, 0);
93830 - atomic_set(&net->fnhe_genid, 0);
93831 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
93832 + atomic_set_unchecked(&net->fnhe_genid, 0);
93833 get_random_bytes(&net->ipv4.dev_addr_genid,
93834 sizeof(net->ipv4.dev_addr_genid));
93835 return 0;
93836 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
93837 index 540279f..9855b16 100644
93838 --- a/net/ipv4/sysctl_net_ipv4.c
93839 +++ b/net/ipv4/sysctl_net_ipv4.c
93840 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
93841 {
93842 int ret;
93843 int range[2];
93844 - struct ctl_table tmp = {
93845 + ctl_table_no_const tmp = {
93846 .data = &range,
93847 .maxlen = sizeof(range),
93848 .mode = table->mode,
93849 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
93850 int ret;
93851 gid_t urange[2];
93852 kgid_t low, high;
93853 - struct ctl_table tmp = {
93854 + ctl_table_no_const tmp = {
93855 .data = &urange,
93856 .maxlen = sizeof(urange),
93857 .mode = table->mode,
93858 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
93859 void __user *buffer, size_t *lenp, loff_t *ppos)
93860 {
93861 char val[TCP_CA_NAME_MAX];
93862 - struct ctl_table tbl = {
93863 + ctl_table_no_const tbl = {
93864 .data = val,
93865 .maxlen = TCP_CA_NAME_MAX,
93866 };
93867 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
93868 void __user *buffer, size_t *lenp,
93869 loff_t *ppos)
93870 {
93871 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
93872 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
93873 int ret;
93874
93875 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93876 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
93877 void __user *buffer, size_t *lenp,
93878 loff_t *ppos)
93879 {
93880 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
93881 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
93882 int ret;
93883
93884 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93885 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
93886 struct mem_cgroup *memcg;
93887 #endif
93888
93889 - struct ctl_table tmp = {
93890 + ctl_table_no_const tmp = {
93891 .data = &vec,
93892 .maxlen = sizeof(vec),
93893 .mode = ctl->mode,
93894 };
93895
93896 if (!write) {
93897 - ctl->data = &net->ipv4.sysctl_tcp_mem;
93898 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
93899 + ctl_table_no_const tcp_mem = *ctl;
93900 +
93901 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
93902 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
93903 }
93904
93905 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
93906 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
93907 void __user *buffer, size_t *lenp,
93908 loff_t *ppos)
93909 {
93910 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93911 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93912 struct tcp_fastopen_context *ctxt;
93913 int ret;
93914 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
93915 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
93916 },
93917 {
93918 .procname = "ip_local_reserved_ports",
93919 - .data = NULL, /* initialized in sysctl_ipv4_init */
93920 + .data = sysctl_local_reserved_ports,
93921 .maxlen = 65536,
93922 .mode = 0644,
93923 .proc_handler = proc_do_large_bitmap,
93924 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
93925
93926 static __net_init int ipv4_sysctl_init_net(struct net *net)
93927 {
93928 - struct ctl_table *table;
93929 + ctl_table_no_const *table = NULL;
93930
93931 - table = ipv4_net_table;
93932 if (!net_eq(net, &init_net)) {
93933 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
93934 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
93935 if (table == NULL)
93936 goto err_alloc;
93937
93938 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
93939
93940 tcp_init_mem(net);
93941
93942 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93943 + if (!net_eq(net, &init_net))
93944 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93945 + else
93946 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
93947 if (net->ipv4.ipv4_hdr == NULL)
93948 goto err_reg;
93949
93950 return 0;
93951
93952 err_reg:
93953 - if (!net_eq(net, &init_net))
93954 - kfree(table);
93955 + kfree(table);
93956 err_alloc:
93957 return -ENOMEM;
93958 }
93959 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
93960 static __init int sysctl_ipv4_init(void)
93961 {
93962 struct ctl_table_header *hdr;
93963 - struct ctl_table *i;
93964 -
93965 - for (i = ipv4_table; i->procname; i++) {
93966 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
93967 - i->data = sysctl_local_reserved_ports;
93968 - break;
93969 - }
93970 - }
93971 - if (!i->procname)
93972 - return -EINVAL;
93973
93974 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
93975 if (hdr == NULL)
93976 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
93977 index 068c8fb..a755c52 100644
93978 --- a/net/ipv4/tcp_input.c
93979 +++ b/net/ipv4/tcp_input.c
93980 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
93981 * simplifies code)
93982 */
93983 static void
93984 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93985 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93986 struct sk_buff *head, struct sk_buff *tail,
93987 u32 start, u32 end)
93988 {
93989 @@ -5520,6 +5520,7 @@ discard:
93990 tcp_paws_reject(&tp->rx_opt, 0))
93991 goto discard_and_undo;
93992
93993 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
93994 if (th->syn) {
93995 /* We see SYN without ACK. It is attempt of
93996 * simultaneous connect with crossed SYNs.
93997 @@ -5570,6 +5571,7 @@ discard:
93998 goto discard;
93999 #endif
94000 }
94001 +#endif
94002 /* "fifth, if neither of the SYN or RST bits is set then
94003 * drop the segment and return."
94004 */
94005 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
94006 goto discard;
94007
94008 if (th->syn) {
94009 - if (th->fin)
94010 + if (th->fin || th->urg || th->psh)
94011 goto discard;
94012 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
94013 return 1;
94014 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
94015 index b14266b..c5fe725 100644
94016 --- a/net/ipv4/tcp_ipv4.c
94017 +++ b/net/ipv4/tcp_ipv4.c
94018 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
94019 EXPORT_SYMBOL(sysctl_tcp_low_latency);
94020
94021
94022 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94023 +extern int grsec_enable_blackhole;
94024 +#endif
94025 +
94026 #ifdef CONFIG_TCP_MD5SIG
94027 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94028 __be32 daddr, __be32 saddr, const struct tcphdr *th);
94029 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
94030 return 0;
94031
94032 reset:
94033 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94034 + if (!grsec_enable_blackhole)
94035 +#endif
94036 tcp_v4_send_reset(rsk, skb);
94037 discard:
94038 kfree_skb(skb);
94039 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
94040 TCP_SKB_CB(skb)->sacked = 0;
94041
94042 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94043 - if (!sk)
94044 + if (!sk) {
94045 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94046 + ret = 1;
94047 +#endif
94048 goto no_tcp_socket;
94049 -
94050 + }
94051 process:
94052 - if (sk->sk_state == TCP_TIME_WAIT)
94053 + if (sk->sk_state == TCP_TIME_WAIT) {
94054 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94055 + ret = 2;
94056 +#endif
94057 goto do_time_wait;
94058 + }
94059
94060 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
94061 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94062 @@ -2033,6 +2047,10 @@ csum_error:
94063 bad_packet:
94064 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94065 } else {
94066 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94067 + if (!grsec_enable_blackhole || (ret == 1 &&
94068 + (skb->dev->flags & IFF_LOOPBACK)))
94069 +#endif
94070 tcp_v4_send_reset(NULL, skb);
94071 }
94072
94073 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
94074 index 58a3e69..7f0626e 100644
94075 --- a/net/ipv4/tcp_minisocks.c
94076 +++ b/net/ipv4/tcp_minisocks.c
94077 @@ -27,6 +27,10 @@
94078 #include <net/inet_common.h>
94079 #include <net/xfrm.h>
94080
94081 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94082 +extern int grsec_enable_blackhole;
94083 +#endif
94084 +
94085 int sysctl_tcp_syncookies __read_mostly = 1;
94086 EXPORT_SYMBOL(sysctl_tcp_syncookies);
94087
94088 @@ -711,7 +715,10 @@ embryonic_reset:
94089 * avoid becoming vulnerable to outside attack aiming at
94090 * resetting legit local connections.
94091 */
94092 - req->rsk_ops->send_reset(sk, skb);
94093 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94094 + if (!grsec_enable_blackhole)
94095 +#endif
94096 + req->rsk_ops->send_reset(sk, skb);
94097 } else if (fastopen) { /* received a valid RST pkt */
94098 reqsk_fastopen_remove(sk, req, true);
94099 tcp_reset(sk);
94100 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
94101 index 611beab..c4b6e1d 100644
94102 --- a/net/ipv4/tcp_probe.c
94103 +++ b/net/ipv4/tcp_probe.c
94104 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
94105 if (cnt + width >= len)
94106 break;
94107
94108 - if (copy_to_user(buf + cnt, tbuf, width))
94109 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
94110 return -EFAULT;
94111 cnt += width;
94112 }
94113 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
94114 index 4b85e6f..22f9ac9 100644
94115 --- a/net/ipv4/tcp_timer.c
94116 +++ b/net/ipv4/tcp_timer.c
94117 @@ -22,6 +22,10 @@
94118 #include <linux/gfp.h>
94119 #include <net/tcp.h>
94120
94121 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94122 +extern int grsec_lastack_retries;
94123 +#endif
94124 +
94125 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
94126 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
94127 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
94128 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
94129 }
94130 }
94131
94132 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94133 + if ((sk->sk_state == TCP_LAST_ACK) &&
94134 + (grsec_lastack_retries > 0) &&
94135 + (grsec_lastack_retries < retry_until))
94136 + retry_until = grsec_lastack_retries;
94137 +#endif
94138 +
94139 if (retransmits_timed_out(sk, retry_until,
94140 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
94141 /* Has it gone just too far? */
94142 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
94143 index 0ca44df..b5e4b11 100644
94144 --- a/net/ipv4/udp.c
94145 +++ b/net/ipv4/udp.c
94146 @@ -87,6 +87,7 @@
94147 #include <linux/types.h>
94148 #include <linux/fcntl.h>
94149 #include <linux/module.h>
94150 +#include <linux/security.h>
94151 #include <linux/socket.h>
94152 #include <linux/sockios.h>
94153 #include <linux/igmp.h>
94154 @@ -112,6 +113,10 @@
94155 #include <net/busy_poll.h>
94156 #include "udp_impl.h"
94157
94158 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94159 +extern int grsec_enable_blackhole;
94160 +#endif
94161 +
94162 struct udp_table udp_table __read_mostly;
94163 EXPORT_SYMBOL(udp_table);
94164
94165 @@ -595,6 +600,9 @@ found:
94166 return s;
94167 }
94168
94169 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
94170 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
94171 +
94172 /*
94173 * This routine is called by the ICMP module when it gets some
94174 * sort of error condition. If err < 0 then the socket should
94175 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94176 dport = usin->sin_port;
94177 if (dport == 0)
94178 return -EINVAL;
94179 +
94180 + err = gr_search_udp_sendmsg(sk, usin);
94181 + if (err)
94182 + return err;
94183 } else {
94184 if (sk->sk_state != TCP_ESTABLISHED)
94185 return -EDESTADDRREQ;
94186 +
94187 + err = gr_search_udp_sendmsg(sk, NULL);
94188 + if (err)
94189 + return err;
94190 +
94191 daddr = inet->inet_daddr;
94192 dport = inet->inet_dport;
94193 /* Open fast path for connected socket.
94194 @@ -1138,7 +1155,7 @@ static unsigned int first_packet_length(struct sock *sk)
94195 IS_UDPLITE(sk));
94196 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94197 IS_UDPLITE(sk));
94198 - atomic_inc(&sk->sk_drops);
94199 + atomic_inc_unchecked(&sk->sk_drops);
94200 __skb_unlink(skb, rcvq);
94201 __skb_queue_tail(&list_kill, skb);
94202 }
94203 @@ -1224,6 +1241,10 @@ try_again:
94204 if (!skb)
94205 goto out;
94206
94207 + err = gr_search_udp_recvmsg(sk, skb);
94208 + if (err)
94209 + goto out_free;
94210 +
94211 ulen = skb->len - sizeof(struct udphdr);
94212 copied = len;
94213 if (copied > ulen)
94214 @@ -1257,7 +1278,7 @@ try_again:
94215 if (unlikely(err)) {
94216 trace_kfree_skb(skb, udp_recvmsg);
94217 if (!peeked) {
94218 - atomic_inc(&sk->sk_drops);
94219 + atomic_inc_unchecked(&sk->sk_drops);
94220 UDP_INC_STATS_USER(sock_net(sk),
94221 UDP_MIB_INERRORS, is_udplite);
94222 }
94223 @@ -1544,7 +1565,7 @@ csum_error:
94224 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94225 drop:
94226 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94227 - atomic_inc(&sk->sk_drops);
94228 + atomic_inc_unchecked(&sk->sk_drops);
94229 kfree_skb(skb);
94230 return -1;
94231 }
94232 @@ -1563,7 +1584,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94233 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94234
94235 if (!skb1) {
94236 - atomic_inc(&sk->sk_drops);
94237 + atomic_inc_unchecked(&sk->sk_drops);
94238 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94239 IS_UDPLITE(sk));
94240 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94241 @@ -1735,6 +1756,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94242 goto csum_error;
94243
94244 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94245 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94246 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94247 +#endif
94248 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
94249
94250 /*
94251 @@ -2167,7 +2191,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
94252 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94253 0, sock_i_ino(sp),
94254 atomic_read(&sp->sk_refcnt), sp,
94255 - atomic_read(&sp->sk_drops), len);
94256 + atomic_read_unchecked(&sp->sk_drops), len);
94257 }
94258
94259 int udp4_seq_show(struct seq_file *seq, void *v)
94260 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
94261 index ccde542..eeb5ff7 100644
94262 --- a/net/ipv4/xfrm4_policy.c
94263 +++ b/net/ipv4/xfrm4_policy.c
94264 @@ -182,11 +182,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
94265 fl4->flowi4_tos = iph->tos;
94266 }
94267
94268 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
94269 +static int xfrm4_garbage_collect(struct dst_ops *ops)
94270 {
94271 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
94272
94273 - xfrm4_policy_afinfo.garbage_collect(net);
94274 + xfrm_garbage_collect_deferred(net);
94275 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
94276 }
94277
94278 @@ -265,19 +265,18 @@ static struct ctl_table xfrm4_policy_table[] = {
94279
94280 static int __net_init xfrm4_net_init(struct net *net)
94281 {
94282 - struct ctl_table *table;
94283 + ctl_table_no_const *table = NULL;
94284 struct ctl_table_header *hdr;
94285
94286 - table = xfrm4_policy_table;
94287 if (!net_eq(net, &init_net)) {
94288 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94289 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94290 if (!table)
94291 goto err_alloc;
94292
94293 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
94294 - }
94295 -
94296 - hdr = register_net_sysctl(net, "net/ipv4", table);
94297 + hdr = register_net_sysctl(net, "net/ipv4", table);
94298 + } else
94299 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
94300 if (!hdr)
94301 goto err_reg;
94302
94303 @@ -285,8 +284,7 @@ static int __net_init xfrm4_net_init(struct net *net)
94304 return 0;
94305
94306 err_reg:
94307 - if (!net_eq(net, &init_net))
94308 - kfree(table);
94309 + kfree(table);
94310 err_alloc:
94311 return -ENOMEM;
94312 }
94313 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
94314 index cd3fb30..b7dfef7 100644
94315 --- a/net/ipv6/addrconf.c
94316 +++ b/net/ipv6/addrconf.c
94317 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
94318 idx = 0;
94319 head = &net->dev_index_head[h];
94320 rcu_read_lock();
94321 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
94322 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
94323 net->dev_base_seq;
94324 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94325 if (idx < s_idx)
94326 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
94327 p.iph.ihl = 5;
94328 p.iph.protocol = IPPROTO_IPV6;
94329 p.iph.ttl = 64;
94330 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
94331 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
94332
94333 if (ops->ndo_do_ioctl) {
94334 mm_segment_t oldfs = get_fs();
94335 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
94336 s_ip_idx = ip_idx = cb->args[2];
94337
94338 rcu_read_lock();
94339 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94340 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94341 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
94342 idx = 0;
94343 head = &net->dev_index_head[h];
94344 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94345 dst_free(&ifp->rt->dst);
94346 break;
94347 }
94348 - atomic_inc(&net->ipv6.dev_addr_genid);
94349 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
94350 rt_genid_bump_ipv6(net);
94351 }
94352
94353 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
94354 int *valp = ctl->data;
94355 int val = *valp;
94356 loff_t pos = *ppos;
94357 - struct ctl_table lctl;
94358 + ctl_table_no_const lctl;
94359 int ret;
94360
94361 /*
94362 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
94363 int *valp = ctl->data;
94364 int val = *valp;
94365 loff_t pos = *ppos;
94366 - struct ctl_table lctl;
94367 + ctl_table_no_const lctl;
94368 int ret;
94369
94370 /*
94371 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
94372 index 7c96100..bfd994a 100644
94373 --- a/net/ipv6/af_inet6.c
94374 +++ b/net/ipv6/af_inet6.c
94375 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
94376
94377 net->ipv6.sysctl.bindv6only = 0;
94378 net->ipv6.sysctl.icmpv6_time = 1*HZ;
94379 - atomic_set(&net->ipv6.rt_genid, 0);
94380 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
94381
94382 err = ipv6_init_mibs(net);
94383 if (err)
94384 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
94385 index 48b6bd2..76d3458 100644
94386 --- a/net/ipv6/datagram.c
94387 +++ b/net/ipv6/datagram.c
94388 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
94389 0,
94390 sock_i_ino(sp),
94391 atomic_read(&sp->sk_refcnt), sp,
94392 - atomic_read(&sp->sk_drops));
94393 + atomic_read_unchecked(&sp->sk_drops));
94394 }
94395 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
94396 index eef8d94..cfa1852 100644
94397 --- a/net/ipv6/icmp.c
94398 +++ b/net/ipv6/icmp.c
94399 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
94400
94401 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
94402 {
94403 - struct ctl_table *table;
94404 + ctl_table_no_const *table;
94405
94406 table = kmemdup(ipv6_icmp_table_template,
94407 sizeof(ipv6_icmp_table_template),
94408 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
94409 index bf4a9a0..e5f6ac5 100644
94410 --- a/net/ipv6/ip6_gre.c
94411 +++ b/net/ipv6/ip6_gre.c
94412 @@ -74,7 +74,7 @@ struct ip6gre_net {
94413 struct net_device *fb_tunnel_dev;
94414 };
94415
94416 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
94417 +static struct rtnl_link_ops ip6gre_link_ops;
94418 static int ip6gre_tunnel_init(struct net_device *dev);
94419 static void ip6gre_tunnel_setup(struct net_device *dev);
94420 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
94421 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
94422 }
94423
94424
94425 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
94426 +static struct inet6_protocol ip6gre_protocol = {
94427 .handler = ip6gre_rcv,
94428 .err_handler = ip6gre_err,
94429 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
94430 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
94431 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
94432 };
94433
94434 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94435 +static struct rtnl_link_ops ip6gre_link_ops = {
94436 .kind = "ip6gre",
94437 .maxtype = IFLA_GRE_MAX,
94438 .policy = ip6gre_policy,
94439 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94440 .fill_info = ip6gre_fill_info,
94441 };
94442
94443 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
94444 +static struct rtnl_link_ops ip6gre_tap_ops = {
94445 .kind = "ip6gretap",
94446 .maxtype = IFLA_GRE_MAX,
94447 .policy = ip6gre_policy,
94448 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
94449 index 583b77e..99522b8 100644
94450 --- a/net/ipv6/ip6_tunnel.c
94451 +++ b/net/ipv6/ip6_tunnel.c
94452 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
94453
94454 static int ip6_tnl_dev_init(struct net_device *dev);
94455 static void ip6_tnl_dev_setup(struct net_device *dev);
94456 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
94457 +static struct rtnl_link_ops ip6_link_ops;
94458
94459 static int ip6_tnl_net_id __read_mostly;
94460 struct ip6_tnl_net {
94461 @@ -1690,7 +1690,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
94462 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
94463 };
94464
94465 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
94466 +static struct rtnl_link_ops ip6_link_ops = {
94467 .kind = "ip6tnl",
94468 .maxtype = IFLA_IPTUN_MAX,
94469 .policy = ip6_tnl_policy,
94470 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
94471 index d1e2e8e..51c19ae 100644
94472 --- a/net/ipv6/ipv6_sockglue.c
94473 +++ b/net/ipv6/ipv6_sockglue.c
94474 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
94475 if (sk->sk_type != SOCK_STREAM)
94476 return -ENOPROTOOPT;
94477
94478 - msg.msg_control = optval;
94479 + msg.msg_control = (void __force_kernel *)optval;
94480 msg.msg_controllen = len;
94481 msg.msg_flags = flags;
94482
94483 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
94484 index 44400c2..8e11f52 100644
94485 --- a/net/ipv6/netfilter/ip6_tables.c
94486 +++ b/net/ipv6/netfilter/ip6_tables.c
94487 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
94488 #endif
94489
94490 static int get_info(struct net *net, void __user *user,
94491 - const int *len, int compat)
94492 + int len, int compat)
94493 {
94494 char name[XT_TABLE_MAXNAMELEN];
94495 struct xt_table *t;
94496 int ret;
94497
94498 - if (*len != sizeof(struct ip6t_getinfo)) {
94499 - duprintf("length %u != %zu\n", *len,
94500 + if (len != sizeof(struct ip6t_getinfo)) {
94501 + duprintf("length %u != %zu\n", len,
94502 sizeof(struct ip6t_getinfo));
94503 return -EINVAL;
94504 }
94505 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
94506 info.size = private->size;
94507 strcpy(info.name, name);
94508
94509 - if (copy_to_user(user, &info, *len) != 0)
94510 + if (copy_to_user(user, &info, len) != 0)
94511 ret = -EFAULT;
94512 else
94513 ret = 0;
94514 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94515
94516 switch (cmd) {
94517 case IP6T_SO_GET_INFO:
94518 - ret = get_info(sock_net(sk), user, len, 1);
94519 + ret = get_info(sock_net(sk), user, *len, 1);
94520 break;
94521 case IP6T_SO_GET_ENTRIES:
94522 ret = compat_get_entries(sock_net(sk), user, len);
94523 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94524
94525 switch (cmd) {
94526 case IP6T_SO_GET_INFO:
94527 - ret = get_info(sock_net(sk), user, len, 0);
94528 + ret = get_info(sock_net(sk), user, *len, 0);
94529 break;
94530
94531 case IP6T_SO_GET_ENTRIES:
94532 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
94533 index dffdc1a..ccc6678 100644
94534 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
94535 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
94536 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
94537
94538 static int nf_ct_frag6_sysctl_register(struct net *net)
94539 {
94540 - struct ctl_table *table;
94541 + ctl_table_no_const *table = NULL;
94542 struct ctl_table_header *hdr;
94543
94544 - table = nf_ct_frag6_sysctl_table;
94545 if (!net_eq(net, &init_net)) {
94546 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
94547 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
94548 GFP_KERNEL);
94549 if (table == NULL)
94550 goto err_alloc;
94551 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94552 table[0].data = &net->nf_frag.frags.timeout;
94553 table[1].data = &net->nf_frag.frags.low_thresh;
94554 table[2].data = &net->nf_frag.frags.high_thresh;
94555 - }
94556 -
94557 - hdr = register_net_sysctl(net, "net/netfilter", table);
94558 + hdr = register_net_sysctl(net, "net/netfilter", table);
94559 + } else
94560 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
94561 if (hdr == NULL)
94562 goto err_reg;
94563
94564 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94565 return 0;
94566
94567 err_reg:
94568 - if (!net_eq(net, &init_net))
94569 - kfree(table);
94570 + kfree(table);
94571 err_alloc:
94572 return -ENOMEM;
94573 }
94574 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
94575 index 827f795..7e28e82 100644
94576 --- a/net/ipv6/output_core.c
94577 +++ b/net/ipv6/output_core.c
94578 @@ -9,8 +9,8 @@
94579
94580 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94581 {
94582 - static atomic_t ipv6_fragmentation_id;
94583 - int old, new;
94584 + static atomic_unchecked_t ipv6_fragmentation_id;
94585 + int id;
94586
94587 #if IS_ENABLED(CONFIG_IPV6)
94588 if (rt && !(rt->dst.flags & DST_NOPEER)) {
94589 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94590 }
94591 }
94592 #endif
94593 - do {
94594 - old = atomic_read(&ipv6_fragmentation_id);
94595 - new = old + 1;
94596 - if (!new)
94597 - new = 1;
94598 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
94599 - fhdr->identification = htonl(new);
94600 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94601 + if (!id)
94602 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94603 + fhdr->identification = htonl(id);
94604 }
94605 EXPORT_SYMBOL(ipv6_select_ident);
94606
94607 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
94608 index 18f19df..b46ada1 100644
94609 --- a/net/ipv6/ping.c
94610 +++ b/net/ipv6/ping.c
94611 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
94612 };
94613 #endif
94614
94615 +static struct pingv6_ops real_pingv6_ops = {
94616 + .ipv6_recv_error = ipv6_recv_error,
94617 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
94618 + .icmpv6_err_convert = icmpv6_err_convert,
94619 + .ipv6_icmp_error = ipv6_icmp_error,
94620 + .ipv6_chk_addr = ipv6_chk_addr,
94621 +};
94622 +
94623 +static struct pingv6_ops dummy_pingv6_ops = {
94624 + .ipv6_recv_error = dummy_ipv6_recv_error,
94625 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
94626 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
94627 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
94628 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
94629 +};
94630 +
94631 int __init pingv6_init(void)
94632 {
94633 #ifdef CONFIG_PROC_FS
94634 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
94635 if (ret)
94636 return ret;
94637 #endif
94638 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
94639 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
94640 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
94641 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
94642 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
94643 + pingv6_ops = &real_pingv6_ops;
94644 return inet6_register_protosw(&pingv6_protosw);
94645 }
94646
94647 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
94648 */
94649 void pingv6_exit(void)
94650 {
94651 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
94652 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
94653 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
94654 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
94655 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
94656 + pingv6_ops = &dummy_pingv6_ops;
94657 #ifdef CONFIG_PROC_FS
94658 unregister_pernet_subsys(&ping_v6_net_ops);
94659 #endif
94660 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
94661 index a4ed241..8bf6277 100644
94662 --- a/net/ipv6/raw.c
94663 +++ b/net/ipv6/raw.c
94664 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
94665 {
94666 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
94667 skb_checksum_complete(skb)) {
94668 - atomic_inc(&sk->sk_drops);
94669 + atomic_inc_unchecked(&sk->sk_drops);
94670 kfree_skb(skb);
94671 return NET_RX_DROP;
94672 }
94673 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94674 struct raw6_sock *rp = raw6_sk(sk);
94675
94676 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
94677 - atomic_inc(&sk->sk_drops);
94678 + atomic_inc_unchecked(&sk->sk_drops);
94679 kfree_skb(skb);
94680 return NET_RX_DROP;
94681 }
94682 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94683
94684 if (inet->hdrincl) {
94685 if (skb_checksum_complete(skb)) {
94686 - atomic_inc(&sk->sk_drops);
94687 + atomic_inc_unchecked(&sk->sk_drops);
94688 kfree_skb(skb);
94689 return NET_RX_DROP;
94690 }
94691 @@ -609,7 +609,7 @@ out:
94692 return err;
94693 }
94694
94695 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
94696 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
94697 struct flowi6 *fl6, struct dst_entry **dstp,
94698 unsigned int flags)
94699 {
94700 @@ -922,12 +922,15 @@ do_confirm:
94701 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
94702 char __user *optval, int optlen)
94703 {
94704 + struct icmp6_filter filter;
94705 +
94706 switch (optname) {
94707 case ICMPV6_FILTER:
94708 if (optlen > sizeof(struct icmp6_filter))
94709 optlen = sizeof(struct icmp6_filter);
94710 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
94711 + if (copy_from_user(&filter, optval, optlen))
94712 return -EFAULT;
94713 + raw6_sk(sk)->filter = filter;
94714 return 0;
94715 default:
94716 return -ENOPROTOOPT;
94717 @@ -940,6 +943,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94718 char __user *optval, int __user *optlen)
94719 {
94720 int len;
94721 + struct icmp6_filter filter;
94722
94723 switch (optname) {
94724 case ICMPV6_FILTER:
94725 @@ -951,7 +955,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94726 len = sizeof(struct icmp6_filter);
94727 if (put_user(len, optlen))
94728 return -EFAULT;
94729 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
94730 + filter = raw6_sk(sk)->filter;
94731 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
94732 return -EFAULT;
94733 return 0;
94734 default:
94735 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
94736 index 1aeb473..bea761c 100644
94737 --- a/net/ipv6/reassembly.c
94738 +++ b/net/ipv6/reassembly.c
94739 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
94740
94741 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94742 {
94743 - struct ctl_table *table;
94744 + ctl_table_no_const *table = NULL;
94745 struct ctl_table_header *hdr;
94746
94747 - table = ip6_frags_ns_ctl_table;
94748 if (!net_eq(net, &init_net)) {
94749 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94750 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94751 if (table == NULL)
94752 goto err_alloc;
94753
94754 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94755 /* Don't export sysctls to unprivileged users */
94756 if (net->user_ns != &init_user_ns)
94757 table[0].procname = NULL;
94758 - }
94759 + hdr = register_net_sysctl(net, "net/ipv6", table);
94760 + } else
94761 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
94762
94763 - hdr = register_net_sysctl(net, "net/ipv6", table);
94764 if (hdr == NULL)
94765 goto err_reg;
94766
94767 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94768 return 0;
94769
94770 err_reg:
94771 - if (!net_eq(net, &init_net))
94772 - kfree(table);
94773 + kfree(table);
94774 err_alloc:
94775 return -ENOMEM;
94776 }
94777 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
94778 index 04e17b3..83502e9 100644
94779 --- a/net/ipv6/route.c
94780 +++ b/net/ipv6/route.c
94781 @@ -3006,7 +3006,7 @@ struct ctl_table ipv6_route_table_template[] = {
94782
94783 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
94784 {
94785 - struct ctl_table *table;
94786 + ctl_table_no_const *table;
94787
94788 table = kmemdup(ipv6_route_table_template,
94789 sizeof(ipv6_route_table_template),
94790 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
94791 index 1926945..30a1a57 100644
94792 --- a/net/ipv6/sit.c
94793 +++ b/net/ipv6/sit.c
94794 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
94795 static void ipip6_dev_free(struct net_device *dev);
94796 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
94797 __be32 *v4dst);
94798 -static struct rtnl_link_ops sit_link_ops __read_mostly;
94799 +static struct rtnl_link_ops sit_link_ops;
94800
94801 static int sit_net_id __read_mostly;
94802 struct sit_net {
94803 @@ -1594,7 +1594,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
94804 #endif
94805 };
94806
94807 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
94808 +static struct rtnl_link_ops sit_link_ops = {
94809 .kind = "sit",
94810 .maxtype = IFLA_IPTUN_MAX,
94811 .policy = ipip6_policy,
94812 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
94813 index 107b2f1..72741a9 100644
94814 --- a/net/ipv6/sysctl_net_ipv6.c
94815 +++ b/net/ipv6/sysctl_net_ipv6.c
94816 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
94817
94818 static int __net_init ipv6_sysctl_net_init(struct net *net)
94819 {
94820 - struct ctl_table *ipv6_table;
94821 + ctl_table_no_const *ipv6_table;
94822 struct ctl_table *ipv6_route_table;
94823 struct ctl_table *ipv6_icmp_table;
94824 int err;
94825 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
94826 index 5c71501..7e8d5d3 100644
94827 --- a/net/ipv6/tcp_ipv6.c
94828 +++ b/net/ipv6/tcp_ipv6.c
94829 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
94830 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
94831 }
94832
94833 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94834 +extern int grsec_enable_blackhole;
94835 +#endif
94836 +
94837 static void tcp_v6_hash(struct sock *sk)
94838 {
94839 if (sk->sk_state != TCP_CLOSE) {
94840 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
94841 return 0;
94842
94843 reset:
94844 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94845 + if (!grsec_enable_blackhole)
94846 +#endif
94847 tcp_v6_send_reset(sk, skb);
94848 discard:
94849 if (opt_skb)
94850 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
94851 TCP_SKB_CB(skb)->sacked = 0;
94852
94853 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94854 - if (!sk)
94855 + if (!sk) {
94856 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94857 + ret = 1;
94858 +#endif
94859 goto no_tcp_socket;
94860 + }
94861
94862 process:
94863 - if (sk->sk_state == TCP_TIME_WAIT)
94864 + if (sk->sk_state == TCP_TIME_WAIT) {
94865 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94866 + ret = 2;
94867 +#endif
94868 goto do_time_wait;
94869 + }
94870
94871 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
94872 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94873 @@ -1536,6 +1551,10 @@ csum_error:
94874 bad_packet:
94875 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94876 } else {
94877 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94878 + if (!grsec_enable_blackhole || (ret == 1 &&
94879 + (skb->dev->flags & IFF_LOOPBACK)))
94880 +#endif
94881 tcp_v6_send_reset(NULL, skb);
94882 }
94883
94884 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
94885 index 1878609..b48e1d4 100644
94886 --- a/net/ipv6/udp.c
94887 +++ b/net/ipv6/udp.c
94888 @@ -53,6 +53,10 @@
94889 #include <trace/events/skb.h>
94890 #include "udp_impl.h"
94891
94892 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94893 +extern int grsec_enable_blackhole;
94894 +#endif
94895 +
94896 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
94897 {
94898 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
94899 @@ -420,7 +424,7 @@ try_again:
94900 if (unlikely(err)) {
94901 trace_kfree_skb(skb, udpv6_recvmsg);
94902 if (!peeked) {
94903 - atomic_inc(&sk->sk_drops);
94904 + atomic_inc_unchecked(&sk->sk_drops);
94905 if (is_udp4)
94906 UDP_INC_STATS_USER(sock_net(sk),
94907 UDP_MIB_INERRORS,
94908 @@ -668,7 +672,7 @@ csum_error:
94909 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94910 drop:
94911 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94912 - atomic_inc(&sk->sk_drops);
94913 + atomic_inc_unchecked(&sk->sk_drops);
94914 kfree_skb(skb);
94915 return -1;
94916 }
94917 @@ -726,7 +730,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94918 if (likely(skb1 == NULL))
94919 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94920 if (!skb1) {
94921 - atomic_inc(&sk->sk_drops);
94922 + atomic_inc_unchecked(&sk->sk_drops);
94923 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94924 IS_UDPLITE(sk));
94925 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94926 @@ -866,6 +870,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94927 goto csum_error;
94928
94929 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94930 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94931 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94932 +#endif
94933 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
94934
94935 kfree_skb(skb);
94936 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
94937 index 08ed277..80e4bc8 100644
94938 --- a/net/ipv6/xfrm6_policy.c
94939 +++ b/net/ipv6/xfrm6_policy.c
94940 @@ -208,11 +208,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
94941 }
94942 }
94943
94944 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
94945 +static int xfrm6_garbage_collect(struct dst_ops *ops)
94946 {
94947 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94948
94949 - xfrm6_policy_afinfo.garbage_collect(net);
94950 + xfrm_garbage_collect_deferred(net);
94951 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94952 }
94953
94954 @@ -325,19 +325,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94955
94956 static int __net_init xfrm6_net_init(struct net *net)
94957 {
94958 - struct ctl_table *table;
94959 + ctl_table_no_const *table = NULL;
94960 struct ctl_table_header *hdr;
94961
94962 - table = xfrm6_policy_table;
94963 if (!net_eq(net, &init_net)) {
94964 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94965 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94966 if (!table)
94967 goto err_alloc;
94968
94969 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94970 - }
94971 + hdr = register_net_sysctl(net, "net/ipv6", table);
94972 + } else
94973 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94974
94975 - hdr = register_net_sysctl(net, "net/ipv6", table);
94976 if (!hdr)
94977 goto err_reg;
94978
94979 @@ -345,8 +345,7 @@ static int __net_init xfrm6_net_init(struct net *net)
94980 return 0;
94981
94982 err_reg:
94983 - if (!net_eq(net, &init_net))
94984 - kfree(table);
94985 + kfree(table);
94986 err_alloc:
94987 return -ENOMEM;
94988 }
94989 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
94990 index 41ac7938..75e3bb1 100644
94991 --- a/net/irda/ircomm/ircomm_tty.c
94992 +++ b/net/irda/ircomm/ircomm_tty.c
94993 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94994 add_wait_queue(&port->open_wait, &wait);
94995
94996 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
94997 - __FILE__, __LINE__, tty->driver->name, port->count);
94998 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94999
95000 spin_lock_irqsave(&port->lock, flags);
95001 if (!tty_hung_up_p(filp))
95002 - port->count--;
95003 + atomic_dec(&port->count);
95004 port->blocked_open++;
95005 spin_unlock_irqrestore(&port->lock, flags);
95006
95007 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95008 }
95009
95010 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
95011 - __FILE__, __LINE__, tty->driver->name, port->count);
95012 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95013
95014 schedule();
95015 }
95016 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95017
95018 spin_lock_irqsave(&port->lock, flags);
95019 if (!tty_hung_up_p(filp))
95020 - port->count++;
95021 + atomic_inc(&port->count);
95022 port->blocked_open--;
95023 spin_unlock_irqrestore(&port->lock, flags);
95024
95025 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
95026 - __FILE__, __LINE__, tty->driver->name, port->count);
95027 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95028
95029 if (!retval)
95030 port->flags |= ASYNC_NORMAL_ACTIVE;
95031 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
95032
95033 /* ++ is not atomic, so this should be protected - Jean II */
95034 spin_lock_irqsave(&self->port.lock, flags);
95035 - self->port.count++;
95036 + atomic_inc(&self->port.count);
95037 spin_unlock_irqrestore(&self->port.lock, flags);
95038 tty_port_tty_set(&self->port, tty);
95039
95040 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
95041 - self->line, self->port.count);
95042 + self->line, atomic_read(&self->port.count));
95043
95044 /* Not really used by us, but lets do it anyway */
95045 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
95046 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
95047 tty_kref_put(port->tty);
95048 }
95049 port->tty = NULL;
95050 - port->count = 0;
95051 + atomic_set(&port->count, 0);
95052 spin_unlock_irqrestore(&port->lock, flags);
95053
95054 wake_up_interruptible(&port->open_wait);
95055 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
95056 seq_putc(m, '\n');
95057
95058 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
95059 - seq_printf(m, "Open count: %d\n", self->port.count);
95060 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
95061 seq_printf(m, "Max data size: %d\n", self->max_data_size);
95062 seq_printf(m, "Max header size: %d\n", self->max_header_size);
95063
95064 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
95065 index 168aff5..9d43132 100644
95066 --- a/net/iucv/af_iucv.c
95067 +++ b/net/iucv/af_iucv.c
95068 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
95069
95070 write_lock_bh(&iucv_sk_list.lock);
95071
95072 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
95073 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95074 while (__iucv_get_sock_by_name(name)) {
95075 sprintf(name, "%08x",
95076 - atomic_inc_return(&iucv_sk_list.autobind_name));
95077 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95078 }
95079
95080 write_unlock_bh(&iucv_sk_list.lock);
95081 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
95082 index cd5b8ec..f205e6b 100644
95083 --- a/net/iucv/iucv.c
95084 +++ b/net/iucv/iucv.c
95085 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
95086 return NOTIFY_OK;
95087 }
95088
95089 -static struct notifier_block __refdata iucv_cpu_notifier = {
95090 +static struct notifier_block iucv_cpu_notifier = {
95091 .notifier_call = iucv_cpu_notify,
95092 };
95093
95094 diff --git a/net/key/af_key.c b/net/key/af_key.c
95095 index 911ef03..58f9c96 100644
95096 --- a/net/key/af_key.c
95097 +++ b/net/key/af_key.c
95098 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
95099 static u32 get_acqseq(void)
95100 {
95101 u32 res;
95102 - static atomic_t acqseq;
95103 + static atomic_unchecked_t acqseq;
95104
95105 do {
95106 - res = atomic_inc_return(&acqseq);
95107 + res = atomic_inc_return_unchecked(&acqseq);
95108 } while (!res);
95109 return res;
95110 }
95111 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
95112 index 629dee7..4bdd2c8 100644
95113 --- a/net/mac80211/cfg.c
95114 +++ b/net/mac80211/cfg.c
95115 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
95116 ret = ieee80211_vif_use_channel(sdata, chandef,
95117 IEEE80211_CHANCTX_EXCLUSIVE);
95118 }
95119 - } else if (local->open_count == local->monitors) {
95120 + } else if (local_read(&local->open_count) == local->monitors) {
95121 local->_oper_chandef = *chandef;
95122 ieee80211_hw_config(local, 0);
95123 }
95124 @@ -3125,7 +3125,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
95125 else
95126 local->probe_req_reg--;
95127
95128 - if (!local->open_count)
95129 + if (!local_read(&local->open_count))
95130 break;
95131
95132 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
95133 @@ -3588,8 +3588,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
95134 if (chanctx_conf) {
95135 *chandef = chanctx_conf->def;
95136 ret = 0;
95137 - } else if (local->open_count > 0 &&
95138 - local->open_count == local->monitors &&
95139 + } else if (local_read(&local->open_count) > 0 &&
95140 + local_read(&local->open_count) == local->monitors &&
95141 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
95142 if (local->use_chanctx)
95143 *chandef = local->monitor_chandef;
95144 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
95145 index 611abfc..8c2c7e4 100644
95146 --- a/net/mac80211/ieee80211_i.h
95147 +++ b/net/mac80211/ieee80211_i.h
95148 @@ -28,6 +28,7 @@
95149 #include <net/ieee80211_radiotap.h>
95150 #include <net/cfg80211.h>
95151 #include <net/mac80211.h>
95152 +#include <asm/local.h>
95153 #include "key.h"
95154 #include "sta_info.h"
95155 #include "debug.h"
95156 @@ -945,7 +946,7 @@ struct ieee80211_local {
95157 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
95158 spinlock_t queue_stop_reason_lock;
95159
95160 - int open_count;
95161 + local_t open_count;
95162 int monitors, cooked_mntrs;
95163 /* number of interfaces with corresponding FIF_ flags */
95164 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
95165 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
95166 index fcecd63..a404454 100644
95167 --- a/net/mac80211/iface.c
95168 +++ b/net/mac80211/iface.c
95169 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95170 break;
95171 }
95172
95173 - if (local->open_count == 0) {
95174 + if (local_read(&local->open_count) == 0) {
95175 res = drv_start(local);
95176 if (res)
95177 goto err_del_bss;
95178 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95179 res = drv_add_interface(local, sdata);
95180 if (res)
95181 goto err_stop;
95182 - } else if (local->monitors == 0 && local->open_count == 0) {
95183 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
95184 res = ieee80211_add_virtual_monitor(local);
95185 if (res)
95186 goto err_stop;
95187 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95188 atomic_inc(&local->iff_promiscs);
95189
95190 if (coming_up)
95191 - local->open_count++;
95192 + local_inc(&local->open_count);
95193
95194 if (hw_reconf_flags)
95195 ieee80211_hw_config(local, hw_reconf_flags);
95196 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95197 err_del_interface:
95198 drv_remove_interface(local, sdata);
95199 err_stop:
95200 - if (!local->open_count)
95201 + if (!local_read(&local->open_count))
95202 drv_stop(local);
95203 err_del_bss:
95204 sdata->bss = NULL;
95205 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95206 }
95207
95208 if (going_down)
95209 - local->open_count--;
95210 + local_dec(&local->open_count);
95211
95212 switch (sdata->vif.type) {
95213 case NL80211_IFTYPE_AP_VLAN:
95214 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95215 }
95216 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
95217
95218 - if (local->open_count == 0)
95219 + if (local_read(&local->open_count) == 0)
95220 ieee80211_clear_tx_pending(local);
95221
95222 /*
95223 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95224
95225 ieee80211_recalc_ps(local, -1);
95226
95227 - if (local->open_count == 0) {
95228 + if (local_read(&local->open_count) == 0) {
95229 ieee80211_stop_device(local);
95230
95231 /* no reconfiguring after stop! */
95232 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95233 ieee80211_configure_filter(local);
95234 ieee80211_hw_config(local, hw_reconf_flags);
95235
95236 - if (local->monitors == local->open_count)
95237 + if (local->monitors == local_read(&local->open_count))
95238 ieee80211_add_virtual_monitor(local);
95239 }
95240
95241 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
95242 index 21d5d44..4fee18a 100644
95243 --- a/net/mac80211/main.c
95244 +++ b/net/mac80211/main.c
95245 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
95246 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
95247 IEEE80211_CONF_CHANGE_POWER);
95248
95249 - if (changed && local->open_count) {
95250 + if (changed && local_read(&local->open_count)) {
95251 ret = drv_config(local, changed);
95252 /*
95253 * Goal:
95254 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
95255 index 3401262..d5cd68d 100644
95256 --- a/net/mac80211/pm.c
95257 +++ b/net/mac80211/pm.c
95258 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95259 struct ieee80211_sub_if_data *sdata;
95260 struct sta_info *sta;
95261
95262 - if (!local->open_count)
95263 + if (!local_read(&local->open_count))
95264 goto suspend;
95265
95266 ieee80211_scan_cancel(local);
95267 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95268 cancel_work_sync(&local->dynamic_ps_enable_work);
95269 del_timer_sync(&local->dynamic_ps_timer);
95270
95271 - local->wowlan = wowlan && local->open_count;
95272 + local->wowlan = wowlan && local_read(&local->open_count);
95273 if (local->wowlan) {
95274 int err = drv_suspend(local, wowlan);
95275 if (err < 0) {
95276 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95277 WARN_ON(!list_empty(&local->chanctx_list));
95278
95279 /* stop hardware - this must stop RX */
95280 - if (local->open_count)
95281 + if (local_read(&local->open_count))
95282 ieee80211_stop_device(local);
95283
95284 suspend:
95285 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
95286 index e126605..73d2c39 100644
95287 --- a/net/mac80211/rate.c
95288 +++ b/net/mac80211/rate.c
95289 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
95290
95291 ASSERT_RTNL();
95292
95293 - if (local->open_count)
95294 + if (local_read(&local->open_count))
95295 return -EBUSY;
95296
95297 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
95298 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
95299 index c97a065..ff61928 100644
95300 --- a/net/mac80211/rc80211_pid_debugfs.c
95301 +++ b/net/mac80211/rc80211_pid_debugfs.c
95302 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
95303
95304 spin_unlock_irqrestore(&events->lock, status);
95305
95306 - if (copy_to_user(buf, pb, p))
95307 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
95308 return -EFAULT;
95309
95310 return p;
95311 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
95312 index 69e4ef5..e8e4b92 100644
95313 --- a/net/mac80211/util.c
95314 +++ b/net/mac80211/util.c
95315 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95316 }
95317 #endif
95318 /* everything else happens only if HW was up & running */
95319 - if (!local->open_count)
95320 + if (!local_read(&local->open_count))
95321 goto wake_up;
95322
95323 /*
95324 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95325 local->in_reconfig = false;
95326 barrier();
95327
95328 - if (local->monitors == local->open_count && local->monitors > 0)
95329 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
95330 ieee80211_add_virtual_monitor(local);
95331
95332 /*
95333 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
95334 index 6e839b6..002a233 100644
95335 --- a/net/netfilter/Kconfig
95336 +++ b/net/netfilter/Kconfig
95337 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
95338
95339 To compile it as a module, choose M here. If unsure, say N.
95340
95341 +config NETFILTER_XT_MATCH_GRADM
95342 + tristate '"gradm" match support'
95343 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
95344 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
95345 + ---help---
95346 + The gradm match allows to match on grsecurity RBAC being enabled.
95347 + It is useful when iptables rules are applied early on bootup to
95348 + prevent connections to the machine (except from a trusted host)
95349 + while the RBAC system is disabled.
95350 +
95351 config NETFILTER_XT_MATCH_HASHLIMIT
95352 tristate '"hashlimit" match support'
95353 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
95354 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
95355 index c3a0a12..90b587f 100644
95356 --- a/net/netfilter/Makefile
95357 +++ b/net/netfilter/Makefile
95358 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
95359 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
95360 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
95361 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
95362 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
95363 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
95364 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
95365 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
95366 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
95367 index f2e30fb..f131862 100644
95368 --- a/net/netfilter/ipset/ip_set_core.c
95369 +++ b/net/netfilter/ipset/ip_set_core.c
95370 @@ -1819,7 +1819,7 @@ done:
95371 return ret;
95372 }
95373
95374 -static struct nf_sockopt_ops so_set __read_mostly = {
95375 +static struct nf_sockopt_ops so_set = {
95376 .pf = PF_INET,
95377 .get_optmin = SO_IP_SET,
95378 .get_optmax = SO_IP_SET + 1,
95379 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
95380 index 4c8e5c0..5a79b4d 100644
95381 --- a/net/netfilter/ipvs/ip_vs_conn.c
95382 +++ b/net/netfilter/ipvs/ip_vs_conn.c
95383 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
95384 /* Increase the refcnt counter of the dest */
95385 ip_vs_dest_hold(dest);
95386
95387 - conn_flags = atomic_read(&dest->conn_flags);
95388 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
95389 if (cp->protocol != IPPROTO_UDP)
95390 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
95391 flags = cp->flags;
95392 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
95393
95394 cp->control = NULL;
95395 atomic_set(&cp->n_control, 0);
95396 - atomic_set(&cp->in_pkts, 0);
95397 + atomic_set_unchecked(&cp->in_pkts, 0);
95398
95399 cp->packet_xmit = NULL;
95400 cp->app = NULL;
95401 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
95402
95403 /* Don't drop the entry if its number of incoming packets is not
95404 located in [0, 8] */
95405 - i = atomic_read(&cp->in_pkts);
95406 + i = atomic_read_unchecked(&cp->in_pkts);
95407 if (i > 8 || i < 0) return 0;
95408
95409 if (!todrop_rate[i]) return 0;
95410 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
95411 index 74fd00c..06e7ac7 100644
95412 --- a/net/netfilter/ipvs/ip_vs_core.c
95413 +++ b/net/netfilter/ipvs/ip_vs_core.c
95414 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
95415 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
95416 /* do not touch skb anymore */
95417
95418 - atomic_inc(&cp->in_pkts);
95419 + atomic_inc_unchecked(&cp->in_pkts);
95420 ip_vs_conn_put(cp);
95421 return ret;
95422 }
95423 @@ -1719,7 +1719,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
95424 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
95425 pkts = sysctl_sync_threshold(ipvs);
95426 else
95427 - pkts = atomic_add_return(1, &cp->in_pkts);
95428 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95429
95430 if (ipvs->sync_state & IP_VS_STATE_MASTER)
95431 ip_vs_sync_conn(net, cp, pkts);
95432 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
95433 index a3df9bd..895ae09 100644
95434 --- a/net/netfilter/ipvs/ip_vs_ctl.c
95435 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
95436 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
95437 */
95438 ip_vs_rs_hash(ipvs, dest);
95439 }
95440 - atomic_set(&dest->conn_flags, conn_flags);
95441 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
95442
95443 /* bind the service */
95444 old_svc = rcu_dereference_protected(dest->svc, 1);
95445 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
95446 * align with netns init in ip_vs_control_net_init()
95447 */
95448
95449 -static struct ctl_table vs_vars[] = {
95450 +static ctl_table_no_const vs_vars[] __read_only = {
95451 {
95452 .procname = "amemthresh",
95453 .maxlen = sizeof(int),
95454 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95455 " %-7s %-6d %-10d %-10d\n",
95456 &dest->addr.in6,
95457 ntohs(dest->port),
95458 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95459 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95460 atomic_read(&dest->weight),
95461 atomic_read(&dest->activeconns),
95462 atomic_read(&dest->inactconns));
95463 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95464 "%-7s %-6d %-10d %-10d\n",
95465 ntohl(dest->addr.ip),
95466 ntohs(dest->port),
95467 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95468 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95469 atomic_read(&dest->weight),
95470 atomic_read(&dest->activeconns),
95471 atomic_read(&dest->inactconns));
95472 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
95473
95474 entry.addr = dest->addr.ip;
95475 entry.port = dest->port;
95476 - entry.conn_flags = atomic_read(&dest->conn_flags);
95477 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
95478 entry.weight = atomic_read(&dest->weight);
95479 entry.u_threshold = dest->u_threshold;
95480 entry.l_threshold = dest->l_threshold;
95481 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
95482 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
95483 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
95484 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
95485 - (atomic_read(&dest->conn_flags) &
95486 + (atomic_read_unchecked(&dest->conn_flags) &
95487 IP_VS_CONN_F_FWD_MASK)) ||
95488 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
95489 atomic_read(&dest->weight)) ||
95490 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
95491 {
95492 int idx;
95493 struct netns_ipvs *ipvs = net_ipvs(net);
95494 - struct ctl_table *tbl;
95495 + ctl_table_no_const *tbl;
95496
95497 atomic_set(&ipvs->dropentry, 0);
95498 spin_lock_init(&ipvs->dropentry_lock);
95499 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
95500 index eff13c9..c1aab3e 100644
95501 --- a/net/netfilter/ipvs/ip_vs_lblc.c
95502 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
95503 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
95504 * IPVS LBLC sysctl table
95505 */
95506 #ifdef CONFIG_SYSCTL
95507 -static struct ctl_table vs_vars_table[] = {
95508 +static ctl_table_no_const vs_vars_table[] __read_only = {
95509 {
95510 .procname = "lblc_expiration",
95511 .data = NULL,
95512 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
95513 index 0b85500..8513fa5 100644
95514 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
95515 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
95516 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
95517 * IPVS LBLCR sysctl table
95518 */
95519
95520 -static struct ctl_table vs_vars_table[] = {
95521 +static ctl_table_no_const vs_vars_table[] __read_only = {
95522 {
95523 .procname = "lblcr_expiration",
95524 .data = NULL,
95525 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
95526 index f448471..995f131 100644
95527 --- a/net/netfilter/ipvs/ip_vs_sync.c
95528 +++ b/net/netfilter/ipvs/ip_vs_sync.c
95529 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
95530 cp = cp->control;
95531 if (cp) {
95532 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95533 - pkts = atomic_add_return(1, &cp->in_pkts);
95534 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95535 else
95536 pkts = sysctl_sync_threshold(ipvs);
95537 ip_vs_sync_conn(net, cp->control, pkts);
95538 @@ -771,7 +771,7 @@ control:
95539 if (!cp)
95540 return;
95541 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95542 - pkts = atomic_add_return(1, &cp->in_pkts);
95543 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95544 else
95545 pkts = sysctl_sync_threshold(ipvs);
95546 goto sloop;
95547 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
95548
95549 if (opt)
95550 memcpy(&cp->in_seq, opt, sizeof(*opt));
95551 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95552 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95553 cp->state = state;
95554 cp->old_state = cp->state;
95555 /*
95556 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
95557 index c47444e..b0961c6 100644
95558 --- a/net/netfilter/ipvs/ip_vs_xmit.c
95559 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
95560 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
95561 else
95562 rc = NF_ACCEPT;
95563 /* do not touch skb anymore */
95564 - atomic_inc(&cp->in_pkts);
95565 + atomic_inc_unchecked(&cp->in_pkts);
95566 goto out;
95567 }
95568
95569 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
95570 else
95571 rc = NF_ACCEPT;
95572 /* do not touch skb anymore */
95573 - atomic_inc(&cp->in_pkts);
95574 + atomic_inc_unchecked(&cp->in_pkts);
95575 goto out;
95576 }
95577
95578 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
95579 index 2d3030a..7ba1c0a 100644
95580 --- a/net/netfilter/nf_conntrack_acct.c
95581 +++ b/net/netfilter/nf_conntrack_acct.c
95582 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
95583 #ifdef CONFIG_SYSCTL
95584 static int nf_conntrack_acct_init_sysctl(struct net *net)
95585 {
95586 - struct ctl_table *table;
95587 + ctl_table_no_const *table;
95588
95589 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
95590 GFP_KERNEL);
95591 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
95592 index 5d892fe..d2fc9d8 100644
95593 --- a/net/netfilter/nf_conntrack_core.c
95594 +++ b/net/netfilter/nf_conntrack_core.c
95595 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
95596 #define DYING_NULLS_VAL ((1<<30)+1)
95597 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
95598
95599 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95600 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
95601 +#endif
95602 +
95603 int nf_conntrack_init_net(struct net *net)
95604 {
95605 int ret;
95606 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
95607 goto err_stat;
95608 }
95609
95610 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95611 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
95612 +#else
95613 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
95614 +#endif
95615 if (!net->ct.slabname) {
95616 ret = -ENOMEM;
95617 goto err_slabname;
95618 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
95619 index 1df1761..ce8b88a 100644
95620 --- a/net/netfilter/nf_conntrack_ecache.c
95621 +++ b/net/netfilter/nf_conntrack_ecache.c
95622 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
95623 #ifdef CONFIG_SYSCTL
95624 static int nf_conntrack_event_init_sysctl(struct net *net)
95625 {
95626 - struct ctl_table *table;
95627 + ctl_table_no_const *table;
95628
95629 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
95630 GFP_KERNEL);
95631 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
95632 index 974a2a4..52cc6ff 100644
95633 --- a/net/netfilter/nf_conntrack_helper.c
95634 +++ b/net/netfilter/nf_conntrack_helper.c
95635 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
95636
95637 static int nf_conntrack_helper_init_sysctl(struct net *net)
95638 {
95639 - struct ctl_table *table;
95640 + ctl_table_no_const *table;
95641
95642 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
95643 GFP_KERNEL);
95644 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
95645 index ce30041..3861b5d 100644
95646 --- a/net/netfilter/nf_conntrack_proto.c
95647 +++ b/net/netfilter/nf_conntrack_proto.c
95648 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
95649
95650 static void
95651 nf_ct_unregister_sysctl(struct ctl_table_header **header,
95652 - struct ctl_table **table,
95653 + ctl_table_no_const **table,
95654 unsigned int users)
95655 {
95656 if (users > 0)
95657 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
95658 index a99b6c3..cb372f9 100644
95659 --- a/net/netfilter/nf_conntrack_proto_dccp.c
95660 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
95661 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95662 const char *msg;
95663 u_int8_t state;
95664
95665 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95666 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95667 BUG_ON(dh == NULL);
95668
95669 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
95670 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95671 out_invalid:
95672 if (LOG_INVALID(net, IPPROTO_DCCP))
95673 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
95674 - NULL, msg);
95675 + NULL, "%s", msg);
95676 return false;
95677 }
95678
95679 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
95680 u_int8_t type, old_state, new_state;
95681 enum ct_dccp_roles role;
95682
95683 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95684 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95685 BUG_ON(dh == NULL);
95686 type = dh->dccph_type;
95687
95688 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95689 unsigned int cscov;
95690 const char *msg;
95691
95692 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95693 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95694 if (dh == NULL) {
95695 msg = "nf_ct_dccp: short packet ";
95696 goto out_invalid;
95697 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95698
95699 out_invalid:
95700 if (LOG_INVALID(net, IPPROTO_DCCP))
95701 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
95702 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
95703 return -NF_ACCEPT;
95704 }
95705
95706 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
95707 index f641751..d3c5b51 100644
95708 --- a/net/netfilter/nf_conntrack_standalone.c
95709 +++ b/net/netfilter/nf_conntrack_standalone.c
95710 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
95711
95712 static int nf_conntrack_standalone_init_sysctl(struct net *net)
95713 {
95714 - struct ctl_table *table;
95715 + ctl_table_no_const *table;
95716
95717 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
95718 GFP_KERNEL);
95719 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
95720 index 902fb0a..87f7fdb 100644
95721 --- a/net/netfilter/nf_conntrack_timestamp.c
95722 +++ b/net/netfilter/nf_conntrack_timestamp.c
95723 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
95724 #ifdef CONFIG_SYSCTL
95725 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
95726 {
95727 - struct ctl_table *table;
95728 + ctl_table_no_const *table;
95729
95730 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
95731 GFP_KERNEL);
95732 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
95733 index 85296d4..8becdec 100644
95734 --- a/net/netfilter/nf_log.c
95735 +++ b/net/netfilter/nf_log.c
95736 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
95737
95738 #ifdef CONFIG_SYSCTL
95739 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
95740 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
95741 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
95742
95743 static int nf_log_proc_dostring(struct ctl_table *table, int write,
95744 void __user *buffer, size_t *lenp, loff_t *ppos)
95745 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
95746 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
95747 mutex_unlock(&nf_log_mutex);
95748 } else {
95749 + ctl_table_no_const nf_log_table = *table;
95750 +
95751 mutex_lock(&nf_log_mutex);
95752 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
95753 lockdep_is_held(&nf_log_mutex));
95754 if (!logger)
95755 - table->data = "NONE";
95756 + nf_log_table.data = "NONE";
95757 else
95758 - table->data = logger->name;
95759 - r = proc_dostring(table, write, buffer, lenp, ppos);
95760 + nf_log_table.data = logger->name;
95761 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
95762 mutex_unlock(&nf_log_mutex);
95763 }
95764
95765 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
95766 index f042ae5..30ea486 100644
95767 --- a/net/netfilter/nf_sockopt.c
95768 +++ b/net/netfilter/nf_sockopt.c
95769 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
95770 }
95771 }
95772
95773 - list_add(&reg->list, &nf_sockopts);
95774 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
95775 out:
95776 mutex_unlock(&nf_sockopt_mutex);
95777 return ret;
95778 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
95779 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
95780 {
95781 mutex_lock(&nf_sockopt_mutex);
95782 - list_del(&reg->list);
95783 + pax_list_del((struct list_head *)&reg->list);
95784 mutex_unlock(&nf_sockopt_mutex);
95785 }
95786 EXPORT_SYMBOL(nf_unregister_sockopt);
95787 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
95788 index d92cc31..e46f350 100644
95789 --- a/net/netfilter/nfnetlink_log.c
95790 +++ b/net/netfilter/nfnetlink_log.c
95791 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
95792 struct nfnl_log_net {
95793 spinlock_t instances_lock;
95794 struct hlist_head instance_table[INSTANCE_BUCKETS];
95795 - atomic_t global_seq;
95796 + atomic_unchecked_t global_seq;
95797 };
95798
95799 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
95800 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
95801 /* global sequence number */
95802 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
95803 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
95804 - htonl(atomic_inc_return(&log->global_seq))))
95805 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
95806 goto nla_put_failure;
95807
95808 if (data_len) {
95809 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
95810 new file mode 100644
95811 index 0000000..c566332
95812 --- /dev/null
95813 +++ b/net/netfilter/xt_gradm.c
95814 @@ -0,0 +1,51 @@
95815 +/*
95816 + * gradm match for netfilter
95817 + * Copyright © Zbigniew Krzystolik, 2010
95818 + *
95819 + * This program is free software; you can redistribute it and/or modify
95820 + * it under the terms of the GNU General Public License; either version
95821 + * 2 or 3 as published by the Free Software Foundation.
95822 + */
95823 +#include <linux/module.h>
95824 +#include <linux/moduleparam.h>
95825 +#include <linux/skbuff.h>
95826 +#include <linux/netfilter/x_tables.h>
95827 +#include <linux/grsecurity.h>
95828 +#include <linux/netfilter/xt_gradm.h>
95829 +
95830 +static bool
95831 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
95832 +{
95833 + const struct xt_gradm_mtinfo *info = par->matchinfo;
95834 + bool retval = false;
95835 + if (gr_acl_is_enabled())
95836 + retval = true;
95837 + return retval ^ info->invflags;
95838 +}
95839 +
95840 +static struct xt_match gradm_mt_reg __read_mostly = {
95841 + .name = "gradm",
95842 + .revision = 0,
95843 + .family = NFPROTO_UNSPEC,
95844 + .match = gradm_mt,
95845 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
95846 + .me = THIS_MODULE,
95847 +};
95848 +
95849 +static int __init gradm_mt_init(void)
95850 +{
95851 + return xt_register_match(&gradm_mt_reg);
95852 +}
95853 +
95854 +static void __exit gradm_mt_exit(void)
95855 +{
95856 + xt_unregister_match(&gradm_mt_reg);
95857 +}
95858 +
95859 +module_init(gradm_mt_init);
95860 +module_exit(gradm_mt_exit);
95861 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
95862 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
95863 +MODULE_LICENSE("GPL");
95864 +MODULE_ALIAS("ipt_gradm");
95865 +MODULE_ALIAS("ip6t_gradm");
95866 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
95867 index 4fe4fb4..87a89e5 100644
95868 --- a/net/netfilter/xt_statistic.c
95869 +++ b/net/netfilter/xt_statistic.c
95870 @@ -19,7 +19,7 @@
95871 #include <linux/module.h>
95872
95873 struct xt_statistic_priv {
95874 - atomic_t count;
95875 + atomic_unchecked_t count;
95876 } ____cacheline_aligned_in_smp;
95877
95878 MODULE_LICENSE("GPL");
95879 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
95880 break;
95881 case XT_STATISTIC_MODE_NTH:
95882 do {
95883 - oval = atomic_read(&info->master->count);
95884 + oval = atomic_read_unchecked(&info->master->count);
95885 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
95886 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
95887 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
95888 if (nval == 0)
95889 ret = !ret;
95890 break;
95891 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
95892 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
95893 if (info->master == NULL)
95894 return -ENOMEM;
95895 - atomic_set(&info->master->count, info->u.nth.count);
95896 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
95897
95898 return 0;
95899 }
95900 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
95901 index 8df7f64..c5d6821 100644
95902 --- a/net/netlink/af_netlink.c
95903 +++ b/net/netlink/af_netlink.c
95904 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
95905 sk->sk_error_report(sk);
95906 }
95907 }
95908 - atomic_inc(&sk->sk_drops);
95909 + atomic_inc_unchecked(&sk->sk_drops);
95910 }
95911
95912 static void netlink_rcv_wake(struct sock *sk)
95913 @@ -2942,7 +2942,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
95914 sk_wmem_alloc_get(s),
95915 nlk->cb_running,
95916 atomic_read(&s->sk_refcnt),
95917 - atomic_read(&s->sk_drops),
95918 + atomic_read_unchecked(&s->sk_drops),
95919 sock_i_ino(s)
95920 );
95921
95922 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
95923 index 0c741ce..f8c8ca7 100644
95924 --- a/net/netlink/genetlink.c
95925 +++ b/net/netlink/genetlink.c
95926 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95927 goto errout;
95928 }
95929
95930 + pax_open_kernel();
95931 if (ops->dumpit)
95932 - ops->flags |= GENL_CMD_CAP_DUMP;
95933 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95934 if (ops->doit)
95935 - ops->flags |= GENL_CMD_CAP_DO;
95936 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95937 if (ops->policy)
95938 - ops->flags |= GENL_CMD_CAP_HASPOL;
95939 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95940 + pax_close_kernel();
95941
95942 genl_lock_all();
95943 - list_add_tail(&ops->ops_list, &family->ops_list);
95944 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95945 genl_unlock_all();
95946
95947 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95948 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95949 err = 0;
95950 errout:
95951 return err;
95952 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95953 genl_lock_all();
95954 list_for_each_entry(rc, &family->ops_list, ops_list) {
95955 if (rc == ops) {
95956 - list_del(&ops->ops_list);
95957 + pax_list_del((struct list_head *)&ops->ops_list);
95958 genl_unlock_all();
95959 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95960 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95961 return 0;
95962 }
95963 }
95964 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95965 index 698814b..7cfde4e 100644
95966 --- a/net/netrom/af_netrom.c
95967 +++ b/net/netrom/af_netrom.c
95968 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95969 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95970 } else {
95971 sax->fsa_ax25.sax25_family = AF_NETROM;
95972 - sax->fsa_ax25.sax25_ndigis = 0;
95973 sax->fsa_ax25.sax25_call = nr->source_addr;
95974 *uaddr_len = sizeof(struct sockaddr_ax25);
95975 }
95976 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
95977 index 2e8286b..b2659ee 100644
95978 --- a/net/packet/af_packet.c
95979 +++ b/net/packet/af_packet.c
95980 @@ -1692,7 +1692,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95981
95982 spin_lock(&sk->sk_receive_queue.lock);
95983 po->stats.stats1.tp_packets++;
95984 - skb->dropcount = atomic_read(&sk->sk_drops);
95985 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
95986 __skb_queue_tail(&sk->sk_receive_queue, skb);
95987 spin_unlock(&sk->sk_receive_queue.lock);
95988 sk->sk_data_ready(sk, skb->len);
95989 @@ -1701,7 +1701,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95990 drop_n_acct:
95991 spin_lock(&sk->sk_receive_queue.lock);
95992 po->stats.stats1.tp_drops++;
95993 - atomic_inc(&sk->sk_drops);
95994 + atomic_inc_unchecked(&sk->sk_drops);
95995 spin_unlock(&sk->sk_receive_queue.lock);
95996
95997 drop_n_restore:
95998 @@ -3250,7 +3250,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95999 case PACKET_HDRLEN:
96000 if (len > sizeof(int))
96001 len = sizeof(int);
96002 - if (copy_from_user(&val, optval, len))
96003 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
96004 return -EFAULT;
96005 switch (val) {
96006 case TPACKET_V1:
96007 @@ -3293,7 +3293,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96008 len = lv;
96009 if (put_user(len, optlen))
96010 return -EFAULT;
96011 - if (copy_to_user(optval, data, len))
96012 + if (len > sizeof(st) || copy_to_user(optval, data, len))
96013 return -EFAULT;
96014 return 0;
96015 }
96016 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
96017 index e774117..900b8b7 100644
96018 --- a/net/phonet/pep.c
96019 +++ b/net/phonet/pep.c
96020 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96021
96022 case PNS_PEP_CTRL_REQ:
96023 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
96024 - atomic_inc(&sk->sk_drops);
96025 + atomic_inc_unchecked(&sk->sk_drops);
96026 break;
96027 }
96028 __skb_pull(skb, 4);
96029 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96030 }
96031
96032 if (pn->rx_credits == 0) {
96033 - atomic_inc(&sk->sk_drops);
96034 + atomic_inc_unchecked(&sk->sk_drops);
96035 err = -ENOBUFS;
96036 break;
96037 }
96038 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
96039 }
96040
96041 if (pn->rx_credits == 0) {
96042 - atomic_inc(&sk->sk_drops);
96043 + atomic_inc_unchecked(&sk->sk_drops);
96044 err = NET_RX_DROP;
96045 break;
96046 }
96047 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
96048 index 77e38f7..f4ef5c3 100644
96049 --- a/net/phonet/socket.c
96050 +++ b/net/phonet/socket.c
96051 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
96052 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
96053 sock_i_ino(sk),
96054 atomic_read(&sk->sk_refcnt), sk,
96055 - atomic_read(&sk->sk_drops), &len);
96056 + atomic_read_unchecked(&sk->sk_drops), &len);
96057 }
96058 seq_printf(seq, "%*s\n", 127 - len, "");
96059 return 0;
96060 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
96061 index c02a8c4..3c5b600 100644
96062 --- a/net/phonet/sysctl.c
96063 +++ b/net/phonet/sysctl.c
96064 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
96065 {
96066 int ret;
96067 int range[2] = {local_port_range[0], local_port_range[1]};
96068 - struct ctl_table tmp = {
96069 + ctl_table_no_const tmp = {
96070 .data = &range,
96071 .maxlen = sizeof(range),
96072 .mode = table->mode,
96073 diff --git a/net/rds/cong.c b/net/rds/cong.c
96074 index e5b65ac..f3b6fb7 100644
96075 --- a/net/rds/cong.c
96076 +++ b/net/rds/cong.c
96077 @@ -78,7 +78,7 @@
96078 * finds that the saved generation number is smaller than the global generation
96079 * number, it wakes up the process.
96080 */
96081 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
96082 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
96083
96084 /*
96085 * Congestion monitoring
96086 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
96087 rdsdebug("waking map %p for %pI4\n",
96088 map, &map->m_addr);
96089 rds_stats_inc(s_cong_update_received);
96090 - atomic_inc(&rds_cong_generation);
96091 + atomic_inc_unchecked(&rds_cong_generation);
96092 if (waitqueue_active(&map->m_waitq))
96093 wake_up(&map->m_waitq);
96094 if (waitqueue_active(&rds_poll_waitq))
96095 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
96096
96097 int rds_cong_updated_since(unsigned long *recent)
96098 {
96099 - unsigned long gen = atomic_read(&rds_cong_generation);
96100 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
96101
96102 if (likely(*recent == gen))
96103 return 0;
96104 diff --git a/net/rds/ib.h b/net/rds/ib.h
96105 index 7280ab8..e04f4ea 100644
96106 --- a/net/rds/ib.h
96107 +++ b/net/rds/ib.h
96108 @@ -128,7 +128,7 @@ struct rds_ib_connection {
96109 /* sending acks */
96110 unsigned long i_ack_flags;
96111 #ifdef KERNEL_HAS_ATOMIC64
96112 - atomic64_t i_ack_next; /* next ACK to send */
96113 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96114 #else
96115 spinlock_t i_ack_lock; /* protect i_ack_next */
96116 u64 i_ack_next; /* next ACK to send */
96117 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
96118 index 31b74f5..dc1fbfa 100644
96119 --- a/net/rds/ib_cm.c
96120 +++ b/net/rds/ib_cm.c
96121 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
96122 /* Clear the ACK state */
96123 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96124 #ifdef KERNEL_HAS_ATOMIC64
96125 - atomic64_set(&ic->i_ack_next, 0);
96126 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96127 #else
96128 ic->i_ack_next = 0;
96129 #endif
96130 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
96131 index 8eb9501..0c386ff 100644
96132 --- a/net/rds/ib_recv.c
96133 +++ b/net/rds/ib_recv.c
96134 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96135 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
96136 int ack_required)
96137 {
96138 - atomic64_set(&ic->i_ack_next, seq);
96139 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96140 if (ack_required) {
96141 smp_mb__before_clear_bit();
96142 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96143 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96144 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96145 smp_mb__after_clear_bit();
96146
96147 - return atomic64_read(&ic->i_ack_next);
96148 + return atomic64_read_unchecked(&ic->i_ack_next);
96149 }
96150 #endif
96151
96152 diff --git a/net/rds/iw.h b/net/rds/iw.h
96153 index 04ce3b1..48119a6 100644
96154 --- a/net/rds/iw.h
96155 +++ b/net/rds/iw.h
96156 @@ -134,7 +134,7 @@ struct rds_iw_connection {
96157 /* sending acks */
96158 unsigned long i_ack_flags;
96159 #ifdef KERNEL_HAS_ATOMIC64
96160 - atomic64_t i_ack_next; /* next ACK to send */
96161 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96162 #else
96163 spinlock_t i_ack_lock; /* protect i_ack_next */
96164 u64 i_ack_next; /* next ACK to send */
96165 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
96166 index a91e1db..cf3053f 100644
96167 --- a/net/rds/iw_cm.c
96168 +++ b/net/rds/iw_cm.c
96169 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
96170 /* Clear the ACK state */
96171 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96172 #ifdef KERNEL_HAS_ATOMIC64
96173 - atomic64_set(&ic->i_ack_next, 0);
96174 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96175 #else
96176 ic->i_ack_next = 0;
96177 #endif
96178 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
96179 index 4503335..db566b4 100644
96180 --- a/net/rds/iw_recv.c
96181 +++ b/net/rds/iw_recv.c
96182 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96183 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
96184 int ack_required)
96185 {
96186 - atomic64_set(&ic->i_ack_next, seq);
96187 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96188 if (ack_required) {
96189 smp_mb__before_clear_bit();
96190 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96191 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96192 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96193 smp_mb__after_clear_bit();
96194
96195 - return atomic64_read(&ic->i_ack_next);
96196 + return atomic64_read_unchecked(&ic->i_ack_next);
96197 }
96198 #endif
96199
96200 diff --git a/net/rds/rds.h b/net/rds/rds.h
96201 index ec1d731..90a3a8d 100644
96202 --- a/net/rds/rds.h
96203 +++ b/net/rds/rds.h
96204 @@ -449,7 +449,7 @@ struct rds_transport {
96205 void (*sync_mr)(void *trans_private, int direction);
96206 void (*free_mr)(void *trans_private, int invalidate);
96207 void (*flush_mrs)(void);
96208 -};
96209 +} __do_const;
96210
96211 struct rds_sock {
96212 struct sock rs_sk;
96213 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
96214 index edac9ef..16bcb98 100644
96215 --- a/net/rds/tcp.c
96216 +++ b/net/rds/tcp.c
96217 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
96218 int val = 1;
96219
96220 set_fs(KERNEL_DS);
96221 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
96222 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
96223 sizeof(val));
96224 set_fs(oldfs);
96225 }
96226 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
96227 index 81cf5a4..b5826ff 100644
96228 --- a/net/rds/tcp_send.c
96229 +++ b/net/rds/tcp_send.c
96230 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
96231
96232 oldfs = get_fs();
96233 set_fs(KERNEL_DS);
96234 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
96235 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
96236 sizeof(val));
96237 set_fs(oldfs);
96238 }
96239 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
96240 index e61aa60..f07cc89 100644
96241 --- a/net/rxrpc/af_rxrpc.c
96242 +++ b/net/rxrpc/af_rxrpc.c
96243 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
96244 __be32 rxrpc_epoch;
96245
96246 /* current debugging ID */
96247 -atomic_t rxrpc_debug_id;
96248 +atomic_unchecked_t rxrpc_debug_id;
96249
96250 /* count of skbs currently in use */
96251 atomic_t rxrpc_n_skbs;
96252 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
96253 index e4d9cbc..b229649 100644
96254 --- a/net/rxrpc/ar-ack.c
96255 +++ b/net/rxrpc/ar-ack.c
96256 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96257
96258 _enter("{%d,%d,%d,%d},",
96259 call->acks_hard, call->acks_unacked,
96260 - atomic_read(&call->sequence),
96261 + atomic_read_unchecked(&call->sequence),
96262 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
96263
96264 stop = 0;
96265 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96266
96267 /* each Tx packet has a new serial number */
96268 sp->hdr.serial =
96269 - htonl(atomic_inc_return(&call->conn->serial));
96270 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
96271
96272 hdr = (struct rxrpc_header *) txb->head;
96273 hdr->serial = sp->hdr.serial;
96274 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
96275 */
96276 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
96277 {
96278 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
96279 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
96280 }
96281
96282 /*
96283 @@ -629,7 +629,7 @@ process_further:
96284
96285 latest = ntohl(sp->hdr.serial);
96286 hard = ntohl(ack.firstPacket);
96287 - tx = atomic_read(&call->sequence);
96288 + tx = atomic_read_unchecked(&call->sequence);
96289
96290 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96291 latest,
96292 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
96293 goto maybe_reschedule;
96294
96295 send_ACK_with_skew:
96296 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
96297 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
96298 ntohl(ack.serial));
96299 send_ACK:
96300 mtu = call->conn->trans->peer->if_mtu;
96301 @@ -1173,7 +1173,7 @@ send_ACK:
96302 ackinfo.rxMTU = htonl(5692);
96303 ackinfo.jumbo_max = htonl(4);
96304
96305 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96306 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96307 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96308 ntohl(hdr.serial),
96309 ntohs(ack.maxSkew),
96310 @@ -1191,7 +1191,7 @@ send_ACK:
96311 send_message:
96312 _debug("send message");
96313
96314 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96315 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96316 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
96317 send_message_2:
96318
96319 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
96320 index a3bbb36..3341fb9 100644
96321 --- a/net/rxrpc/ar-call.c
96322 +++ b/net/rxrpc/ar-call.c
96323 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
96324 spin_lock_init(&call->lock);
96325 rwlock_init(&call->state_lock);
96326 atomic_set(&call->usage, 1);
96327 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
96328 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96329 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
96330
96331 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
96332 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
96333 index 4106ca9..a338d7a 100644
96334 --- a/net/rxrpc/ar-connection.c
96335 +++ b/net/rxrpc/ar-connection.c
96336 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
96337 rwlock_init(&conn->lock);
96338 spin_lock_init(&conn->state_lock);
96339 atomic_set(&conn->usage, 1);
96340 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
96341 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96342 conn->avail_calls = RXRPC_MAXCALLS;
96343 conn->size_align = 4;
96344 conn->header_size = sizeof(struct rxrpc_header);
96345 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
96346 index e7ed43a..6afa140 100644
96347 --- a/net/rxrpc/ar-connevent.c
96348 +++ b/net/rxrpc/ar-connevent.c
96349 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
96350
96351 len = iov[0].iov_len + iov[1].iov_len;
96352
96353 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96354 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96355 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
96356
96357 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96358 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
96359 index 529572f..c758ca7 100644
96360 --- a/net/rxrpc/ar-input.c
96361 +++ b/net/rxrpc/ar-input.c
96362 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
96363 /* track the latest serial number on this connection for ACK packet
96364 * information */
96365 serial = ntohl(sp->hdr.serial);
96366 - hi_serial = atomic_read(&call->conn->hi_serial);
96367 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
96368 while (serial > hi_serial)
96369 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
96370 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
96371 serial);
96372
96373 /* request ACK generation for any ACK or DATA packet that requests
96374 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
96375 index a693aca..81e7293 100644
96376 --- a/net/rxrpc/ar-internal.h
96377 +++ b/net/rxrpc/ar-internal.h
96378 @@ -272,8 +272,8 @@ struct rxrpc_connection {
96379 int error; /* error code for local abort */
96380 int debug_id; /* debug ID for printks */
96381 unsigned int call_counter; /* call ID counter */
96382 - atomic_t serial; /* packet serial number counter */
96383 - atomic_t hi_serial; /* highest serial number received */
96384 + atomic_unchecked_t serial; /* packet serial number counter */
96385 + atomic_unchecked_t hi_serial; /* highest serial number received */
96386 u8 avail_calls; /* number of calls available */
96387 u8 size_align; /* data size alignment (for security) */
96388 u8 header_size; /* rxrpc + security header size */
96389 @@ -346,7 +346,7 @@ struct rxrpc_call {
96390 spinlock_t lock;
96391 rwlock_t state_lock; /* lock for state transition */
96392 atomic_t usage;
96393 - atomic_t sequence; /* Tx data packet sequence counter */
96394 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
96395 u32 abort_code; /* local/remote abort code */
96396 enum { /* current state of call */
96397 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
96398 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
96399 */
96400 extern atomic_t rxrpc_n_skbs;
96401 extern __be32 rxrpc_epoch;
96402 -extern atomic_t rxrpc_debug_id;
96403 +extern atomic_unchecked_t rxrpc_debug_id;
96404 extern struct workqueue_struct *rxrpc_workqueue;
96405
96406 /*
96407 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
96408 index 87f7135..74d3703 100644
96409 --- a/net/rxrpc/ar-local.c
96410 +++ b/net/rxrpc/ar-local.c
96411 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
96412 spin_lock_init(&local->lock);
96413 rwlock_init(&local->services_lock);
96414 atomic_set(&local->usage, 1);
96415 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
96416 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96417 memcpy(&local->srx, srx, sizeof(*srx));
96418 }
96419
96420 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
96421 index e1ac183..b43e10e 100644
96422 --- a/net/rxrpc/ar-output.c
96423 +++ b/net/rxrpc/ar-output.c
96424 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
96425 sp->hdr.cid = call->cid;
96426 sp->hdr.callNumber = call->call_id;
96427 sp->hdr.seq =
96428 - htonl(atomic_inc_return(&call->sequence));
96429 + htonl(atomic_inc_return_unchecked(&call->sequence));
96430 sp->hdr.serial =
96431 - htonl(atomic_inc_return(&conn->serial));
96432 + htonl(atomic_inc_return_unchecked(&conn->serial));
96433 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
96434 sp->hdr.userStatus = 0;
96435 sp->hdr.securityIndex = conn->security_ix;
96436 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
96437 index bebaa43..2644591 100644
96438 --- a/net/rxrpc/ar-peer.c
96439 +++ b/net/rxrpc/ar-peer.c
96440 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
96441 INIT_LIST_HEAD(&peer->error_targets);
96442 spin_lock_init(&peer->lock);
96443 atomic_set(&peer->usage, 1);
96444 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
96445 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96446 memcpy(&peer->srx, srx, sizeof(*srx));
96447
96448 rxrpc_assess_MTU_size(peer);
96449 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
96450 index 38047f7..9f48511 100644
96451 --- a/net/rxrpc/ar-proc.c
96452 +++ b/net/rxrpc/ar-proc.c
96453 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
96454 atomic_read(&conn->usage),
96455 rxrpc_conn_states[conn->state],
96456 key_serial(conn->key),
96457 - atomic_read(&conn->serial),
96458 - atomic_read(&conn->hi_serial));
96459 + atomic_read_unchecked(&conn->serial),
96460 + atomic_read_unchecked(&conn->hi_serial));
96461
96462 return 0;
96463 }
96464 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
96465 index 92df566..87ec1bf 100644
96466 --- a/net/rxrpc/ar-transport.c
96467 +++ b/net/rxrpc/ar-transport.c
96468 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
96469 spin_lock_init(&trans->client_lock);
96470 rwlock_init(&trans->conn_lock);
96471 atomic_set(&trans->usage, 1);
96472 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
96473 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96474
96475 if (peer->srx.transport.family == AF_INET) {
96476 switch (peer->srx.transport_type) {
96477 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
96478 index f226709..0e735a8 100644
96479 --- a/net/rxrpc/rxkad.c
96480 +++ b/net/rxrpc/rxkad.c
96481 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
96482
96483 len = iov[0].iov_len + iov[1].iov_len;
96484
96485 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96486 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96487 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
96488
96489 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96490 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
96491
96492 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
96493
96494 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
96495 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96496 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
96497
96498 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
96499 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
96500 index e7b2d4f..bb1efd0 100644
96501 --- a/net/sctp/ipv6.c
96502 +++ b/net/sctp/ipv6.c
96503 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
96504 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
96505 };
96506
96507 -static struct sctp_af sctp_af_inet6 = {
96508 +static struct sctp_af sctp_af_inet6 __read_only = {
96509 .sa_family = AF_INET6,
96510 .sctp_xmit = sctp_v6_xmit,
96511 .setsockopt = ipv6_setsockopt,
96512 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
96513 #endif
96514 };
96515
96516 -static struct sctp_pf sctp_pf_inet6 = {
96517 +static struct sctp_pf sctp_pf_inet6 __read_only = {
96518 .event_msgname = sctp_inet6_event_msgname,
96519 .skb_msgname = sctp_inet6_skb_msgname,
96520 .af_supported = sctp_inet6_af_supported,
96521 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
96522
96523 void sctp_v6_pf_exit(void)
96524 {
96525 - list_del(&sctp_af_inet6.list);
96526 + pax_list_del(&sctp_af_inet6.list);
96527 }
96528
96529 /* Initialize IPv6 support and register with socket layer. */
96530 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
96531 index 5e17092..19be1d4 100644
96532 --- a/net/sctp/protocol.c
96533 +++ b/net/sctp/protocol.c
96534 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
96535 return 0;
96536 }
96537
96538 + pax_open_kernel();
96539 INIT_LIST_HEAD(&af->list);
96540 - list_add_tail(&af->list, &sctp_address_families);
96541 + pax_close_kernel();
96542 + pax_list_add_tail(&af->list, &sctp_address_families);
96543 return 1;
96544 }
96545
96546 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
96547
96548 static struct sctp_af sctp_af_inet;
96549
96550 -static struct sctp_pf sctp_pf_inet = {
96551 +static struct sctp_pf sctp_pf_inet __read_only = {
96552 .event_msgname = sctp_inet_event_msgname,
96553 .skb_msgname = sctp_inet_skb_msgname,
96554 .af_supported = sctp_inet_af_supported,
96555 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
96556 };
96557
96558 /* IPv4 address related functions. */
96559 -static struct sctp_af sctp_af_inet = {
96560 +static struct sctp_af sctp_af_inet __read_only = {
96561 .sa_family = AF_INET,
96562 .sctp_xmit = sctp_v4_xmit,
96563 .setsockopt = ip_setsockopt,
96564 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
96565
96566 static void sctp_v4_pf_exit(void)
96567 {
96568 - list_del(&sctp_af_inet.list);
96569 + pax_list_del(&sctp_af_inet.list);
96570 }
96571
96572 static int sctp_v4_protosw_init(void)
96573 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
96574 index 1a6eef3..17e898f 100644
96575 --- a/net/sctp/sm_sideeffect.c
96576 +++ b/net/sctp/sm_sideeffect.c
96577 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
96578 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
96579 }
96580
96581 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96582 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96583 NULL,
96584 sctp_generate_t1_cookie_event,
96585 sctp_generate_t1_init_event,
96586 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
96587 index 911b71b..90ade0a 100644
96588 --- a/net/sctp/socket.c
96589 +++ b/net/sctp/socket.c
96590 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
96591 {
96592 struct sctp_association *asoc;
96593 struct sctp_ulpevent *event;
96594 + struct sctp_event_subscribe subscribe;
96595
96596 if (optlen > sizeof(struct sctp_event_subscribe))
96597 return -EINVAL;
96598 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
96599 + if (copy_from_user(&subscribe, optval, optlen))
96600 return -EFAULT;
96601 + sctp_sk(sk)->subscribe = subscribe;
96602
96603 /*
96604 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
96605 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
96606 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96607 int __user *optlen)
96608 {
96609 + struct sctp_event_subscribe subscribe;
96610 +
96611 if (len <= 0)
96612 return -EINVAL;
96613 if (len > sizeof(struct sctp_event_subscribe))
96614 len = sizeof(struct sctp_event_subscribe);
96615 if (put_user(len, optlen))
96616 return -EFAULT;
96617 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
96618 + subscribe = sctp_sk(sk)->subscribe;
96619 + if (copy_to_user(optval, &subscribe, len))
96620 return -EFAULT;
96621 return 0;
96622 }
96623 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96624 */
96625 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
96626 {
96627 + __u32 autoclose;
96628 +
96629 /* Applicable to UDP-style socket only */
96630 if (sctp_style(sk, TCP))
96631 return -EOPNOTSUPP;
96632 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
96633 len = sizeof(int);
96634 if (put_user(len, optlen))
96635 return -EFAULT;
96636 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
96637 + autoclose = sctp_sk(sk)->autoclose;
96638 + if (copy_to_user(optval, &autoclose, sizeof(int)))
96639 return -EFAULT;
96640 return 0;
96641 }
96642 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
96643 */
96644 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
96645 {
96646 + struct sctp_initmsg initmsg;
96647 +
96648 if (len < sizeof(struct sctp_initmsg))
96649 return -EINVAL;
96650 len = sizeof(struct sctp_initmsg);
96651 if (put_user(len, optlen))
96652 return -EFAULT;
96653 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
96654 + initmsg = sctp_sk(sk)->initmsg;
96655 + if (copy_to_user(optval, &initmsg, len))
96656 return -EFAULT;
96657 return 0;
96658 }
96659 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
96660 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
96661 if (space_left < addrlen)
96662 return -ENOMEM;
96663 + if (addrlen > sizeof(temp) || addrlen < 0)
96664 + return -EFAULT;
96665 if (copy_to_user(to, &temp, addrlen))
96666 return -EFAULT;
96667 to += addrlen;
96668 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
96669 index 6b36561..4f21064 100644
96670 --- a/net/sctp/sysctl.c
96671 +++ b/net/sctp/sysctl.c
96672 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96673 {
96674 struct net *net = current->nsproxy->net_ns;
96675 char tmp[8];
96676 - struct ctl_table tbl;
96677 + ctl_table_no_const tbl;
96678 int ret;
96679 int changed = 0;
96680 char *none = "none";
96681 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96682
96683 int sctp_sysctl_net_register(struct net *net)
96684 {
96685 - struct ctl_table *table;
96686 + ctl_table_no_const *table;
96687 int i;
96688
96689 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
96690 diff --git a/net/socket.c b/net/socket.c
96691 index c226ace..561e8f7 100644
96692 --- a/net/socket.c
96693 +++ b/net/socket.c
96694 @@ -88,6 +88,7 @@
96695 #include <linux/magic.h>
96696 #include <linux/slab.h>
96697 #include <linux/xattr.h>
96698 +#include <linux/in.h>
96699
96700 #include <asm/uaccess.h>
96701 #include <asm/unistd.h>
96702 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
96703 unsigned int sysctl_net_busy_poll __read_mostly;
96704 #endif
96705
96706 +#include <linux/grsock.h>
96707 +
96708 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
96709 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
96710 unsigned long nr_segs, loff_t pos);
96711 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
96712 */
96713
96714 static DEFINE_SPINLOCK(net_family_lock);
96715 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96716 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96717
96718 /*
96719 * Statistics counters of the socket lists
96720 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
96721 &sockfs_dentry_operations, SOCKFS_MAGIC);
96722 }
96723
96724 -static struct vfsmount *sock_mnt __read_mostly;
96725 +struct vfsmount *sock_mnt __read_mostly;
96726
96727 static struct file_system_type sock_fs_type = {
96728 .name = "sockfs",
96729 @@ -1254,6 +1257,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96730 return -EAFNOSUPPORT;
96731 if (type < 0 || type >= SOCK_MAX)
96732 return -EINVAL;
96733 + if (protocol < 0)
96734 + return -EINVAL;
96735
96736 /* Compatibility.
96737
96738 @@ -1274,6 +1279,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96739 if (err)
96740 return err;
96741
96742 + if(!kern && !gr_search_socket(family, type, protocol)) {
96743 + if (rcu_access_pointer(net_families[family]) == NULL)
96744 + return -EAFNOSUPPORT;
96745 + else
96746 + return -EACCES;
96747 + }
96748 +
96749 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
96750 + if (rcu_access_pointer(net_families[family]) == NULL)
96751 + return -EAFNOSUPPORT;
96752 + else
96753 + return -EACCES;
96754 + }
96755 +
96756 /*
96757 * Allocate the socket and allow the family to set things up. if
96758 * the protocol is 0, the family is instructed to select an appropriate
96759 @@ -1512,6 +1531,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96760 if (sock) {
96761 err = move_addr_to_kernel(umyaddr, addrlen, &address);
96762 if (err >= 0) {
96763 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
96764 + err = -EACCES;
96765 + goto error;
96766 + }
96767 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
96768 + if (err)
96769 + goto error;
96770 +
96771 err = security_socket_bind(sock,
96772 (struct sockaddr *)&address,
96773 addrlen);
96774 @@ -1520,6 +1547,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96775 (struct sockaddr *)
96776 &address, addrlen);
96777 }
96778 +error:
96779 fput_light(sock->file, fput_needed);
96780 }
96781 return err;
96782 @@ -1543,10 +1571,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
96783 if ((unsigned int)backlog > somaxconn)
96784 backlog = somaxconn;
96785
96786 + if (gr_handle_sock_server_other(sock->sk)) {
96787 + err = -EPERM;
96788 + goto error;
96789 + }
96790 +
96791 + err = gr_search_listen(sock);
96792 + if (err)
96793 + goto error;
96794 +
96795 err = security_socket_listen(sock, backlog);
96796 if (!err)
96797 err = sock->ops->listen(sock, backlog);
96798
96799 +error:
96800 fput_light(sock->file, fput_needed);
96801 }
96802 return err;
96803 @@ -1590,6 +1628,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96804 newsock->type = sock->type;
96805 newsock->ops = sock->ops;
96806
96807 + if (gr_handle_sock_server_other(sock->sk)) {
96808 + err = -EPERM;
96809 + sock_release(newsock);
96810 + goto out_put;
96811 + }
96812 +
96813 + err = gr_search_accept(sock);
96814 + if (err) {
96815 + sock_release(newsock);
96816 + goto out_put;
96817 + }
96818 +
96819 /*
96820 * We don't need try_module_get here, as the listening socket (sock)
96821 * has the protocol module (sock->ops->owner) held.
96822 @@ -1635,6 +1685,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96823 fd_install(newfd, newfile);
96824 err = newfd;
96825
96826 + gr_attach_curr_ip(newsock->sk);
96827 +
96828 out_put:
96829 fput_light(sock->file, fput_needed);
96830 out:
96831 @@ -1667,6 +1719,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96832 int, addrlen)
96833 {
96834 struct socket *sock;
96835 + struct sockaddr *sck;
96836 struct sockaddr_storage address;
96837 int err, fput_needed;
96838
96839 @@ -1677,6 +1730,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96840 if (err < 0)
96841 goto out_put;
96842
96843 + sck = (struct sockaddr *)&address;
96844 +
96845 + if (gr_handle_sock_client(sck)) {
96846 + err = -EACCES;
96847 + goto out_put;
96848 + }
96849 +
96850 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
96851 + if (err)
96852 + goto out_put;
96853 +
96854 err =
96855 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
96856 if (err)
96857 @@ -1758,6 +1822,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
96858 * the protocol.
96859 */
96860
96861 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
96862 +
96863 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
96864 unsigned int, flags, struct sockaddr __user *, addr,
96865 int, addr_len)
96866 @@ -1824,7 +1890,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
96867 struct socket *sock;
96868 struct iovec iov;
96869 struct msghdr msg;
96870 - struct sockaddr_storage address;
96871 + struct sockaddr_storage address = { };
96872 int err, err2;
96873 int fput_needed;
96874
96875 @@ -2044,7 +2110,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96876 * checking falls down on this.
96877 */
96878 if (copy_from_user(ctl_buf,
96879 - (void __user __force *)msg_sys->msg_control,
96880 + (void __force_user *)msg_sys->msg_control,
96881 ctl_len))
96882 goto out_freectl;
96883 msg_sys->msg_control = ctl_buf;
96884 @@ -2195,7 +2261,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96885 int err, total_len, len;
96886
96887 /* kernel mode address */
96888 - struct sockaddr_storage addr;
96889 + struct sockaddr_storage addr = { };
96890
96891 /* user mode address pointers */
96892 struct sockaddr __user *uaddr;
96893 @@ -2226,7 +2292,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96894 * kernel msghdr to use the kernel address space)
96895 */
96896
96897 - uaddr = (__force void __user *)msg_sys->msg_name;
96898 + uaddr = (void __force_user *)msg_sys->msg_name;
96899 uaddr_len = COMPAT_NAMELEN(msg);
96900 if (MSG_CMSG_COMPAT & flags) {
96901 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96902 @@ -2981,7 +3047,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96903 old_fs = get_fs();
96904 set_fs(KERNEL_DS);
96905 err = dev_ioctl(net, cmd,
96906 - (struct ifreq __user __force *) &kifr);
96907 + (struct ifreq __force_user *) &kifr);
96908 set_fs(old_fs);
96909
96910 return err;
96911 @@ -3090,7 +3156,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96912
96913 old_fs = get_fs();
96914 set_fs(KERNEL_DS);
96915 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96916 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96917 set_fs(old_fs);
96918
96919 if (cmd == SIOCGIFMAP && !err) {
96920 @@ -3195,7 +3261,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96921 ret |= get_user(rtdev, &(ur4->rt_dev));
96922 if (rtdev) {
96923 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96924 - r4.rt_dev = (char __user __force *)devname;
96925 + r4.rt_dev = (char __force_user *)devname;
96926 devname[15] = 0;
96927 } else
96928 r4.rt_dev = NULL;
96929 @@ -3421,8 +3487,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96930 int __user *uoptlen;
96931 int err;
96932
96933 - uoptval = (char __user __force *) optval;
96934 - uoptlen = (int __user __force *) optlen;
96935 + uoptval = (char __force_user *) optval;
96936 + uoptlen = (int __force_user *) optlen;
96937
96938 set_fs(KERNEL_DS);
96939 if (level == SOL_SOCKET)
96940 @@ -3442,7 +3508,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96941 char __user *uoptval;
96942 int err;
96943
96944 - uoptval = (char __user __force *) optval;
96945 + uoptval = (char __force_user *) optval;
96946
96947 set_fs(KERNEL_DS);
96948 if (level == SOL_SOCKET)
96949 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96950 index 09fb638..2e6a5c5 100644
96951 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96952 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96953 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96954 uint64_t *handle)
96955 {
96956 struct rsc rsci, *rscp = NULL;
96957 - static atomic64_t ctxhctr;
96958 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96959 long long ctxh;
96960 struct gss_api_mech *gm = NULL;
96961 time_t expiry;
96962 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96963 status = -ENOMEM;
96964 /* the handle needs to be just a unique id,
96965 * use a static counter */
96966 - ctxh = atomic64_inc_return(&ctxhctr);
96967 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96968
96969 /* make a copy for the caller */
96970 *handle = ctxh;
96971 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96972 index 7747960..36d1518 100644
96973 --- a/net/sunrpc/clnt.c
96974 +++ b/net/sunrpc/clnt.c
96975 @@ -656,14 +656,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);
96976 /*
96977 * Free an RPC client
96978 */
96979 -static void
96980 +static struct rpc_clnt *
96981 rpc_free_client(struct rpc_clnt *clnt)
96982 {
96983 + struct rpc_clnt *parent = NULL;
96984 +
96985 dprintk_rcu("RPC: destroying %s client for %s\n",
96986 clnt->cl_program->name,
96987 rcu_dereference(clnt->cl_xprt)->servername);
96988 if (clnt->cl_parent != clnt)
96989 - rpc_release_client(clnt->cl_parent);
96990 + parent = clnt->cl_parent;
96991 rpc_clnt_remove_pipedir(clnt);
96992 rpc_unregister_client(clnt);
96993 rpc_free_iostats(clnt->cl_metrics);
96994 @@ -672,18 +674,17 @@ rpc_free_client(struct rpc_clnt *clnt)
96995 rpciod_down();
96996 rpc_free_clid(clnt);
96997 kfree(clnt);
96998 + return parent;
96999 }
97000
97001 /*
97002 * Free an RPC client
97003 */
97004 -static void
97005 +static struct rpc_clnt *
97006 rpc_free_auth(struct rpc_clnt *clnt)
97007 {
97008 - if (clnt->cl_auth == NULL) {
97009 - rpc_free_client(clnt);
97010 - return;
97011 - }
97012 + if (clnt->cl_auth == NULL)
97013 + return rpc_free_client(clnt);
97014
97015 /*
97016 * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
97017 @@ -694,7 +695,8 @@ rpc_free_auth(struct rpc_clnt *clnt)
97018 rpcauth_release(clnt->cl_auth);
97019 clnt->cl_auth = NULL;
97020 if (atomic_dec_and_test(&clnt->cl_count))
97021 - rpc_free_client(clnt);
97022 + return rpc_free_client(clnt);
97023 + return NULL;
97024 }
97025
97026 /*
97027 @@ -705,10 +707,13 @@ rpc_release_client(struct rpc_clnt *clnt)
97028 {
97029 dprintk("RPC: rpc_release_client(%p)\n", clnt);
97030
97031 - if (list_empty(&clnt->cl_tasks))
97032 - wake_up(&destroy_wait);
97033 - if (atomic_dec_and_test(&clnt->cl_count))
97034 - rpc_free_auth(clnt);
97035 + do {
97036 + if (list_empty(&clnt->cl_tasks))
97037 + wake_up(&destroy_wait);
97038 + if (!atomic_dec_and_test(&clnt->cl_count))
97039 + break;
97040 + clnt = rpc_free_auth(clnt);
97041 + } while (clnt != NULL);
97042 }
97043 EXPORT_SYMBOL_GPL(rpc_release_client);
97044
97045 @@ -1314,7 +1319,9 @@ call_start(struct rpc_task *task)
97046 (RPC_IS_ASYNC(task) ? "async" : "sync"));
97047
97048 /* Increment call count */
97049 - task->tk_msg.rpc_proc->p_count++;
97050 + pax_open_kernel();
97051 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
97052 + pax_close_kernel();
97053 clnt->cl_stats->rpccnt++;
97054 task->tk_action = call_reserve;
97055 }
97056 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
97057 index ff3cc4b..7612a9e 100644
97058 --- a/net/sunrpc/sched.c
97059 +++ b/net/sunrpc/sched.c
97060 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
97061 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
97062 static void rpc_task_set_debuginfo(struct rpc_task *task)
97063 {
97064 - static atomic_t rpc_pid;
97065 + static atomic_unchecked_t rpc_pid;
97066
97067 - task->tk_pid = atomic_inc_return(&rpc_pid);
97068 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
97069 }
97070 #else
97071 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
97072 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
97073 index b974571..678ed90 100644
97074 --- a/net/sunrpc/svc.c
97075 +++ b/net/sunrpc/svc.c
97076 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
97077 svc_putnl(resv, RPC_SUCCESS);
97078
97079 /* Bump per-procedure stats counter */
97080 - procp->pc_count++;
97081 + pax_open_kernel();
97082 + (*(unsigned int *)&procp->pc_count)++;
97083 + pax_close_kernel();
97084
97085 /* Initialize storage for argp and resp */
97086 memset(rqstp->rq_argp, 0, procp->pc_argsize);
97087 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
97088 index 621ca7b..59421dd 100644
97089 --- a/net/sunrpc/svcauth_unix.c
97090 +++ b/net/sunrpc/svcauth_unix.c
97091 @@ -414,7 +414,7 @@ struct unix_gid {
97092 struct group_info *gi;
97093 };
97094
97095 -static int unix_gid_hash(kuid_t uid)
97096 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
97097 {
97098 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
97099 }
97100 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
97101 (*bpp)[-1] = '\n';
97102 }
97103
97104 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97105 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97106
97107 static int unix_gid_parse(struct cache_detail *cd,
97108 char *mesg, int mlen)
97109 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
97110 index c1b6270..05089c1 100644
97111 --- a/net/sunrpc/xprtrdma/svc_rdma.c
97112 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
97113 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
97114 static unsigned int min_max_inline = 4096;
97115 static unsigned int max_max_inline = 65536;
97116
97117 -atomic_t rdma_stat_recv;
97118 -atomic_t rdma_stat_read;
97119 -atomic_t rdma_stat_write;
97120 -atomic_t rdma_stat_sq_starve;
97121 -atomic_t rdma_stat_rq_starve;
97122 -atomic_t rdma_stat_rq_poll;
97123 -atomic_t rdma_stat_rq_prod;
97124 -atomic_t rdma_stat_sq_poll;
97125 -atomic_t rdma_stat_sq_prod;
97126 +atomic_unchecked_t rdma_stat_recv;
97127 +atomic_unchecked_t rdma_stat_read;
97128 +atomic_unchecked_t rdma_stat_write;
97129 +atomic_unchecked_t rdma_stat_sq_starve;
97130 +atomic_unchecked_t rdma_stat_rq_starve;
97131 +atomic_unchecked_t rdma_stat_rq_poll;
97132 +atomic_unchecked_t rdma_stat_rq_prod;
97133 +atomic_unchecked_t rdma_stat_sq_poll;
97134 +atomic_unchecked_t rdma_stat_sq_prod;
97135
97136 /* Temporary NFS request map and context caches */
97137 struct kmem_cache *svc_rdma_map_cachep;
97138 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
97139 len -= *ppos;
97140 if (len > *lenp)
97141 len = *lenp;
97142 - if (len && copy_to_user(buffer, str_buf, len))
97143 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
97144 return -EFAULT;
97145 *lenp = len;
97146 *ppos += len;
97147 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
97148 {
97149 .procname = "rdma_stat_read",
97150 .data = &rdma_stat_read,
97151 - .maxlen = sizeof(atomic_t),
97152 + .maxlen = sizeof(atomic_unchecked_t),
97153 .mode = 0644,
97154 .proc_handler = read_reset_stat,
97155 },
97156 {
97157 .procname = "rdma_stat_recv",
97158 .data = &rdma_stat_recv,
97159 - .maxlen = sizeof(atomic_t),
97160 + .maxlen = sizeof(atomic_unchecked_t),
97161 .mode = 0644,
97162 .proc_handler = read_reset_stat,
97163 },
97164 {
97165 .procname = "rdma_stat_write",
97166 .data = &rdma_stat_write,
97167 - .maxlen = sizeof(atomic_t),
97168 + .maxlen = sizeof(atomic_unchecked_t),
97169 .mode = 0644,
97170 .proc_handler = read_reset_stat,
97171 },
97172 {
97173 .procname = "rdma_stat_sq_starve",
97174 .data = &rdma_stat_sq_starve,
97175 - .maxlen = sizeof(atomic_t),
97176 + .maxlen = sizeof(atomic_unchecked_t),
97177 .mode = 0644,
97178 .proc_handler = read_reset_stat,
97179 },
97180 {
97181 .procname = "rdma_stat_rq_starve",
97182 .data = &rdma_stat_rq_starve,
97183 - .maxlen = sizeof(atomic_t),
97184 + .maxlen = sizeof(atomic_unchecked_t),
97185 .mode = 0644,
97186 .proc_handler = read_reset_stat,
97187 },
97188 {
97189 .procname = "rdma_stat_rq_poll",
97190 .data = &rdma_stat_rq_poll,
97191 - .maxlen = sizeof(atomic_t),
97192 + .maxlen = sizeof(atomic_unchecked_t),
97193 .mode = 0644,
97194 .proc_handler = read_reset_stat,
97195 },
97196 {
97197 .procname = "rdma_stat_rq_prod",
97198 .data = &rdma_stat_rq_prod,
97199 - .maxlen = sizeof(atomic_t),
97200 + .maxlen = sizeof(atomic_unchecked_t),
97201 .mode = 0644,
97202 .proc_handler = read_reset_stat,
97203 },
97204 {
97205 .procname = "rdma_stat_sq_poll",
97206 .data = &rdma_stat_sq_poll,
97207 - .maxlen = sizeof(atomic_t),
97208 + .maxlen = sizeof(atomic_unchecked_t),
97209 .mode = 0644,
97210 .proc_handler = read_reset_stat,
97211 },
97212 {
97213 .procname = "rdma_stat_sq_prod",
97214 .data = &rdma_stat_sq_prod,
97215 - .maxlen = sizeof(atomic_t),
97216 + .maxlen = sizeof(atomic_unchecked_t),
97217 .mode = 0644,
97218 .proc_handler = read_reset_stat,
97219 },
97220 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97221 index 0ce7552..d074459 100644
97222 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97223 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97224 @@ -501,7 +501,7 @@ next_sge:
97225 svc_rdma_put_context(ctxt, 0);
97226 goto out;
97227 }
97228 - atomic_inc(&rdma_stat_read);
97229 + atomic_inc_unchecked(&rdma_stat_read);
97230
97231 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
97232 chl_map->ch[ch_no].count -= read_wr.num_sge;
97233 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97234 dto_q);
97235 list_del_init(&ctxt->dto_q);
97236 } else {
97237 - atomic_inc(&rdma_stat_rq_starve);
97238 + atomic_inc_unchecked(&rdma_stat_rq_starve);
97239 clear_bit(XPT_DATA, &xprt->xpt_flags);
97240 ctxt = NULL;
97241 }
97242 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97243 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
97244 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
97245 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
97246 - atomic_inc(&rdma_stat_recv);
97247 + atomic_inc_unchecked(&rdma_stat_recv);
97248
97249 /* Build up the XDR from the receive buffers. */
97250 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
97251 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97252 index c1d124d..acfc59e 100644
97253 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97254 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97255 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
97256 write_wr.wr.rdma.remote_addr = to;
97257
97258 /* Post It */
97259 - atomic_inc(&rdma_stat_write);
97260 + atomic_inc_unchecked(&rdma_stat_write);
97261 if (svc_rdma_send(xprt, &write_wr))
97262 goto err;
97263 return 0;
97264 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97265 index 62e4f9b..dd3f2d7 100644
97266 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
97267 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97268 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97269 return;
97270
97271 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
97272 - atomic_inc(&rdma_stat_rq_poll);
97273 + atomic_inc_unchecked(&rdma_stat_rq_poll);
97274
97275 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
97276 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
97277 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97278 }
97279
97280 if (ctxt)
97281 - atomic_inc(&rdma_stat_rq_prod);
97282 + atomic_inc_unchecked(&rdma_stat_rq_prod);
97283
97284 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
97285 /*
97286 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97287 return;
97288
97289 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
97290 - atomic_inc(&rdma_stat_sq_poll);
97291 + atomic_inc_unchecked(&rdma_stat_sq_poll);
97292 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
97293 if (wc.status != IB_WC_SUCCESS)
97294 /* Close the transport */
97295 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97296 }
97297
97298 if (ctxt)
97299 - atomic_inc(&rdma_stat_sq_prod);
97300 + atomic_inc_unchecked(&rdma_stat_sq_prod);
97301 }
97302
97303 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
97304 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
97305 spin_lock_bh(&xprt->sc_lock);
97306 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
97307 spin_unlock_bh(&xprt->sc_lock);
97308 - atomic_inc(&rdma_stat_sq_starve);
97309 + atomic_inc_unchecked(&rdma_stat_sq_starve);
97310
97311 /* See if we can opportunistically reap SQ WR to make room */
97312 sq_cq_reap(xprt);
97313 diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
97314 index ee03d35..b752e1d 100644
97315 --- a/net/sunrpc/xprtsock.c
97316 +++ b/net/sunrpc/xprtsock.c
97317 @@ -393,8 +393,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
97318 return kernel_sendmsg(sock, &msg, NULL, 0, 0);
97319 }
97320
97321 -static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
97322 +static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
97323 {
97324 + ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
97325 + int offset, size_t size, int flags);
97326 struct page **ppage;
97327 unsigned int remainder;
97328 int err, sent = 0;
97329 @@ -403,6 +405,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
97330 base += xdr->page_base;
97331 ppage = xdr->pages + (base >> PAGE_SHIFT);
97332 base &= ~PAGE_MASK;
97333 + do_sendpage = sock->ops->sendpage;
97334 + if (!zerocopy)
97335 + do_sendpage = sock_no_sendpage;
97336 for(;;) {
97337 unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
97338 int flags = XS_SENDMSG_FLAGS;
97339 @@ -410,7 +415,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
97340 remainder -= len;
97341 if (remainder != 0 || more)
97342 flags |= MSG_MORE;
97343 - err = sock->ops->sendpage(sock, *ppage, base, len, flags);
97344 + err = do_sendpage(sock, *ppage, base, len, flags);
97345 if (remainder == 0 || err != len)
97346 break;
97347 sent += err;
97348 @@ -431,9 +436,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
97349 * @addrlen: UDP only -- length of destination address
97350 * @xdr: buffer containing this request
97351 * @base: starting position in the buffer
97352 + * @zerocopy: true if it is safe to use sendpage()
97353 *
97354 */
97355 -static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
97356 +static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
97357 {
97358 unsigned int remainder = xdr->len - base;
97359 int err, sent = 0;
97360 @@ -461,7 +467,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
97361 if (base < xdr->page_len) {
97362 unsigned int len = xdr->page_len - base;
97363 remainder -= len;
97364 - err = xs_send_pagedata(sock, xdr, base, remainder != 0);
97365 + err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
97366 if (remainder == 0 || err != len)
97367 goto out;
97368 sent += err;
97369 @@ -564,7 +570,7 @@ static int xs_local_send_request(struct rpc_task *task)
97370 req->rq_svec->iov_base, req->rq_svec->iov_len);
97371
97372 status = xs_sendpages(transport->sock, NULL, 0,
97373 - xdr, req->rq_bytes_sent);
97374 + xdr, req->rq_bytes_sent, true);
97375 dprintk("RPC: %s(%u) = %d\n",
97376 __func__, xdr->len - req->rq_bytes_sent, status);
97377 if (likely(status >= 0)) {
97378 @@ -620,7 +626,7 @@ static int xs_udp_send_request(struct rpc_task *task)
97379 status = xs_sendpages(transport->sock,
97380 xs_addr(xprt),
97381 xprt->addrlen, xdr,
97382 - req->rq_bytes_sent);
97383 + req->rq_bytes_sent, true);
97384
97385 dprintk("RPC: xs_udp_send_request(%u) = %d\n",
97386 xdr->len - req->rq_bytes_sent, status);
97387 @@ -693,6 +699,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
97388 struct rpc_xprt *xprt = req->rq_xprt;
97389 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
97390 struct xdr_buf *xdr = &req->rq_snd_buf;
97391 + bool zerocopy = true;
97392 int status;
97393
97394 xs_encode_stream_record_marker(&req->rq_snd_buf);
97395 @@ -700,13 +707,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
97396 xs_pktdump("packet data:",
97397 req->rq_svec->iov_base,
97398 req->rq_svec->iov_len);
97399 + /* Don't use zero copy if this is a resend. If the RPC call
97400 + * completes while the socket holds a reference to the pages,
97401 + * then we may end up resending corrupted data.
97402 + */
97403 + if (task->tk_flags & RPC_TASK_SENT)
97404 + zerocopy = false;
97405
97406 /* Continue transmitting the packet/record. We must be careful
97407 * to cope with writespace callbacks arriving _after_ we have
97408 * called sendmsg(). */
97409 while (1) {
97410 status = xs_sendpages(transport->sock,
97411 - NULL, 0, xdr, req->rq_bytes_sent);
97412 + NULL, 0, xdr, req->rq_bytes_sent,
97413 + zerocopy);
97414
97415 dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
97416 xdr->len - req->rq_bytes_sent, status);
97417 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
97418 index e7000be..e3b0ba7 100644
97419 --- a/net/sysctl_net.c
97420 +++ b/net/sysctl_net.c
97421 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
97422 kgid_t root_gid = make_kgid(net->user_ns, 0);
97423
97424 /* Allow network administrator to have same access as root. */
97425 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
97426 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
97427 uid_eq(root_uid, current_euid())) {
97428 int mode = (table->mode >> 6) & 7;
97429 return (mode << 6) | (mode << 3) | mode;
97430 diff --git a/net/tipc/link.c b/net/tipc/link.c
97431 index 0cc3d90..cc42021 100644
97432 --- a/net/tipc/link.c
97433 +++ b/net/tipc/link.c
97434 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
97435 struct tipc_msg fragm_hdr;
97436 struct sk_buff *buf, *buf_chain, *prev;
97437 u32 fragm_crs, fragm_rest, hsz, sect_rest;
97438 - const unchar *sect_crs;
97439 + const unchar __user *sect_crs;
97440 int curr_sect;
97441 u32 fragm_no;
97442 int res = 0;
97443 @@ -1207,7 +1207,7 @@ again:
97444
97445 if (!sect_rest) {
97446 sect_rest = msg_sect[++curr_sect].iov_len;
97447 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
97448 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
97449 }
97450
97451 if (sect_rest < fragm_rest)
97452 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
97453 index ced60e2..54eab6c 100644
97454 --- a/net/tipc/msg.c
97455 +++ b/net/tipc/msg.c
97456 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
97457 skb_copy_to_linear_data(*buf, hdr, hsz);
97458 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
97459 skb_copy_to_linear_data_offset(*buf, pos,
97460 - msg_sect[cnt].iov_base,
97461 + (const void __force_kernel *)msg_sect[cnt].iov_base,
97462 msg_sect[cnt].iov_len);
97463 pos += msg_sect[cnt].iov_len;
97464 }
97465 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
97466 index d38bb45..4fd6ac6 100644
97467 --- a/net/tipc/subscr.c
97468 +++ b/net/tipc/subscr.c
97469 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
97470 struct kvec msg_sect;
97471 int ret;
97472
97473 - msg_sect.iov_base = (void *)&sub->evt;
97474 + msg_sect.iov_base = (void __force_user *)&sub->evt;
97475 msg_sect.iov_len = sizeof(struct tipc_event);
97476
97477 sub->evt.event = htohl(event, sub->swap);
97478 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
97479 index c1f403b..b246d87 100644
97480 --- a/net/unix/af_unix.c
97481 +++ b/net/unix/af_unix.c
97482 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
97483 err = -ECONNREFUSED;
97484 if (!S_ISSOCK(inode->i_mode))
97485 goto put_fail;
97486 +
97487 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
97488 + err = -EACCES;
97489 + goto put_fail;
97490 + }
97491 +
97492 u = unix_find_socket_byinode(inode);
97493 if (!u)
97494 goto put_fail;
97495 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
97496 if (u) {
97497 struct dentry *dentry;
97498 dentry = unix_sk(u)->path.dentry;
97499 +
97500 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
97501 + err = -EPERM;
97502 + sock_put(u);
97503 + goto fail;
97504 + }
97505 +
97506 if (dentry)
97507 touch_atime(&unix_sk(u)->path);
97508 } else
97509 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
97510 */
97511 err = security_path_mknod(&path, dentry, mode, 0);
97512 if (!err) {
97513 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
97514 + err = -EACCES;
97515 + goto out;
97516 + }
97517 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
97518 if (!err) {
97519 res->mnt = mntget(path.mnt);
97520 res->dentry = dget(dentry);
97521 + gr_handle_create(dentry, path.mnt);
97522 }
97523 }
97524 +out:
97525 done_path_create(&path, dentry);
97526 return err;
97527 }
97528 @@ -2333,9 +2352,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97529 seq_puts(seq, "Num RefCount Protocol Flags Type St "
97530 "Inode Path\n");
97531 else {
97532 - struct sock *s = v;
97533 + struct sock *s = v, *peer;
97534 struct unix_sock *u = unix_sk(s);
97535 unix_state_lock(s);
97536 + peer = unix_peer(s);
97537 + unix_state_unlock(s);
97538 +
97539 + unix_state_double_lock(s, peer);
97540
97541 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
97542 s,
97543 @@ -2362,8 +2385,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97544 }
97545 for ( ; i < len; i++)
97546 seq_putc(seq, u->addr->name->sun_path[i]);
97547 - }
97548 - unix_state_unlock(s);
97549 + } else if (peer)
97550 + seq_printf(seq, " P%lu", sock_i_ino(peer));
97551 +
97552 + unix_state_double_unlock(s, peer);
97553 seq_putc(seq, '\n');
97554 }
97555
97556 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
97557 index b3d5150..ff3a837 100644
97558 --- a/net/unix/sysctl_net_unix.c
97559 +++ b/net/unix/sysctl_net_unix.c
97560 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
97561
97562 int __net_init unix_sysctl_register(struct net *net)
97563 {
97564 - struct ctl_table *table;
97565 + ctl_table_no_const *table;
97566
97567 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
97568 if (table == NULL)
97569 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
97570 index c8717c1..08539f5 100644
97571 --- a/net/wireless/wext-core.c
97572 +++ b/net/wireless/wext-core.c
97573 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97574 */
97575
97576 /* Support for very large requests */
97577 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
97578 - (user_length > descr->max_tokens)) {
97579 + if (user_length > descr->max_tokens) {
97580 /* Allow userspace to GET more than max so
97581 * we can support any size GET requests.
97582 * There is still a limit : -ENOMEM.
97583 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97584 }
97585 }
97586
97587 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
97588 - /*
97589 - * If this is a GET, but not NOMAX, it means that the extra
97590 - * data is not bounded by userspace, but by max_tokens. Thus
97591 - * set the length to max_tokens. This matches the extra data
97592 - * allocation.
97593 - * The driver should fill it with the number of tokens it
97594 - * provided, and it may check iwp->length rather than having
97595 - * knowledge of max_tokens. If the driver doesn't change the
97596 - * iwp->length, this ioctl just copies back max_token tokens
97597 - * filled with zeroes. Hopefully the driver isn't claiming
97598 - * them to be valid data.
97599 - */
97600 - iwp->length = descr->max_tokens;
97601 - }
97602 -
97603 err = handler(dev, info, (union iwreq_data *) iwp, extra);
97604
97605 iwp->length += essid_compat;
97606 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
97607 index 76e1873..4a12664 100644
97608 --- a/net/xfrm/xfrm_policy.c
97609 +++ b/net/xfrm/xfrm_policy.c
97610 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
97611 {
97612 policy->walk.dead = 1;
97613
97614 - atomic_inc(&policy->genid);
97615 + atomic_inc_unchecked(&policy->genid);
97616
97617 if (del_timer(&policy->polq.hold_timer))
97618 xfrm_pol_put(policy);
97619 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
97620 hlist_add_head(&policy->bydst, chain);
97621 xfrm_pol_hold(policy);
97622 net->xfrm.policy_count[dir]++;
97623 - atomic_inc(&flow_cache_genid);
97624 + atomic_inc_unchecked(&flow_cache_genid);
97625
97626 /* After previous checking, family can either be AF_INET or AF_INET6 */
97627 if (policy->family == AF_INET)
97628 @@ -1636,7 +1636,7 @@ free_dst:
97629 goto out;
97630 }
97631
97632 -static int inline
97633 +static inline int
97634 xfrm_dst_alloc_copy(void **target, const void *src, int size)
97635 {
97636 if (!*target) {
97637 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
97638 return 0;
97639 }
97640
97641 -static int inline
97642 +static inline int
97643 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97644 {
97645 #ifdef CONFIG_XFRM_SUB_POLICY
97646 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97647 #endif
97648 }
97649
97650 -static int inline
97651 +static inline int
97652 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
97653 {
97654 #ifdef CONFIG_XFRM_SUB_POLICY
97655 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
97656
97657 xdst->num_pols = num_pols;
97658 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
97659 - xdst->policy_genid = atomic_read(&pols[0]->genid);
97660 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
97661
97662 return xdst;
97663 }
97664 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
97665 }
97666 EXPORT_SYMBOL(xfrm_garbage_collect);
97667
97668 -static void xfrm_garbage_collect_deferred(struct net *net)
97669 +void xfrm_garbage_collect_deferred(struct net *net)
97670 {
97671 flow_cache_flush_deferred();
97672 __xfrm_garbage_collect(net);
97673 }
97674 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
97675
97676 static void xfrm_init_pmtu(struct dst_entry *dst)
97677 {
97678 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
97679 if (xdst->xfrm_genid != dst->xfrm->genid)
97680 return 0;
97681 if (xdst->num_pols > 0 &&
97682 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
97683 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
97684 return 0;
97685
97686 mtu = dst_mtu(dst->child);
97687 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
97688 dst_ops->link_failure = xfrm_link_failure;
97689 if (likely(dst_ops->neigh_lookup == NULL))
97690 dst_ops->neigh_lookup = xfrm_neigh_lookup;
97691 - if (likely(afinfo->garbage_collect == NULL))
97692 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
97693 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
97694 }
97695 spin_unlock(&xfrm_policy_afinfo_lock);
97696 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
97697 dst_ops->check = NULL;
97698 dst_ops->negative_advice = NULL;
97699 dst_ops->link_failure = NULL;
97700 - afinfo->garbage_collect = NULL;
97701 }
97702 return err;
97703 }
97704 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
97705 sizeof(pol->xfrm_vec[i].saddr));
97706 pol->xfrm_vec[i].encap_family = mp->new_family;
97707 /* flush bundles */
97708 - atomic_inc(&pol->genid);
97709 + atomic_inc_unchecked(&pol->genid);
97710 }
97711 }
97712
97713 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
97714 index b9c3f9e..4767526 100644
97715 --- a/net/xfrm/xfrm_state.c
97716 +++ b/net/xfrm/xfrm_state.c
97717 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
97718
97719 if (unlikely(afinfo == NULL))
97720 return -EAFNOSUPPORT;
97721 - typemap = afinfo->type_map;
97722 + typemap = (const struct xfrm_type **)afinfo->type_map;
97723 spin_lock_bh(&xfrm_type_lock);
97724
97725 - if (likely(typemap[type->proto] == NULL))
97726 + if (likely(typemap[type->proto] == NULL)) {
97727 + pax_open_kernel();
97728 typemap[type->proto] = type;
97729 - else
97730 + pax_close_kernel();
97731 + } else
97732 err = -EEXIST;
97733 spin_unlock_bh(&xfrm_type_lock);
97734 xfrm_state_put_afinfo(afinfo);
97735 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
97736
97737 if (unlikely(afinfo == NULL))
97738 return -EAFNOSUPPORT;
97739 - typemap = afinfo->type_map;
97740 + typemap = (const struct xfrm_type **)afinfo->type_map;
97741 spin_lock_bh(&xfrm_type_lock);
97742
97743 if (unlikely(typemap[type->proto] != type))
97744 err = -ENOENT;
97745 - else
97746 + else {
97747 + pax_open_kernel();
97748 typemap[type->proto] = NULL;
97749 + pax_close_kernel();
97750 + }
97751 spin_unlock_bh(&xfrm_type_lock);
97752 xfrm_state_put_afinfo(afinfo);
97753 return err;
97754 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97755 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97756 {
97757 struct xfrm_state_afinfo *afinfo;
97758 - const struct xfrm_type **typemap;
97759 const struct xfrm_type *type;
97760 int modload_attempted = 0;
97761
97762 @@ -219,9 +223,8 @@ retry:
97763 afinfo = xfrm_state_get_afinfo(family);
97764 if (unlikely(afinfo == NULL))
97765 return NULL;
97766 - typemap = afinfo->type_map;
97767
97768 - type = typemap[proto];
97769 + type = afinfo->type_map[proto];
97770 if (unlikely(type && !try_module_get(type->owner)))
97771 type = NULL;
97772 if (!type && !modload_attempted) {
97773 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97774 return -EAFNOSUPPORT;
97775
97776 err = -EEXIST;
97777 - modemap = afinfo->mode_map;
97778 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97779 spin_lock_bh(&xfrm_mode_lock);
97780 if (modemap[mode->encap])
97781 goto out;
97782 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97783 if (!try_module_get(afinfo->owner))
97784 goto out;
97785
97786 - mode->afinfo = afinfo;
97787 + pax_open_kernel();
97788 + *(const void **)&mode->afinfo = afinfo;
97789 modemap[mode->encap] = mode;
97790 + pax_close_kernel();
97791 err = 0;
97792
97793 out:
97794 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97795 return -EAFNOSUPPORT;
97796
97797 err = -ENOENT;
97798 - modemap = afinfo->mode_map;
97799 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97800 spin_lock_bh(&xfrm_mode_lock);
97801 if (likely(modemap[mode->encap] == mode)) {
97802 + pax_open_kernel();
97803 modemap[mode->encap] = NULL;
97804 + pax_close_kernel();
97805 module_put(mode->afinfo->owner);
97806 err = 0;
97807 }
97808 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97809 u32 xfrm_get_acqseq(void)
97810 {
97811 u32 res;
97812 - static atomic_t acqseq;
97813 + static atomic_unchecked_t acqseq;
97814
97815 do {
97816 - res = atomic_inc_return(&acqseq);
97817 + res = atomic_inc_return_unchecked(&acqseq);
97818 } while (!res);
97819
97820 return res;
97821 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97822 index 05a6e3d..6716ec9 100644
97823 --- a/net/xfrm/xfrm_sysctl.c
97824 +++ b/net/xfrm/xfrm_sysctl.c
97825 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97826
97827 int __net_init xfrm_sysctl_init(struct net *net)
97828 {
97829 - struct ctl_table *table;
97830 + ctl_table_no_const *table;
97831
97832 __xfrm_sysctl_init(net);
97833
97834 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97835 index d5d859c..781cbcb 100644
97836 --- a/scripts/Makefile.build
97837 +++ b/scripts/Makefile.build
97838 @@ -111,7 +111,7 @@ endif
97839 endif
97840
97841 # Do not include host rules unless needed
97842 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97843 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97844 include scripts/Makefile.host
97845 endif
97846
97847 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97848 index 686cb0d..9d653bf 100644
97849 --- a/scripts/Makefile.clean
97850 +++ b/scripts/Makefile.clean
97851 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97852 __clean-files := $(extra-y) $(always) \
97853 $(targets) $(clean-files) \
97854 $(host-progs) \
97855 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97856 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97857 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97858
97859 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97860
97861 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97862 index 1ac414f..38575f7 100644
97863 --- a/scripts/Makefile.host
97864 +++ b/scripts/Makefile.host
97865 @@ -31,6 +31,8 @@
97866 # Note: Shared libraries consisting of C++ files are not supported
97867
97868 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97869 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97870 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97871
97872 # C code
97873 # Executables compiled from a single .c file
97874 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97875 # Shared libaries (only .c supported)
97876 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97877 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97878 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97879 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97880 # Remove .so files from "xxx-objs"
97881 host-cobjs := $(filter-out %.so,$(host-cobjs))
97882 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97883
97884 -#Object (.o) files used by the shared libaries
97885 +# Object (.o) files used by the shared libaries
97886 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97887 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97888
97889 # output directory for programs/.o files
97890 # hostprogs-y := tools/build may have been specified. Retrieve directory
97891 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97892 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97893 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97894 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97895 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97896 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97897 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97898 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97899
97900 obj-dirs += $(host-objdirs)
97901 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97902 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97903 $(call if_changed_dep,host-cshobjs)
97904
97905 +# Compile .c file, create position independent .o file
97906 +# host-cxxshobjs -> .o
97907 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97908 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97909 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97910 + $(call if_changed_dep,host-cxxshobjs)
97911 +
97912 # Link a shared library, based on position independent .o files
97913 # *.o -> .so shared library (host-cshlib)
97914 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97915 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97916 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97917 $(call if_changed,host-cshlib)
97918
97919 +# Link a shared library, based on position independent .o files
97920 +# *.o -> .so shared library (host-cxxshlib)
97921 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97922 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97923 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97924 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97925 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97926 + $(call if_changed,host-cxxshlib)
97927 +
97928 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97929 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97930 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97931
97932 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97933 index 078fe1d..fbdb363 100644
97934 --- a/scripts/basic/fixdep.c
97935 +++ b/scripts/basic/fixdep.c
97936 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97937 /*
97938 * Lookup a value in the configuration string.
97939 */
97940 -static int is_defined_config(const char *name, int len, unsigned int hash)
97941 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97942 {
97943 struct item *aux;
97944
97945 @@ -211,10 +211,10 @@ static void clear_config(void)
97946 /*
97947 * Record the use of a CONFIG_* word.
97948 */
97949 -static void use_config(const char *m, int slen)
97950 +static void use_config(const char *m, unsigned int slen)
97951 {
97952 unsigned int hash = strhash(m, slen);
97953 - int c, i;
97954 + unsigned int c, i;
97955
97956 if (is_defined_config(m, slen, hash))
97957 return;
97958 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97959
97960 static void parse_config_file(const char *map, size_t len)
97961 {
97962 - const int *end = (const int *) (map + len);
97963 + const unsigned int *end = (const unsigned int *) (map + len);
97964 /* start at +1, so that p can never be < map */
97965 - const int *m = (const int *) map + 1;
97966 + const unsigned int *m = (const unsigned int *) map + 1;
97967 const char *p, *q;
97968
97969 for (; m < end; m++) {
97970 @@ -435,7 +435,7 @@ static void print_deps(void)
97971 static void traps(void)
97972 {
97973 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97974 - int *p = (int *)test;
97975 + unsigned int *p = (unsigned int *)test;
97976
97977 if (*p != INT_CONF) {
97978 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97979 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97980 new file mode 100644
97981 index 0000000..5e0222d
97982 --- /dev/null
97983 +++ b/scripts/gcc-plugin.sh
97984 @@ -0,0 +1,17 @@
97985 +#!/bin/bash
97986 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97987 +#include "gcc-plugin.h"
97988 +#include "tree.h"
97989 +#include "tm.h"
97990 +#include "rtl.h"
97991 +#ifdef ENABLE_BUILD_WITH_CXX
97992 +#warning $2
97993 +#else
97994 +#warning $1
97995 +#endif
97996 +EOF`
97997 +if [ $? -eq 0 ]
97998 +then
97999 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
98000 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
98001 +fi
98002 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
98003 index 5de5660..d3deb89 100644
98004 --- a/scripts/headers_install.sh
98005 +++ b/scripts/headers_install.sh
98006 @@ -32,6 +32,7 @@ do
98007 FILE="$(basename "$i")"
98008 sed -r \
98009 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
98010 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
98011 -e 's/__attribute_const__([ \t]|$)/\1/g' \
98012 -e 's@^#include <linux/compiler.h>@@' \
98013 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
98014 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
98015 index 32b10f5..64eeb30 100644
98016 --- a/scripts/link-vmlinux.sh
98017 +++ b/scripts/link-vmlinux.sh
98018 @@ -82,7 +82,9 @@ kallsyms()
98019 kallsymopt="${kallsymopt} --all-symbols"
98020 fi
98021
98022 - kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98023 + if [ -z "${CONFIG_X86_32}" ] || [ -z "${CONFIG_PAX_KERNEXEC}" ]; then
98024 + kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98025 + fi
98026
98027 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
98028 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
98029 @@ -160,7 +162,7 @@ else
98030 fi;
98031
98032 # final build of init/
98033 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
98034 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
98035
98036 kallsymso=""
98037 kallsyms_vmlinux=""
98038 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
98039 index 2370863..212fbca 100644
98040 --- a/scripts/mod/file2alias.c
98041 +++ b/scripts/mod/file2alias.c
98042 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
98043 unsigned long size, unsigned long id_size,
98044 void *symval)
98045 {
98046 - int i;
98047 + unsigned int i;
98048
98049 if (size % id_size || size < id_size) {
98050 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
98051 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
98052 /* USB is special because the bcdDevice can be matched against a numeric range */
98053 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
98054 static void do_usb_entry(void *symval,
98055 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
98056 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
98057 unsigned char range_lo, unsigned char range_hi,
98058 unsigned char max, struct module *mod)
98059 {
98060 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
98061 {
98062 unsigned int devlo, devhi;
98063 unsigned char chi, clo, max;
98064 - int ndigits;
98065 + unsigned int ndigits;
98066
98067 DEF_FIELD(symval, usb_device_id, match_flags);
98068 DEF_FIELD(symval, usb_device_id, idVendor);
98069 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
98070 for (i = 0; i < count; i++) {
98071 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
98072 char acpi_id[sizeof(*id)];
98073 - int j;
98074 + unsigned int j;
98075
98076 buf_printf(&mod->dev_table_buf,
98077 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
98078 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98079
98080 for (j = 0; j < PNP_MAX_DEVICES; j++) {
98081 const char *id = (char *)(*devs)[j].id;
98082 - int i2, j2;
98083 + unsigned int i2, j2;
98084 int dup = 0;
98085
98086 if (!id[0])
98087 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98088 /* add an individual alias for every device entry */
98089 if (!dup) {
98090 char acpi_id[PNP_ID_LEN];
98091 - int k;
98092 + unsigned int k;
98093
98094 buf_printf(&mod->dev_table_buf,
98095 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
98096 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
98097 static int do_dmi_entry(const char *filename, void *symval,
98098 char *alias)
98099 {
98100 - int i, j;
98101 + unsigned int i, j;
98102 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
98103 sprintf(alias, "dmi*");
98104
98105 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
98106 index 8247979..815ec76 100644
98107 --- a/scripts/mod/modpost.c
98108 +++ b/scripts/mod/modpost.c
98109 @@ -931,6 +931,7 @@ enum mismatch {
98110 ANY_INIT_TO_ANY_EXIT,
98111 ANY_EXIT_TO_ANY_INIT,
98112 EXPORT_TO_INIT_EXIT,
98113 + DATA_TO_TEXT
98114 };
98115
98116 struct sectioncheck {
98117 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
98118 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
98119 .mismatch = EXPORT_TO_INIT_EXIT,
98120 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
98121 +},
98122 +/* Do not reference code from writable data */
98123 +{
98124 + .fromsec = { DATA_SECTIONS, NULL },
98125 + .tosec = { TEXT_SECTIONS, NULL },
98126 + .mismatch = DATA_TO_TEXT
98127 }
98128 };
98129
98130 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
98131 continue;
98132 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
98133 continue;
98134 - if (sym->st_value == addr)
98135 - return sym;
98136 /* Find a symbol nearby - addr are maybe negative */
98137 d = sym->st_value - addr;
98138 + if (d == 0)
98139 + return sym;
98140 if (d < 0)
98141 d = addr - sym->st_value;
98142 if (d < distance) {
98143 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
98144 tosym, prl_to, prl_to, tosym);
98145 free(prl_to);
98146 break;
98147 + case DATA_TO_TEXT:
98148 +#if 0
98149 + fprintf(stderr,
98150 + "The %s %s:%s references\n"
98151 + "the %s %s:%s%s\n",
98152 + from, fromsec, fromsym, to, tosec, tosym, to_p);
98153 +#endif
98154 + break;
98155 }
98156 fprintf(stderr, "\n");
98157 }
98158 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
98159 static void check_sec_ref(struct module *mod, const char *modname,
98160 struct elf_info *elf)
98161 {
98162 - int i;
98163 + unsigned int i;
98164 Elf_Shdr *sechdrs = elf->sechdrs;
98165
98166 /* Walk through all sections */
98167 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
98168 va_end(ap);
98169 }
98170
98171 -void buf_write(struct buffer *buf, const char *s, int len)
98172 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
98173 {
98174 if (buf->size - buf->pos < len) {
98175 buf->size += len + SZ;
98176 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
98177 if (fstat(fileno(file), &st) < 0)
98178 goto close_write;
98179
98180 - if (st.st_size != b->pos)
98181 + if (st.st_size != (off_t)b->pos)
98182 goto close_write;
98183
98184 tmp = NOFAIL(malloc(b->pos));
98185 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
98186 index 51207e4..f7d603d 100644
98187 --- a/scripts/mod/modpost.h
98188 +++ b/scripts/mod/modpost.h
98189 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
98190
98191 struct buffer {
98192 char *p;
98193 - int pos;
98194 - int size;
98195 + unsigned int pos;
98196 + unsigned int size;
98197 };
98198
98199 void __attribute__((format(printf, 2, 3)))
98200 buf_printf(struct buffer *buf, const char *fmt, ...);
98201
98202 void
98203 -buf_write(struct buffer *buf, const char *s, int len);
98204 +buf_write(struct buffer *buf, const char *s, unsigned int len);
98205
98206 struct module {
98207 struct module *next;
98208 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
98209 index 9dfcd6d..099068e 100644
98210 --- a/scripts/mod/sumversion.c
98211 +++ b/scripts/mod/sumversion.c
98212 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
98213 goto out;
98214 }
98215
98216 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
98217 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
98218 warn("writing sum in %s failed: %s\n",
98219 filename, strerror(errno));
98220 goto out;
98221 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
98222 index 0865b3e..7235dd4 100644
98223 --- a/scripts/module-common.lds
98224 +++ b/scripts/module-common.lds
98225 @@ -6,6 +6,10 @@
98226 SECTIONS {
98227 /DISCARD/ : { *(.discard) }
98228
98229 + .rodata : {
98230 + *(.rodata) *(.rodata.*)
98231 + *(.data..read_only)
98232 + }
98233 __ksymtab : { *(SORT(___ksymtab+*)) }
98234 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
98235 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
98236 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
98237 index 90e521f..e9eaf8f 100644
98238 --- a/scripts/package/builddeb
98239 +++ b/scripts/package/builddeb
98240 @@ -281,6 +281,7 @@ fi
98241 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
98242 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
98243 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
98244 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
98245 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
98246 mkdir -p "$destdir"
98247 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
98248 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
98249 index 68bb4ef..2f419e1 100644
98250 --- a/scripts/pnmtologo.c
98251 +++ b/scripts/pnmtologo.c
98252 @@ -244,14 +244,14 @@ static void write_header(void)
98253 fprintf(out, " * Linux logo %s\n", logoname);
98254 fputs(" */\n\n", out);
98255 fputs("#include <linux/linux_logo.h>\n\n", out);
98256 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
98257 + fprintf(out, "static unsigned char %s_data[] = {\n",
98258 logoname);
98259 }
98260
98261 static void write_footer(void)
98262 {
98263 fputs("\n};\n\n", out);
98264 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
98265 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
98266 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
98267 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
98268 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
98269 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
98270 fputs("\n};\n\n", out);
98271
98272 /* write logo clut */
98273 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
98274 + fprintf(out, "static unsigned char %s_clut[] = {\n",
98275 logoname);
98276 write_hex_cnt = 0;
98277 for (i = 0; i < logo_clutsize; i++) {
98278 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
98279 index f5eb43d..1814de8 100644
98280 --- a/scripts/sortextable.h
98281 +++ b/scripts/sortextable.h
98282 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98283 const char *secstrtab;
98284 const char *strtab;
98285 char *extab_image;
98286 - int extab_index = 0;
98287 - int i;
98288 - int idx;
98289 + unsigned int extab_index = 0;
98290 + unsigned int i;
98291 + unsigned int idx;
98292
98293 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
98294 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
98295 diff --git a/security/Kconfig b/security/Kconfig
98296 index e9c6ac7..031a726 100644
98297 --- a/security/Kconfig
98298 +++ b/security/Kconfig
98299 @@ -4,6 +4,960 @@
98300
98301 menu "Security options"
98302
98303 +menu "Grsecurity"
98304 +
98305 + config ARCH_TRACK_EXEC_LIMIT
98306 + bool
98307 +
98308 + config PAX_KERNEXEC_PLUGIN
98309 + bool
98310 +
98311 + config PAX_PER_CPU_PGD
98312 + bool
98313 +
98314 + config TASK_SIZE_MAX_SHIFT
98315 + int
98316 + depends on X86_64
98317 + default 47 if !PAX_PER_CPU_PGD
98318 + default 42 if PAX_PER_CPU_PGD
98319 +
98320 + config PAX_ENABLE_PAE
98321 + bool
98322 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
98323 +
98324 + config PAX_USERCOPY_SLABS
98325 + bool
98326 +
98327 +config GRKERNSEC
98328 + bool "Grsecurity"
98329 + select CRYPTO
98330 + select CRYPTO_SHA256
98331 + select PROC_FS
98332 + select STOP_MACHINE
98333 + select TTY
98334 + select DEBUG_LIST
98335 + help
98336 + If you say Y here, you will be able to configure many features
98337 + that will enhance the security of your system. It is highly
98338 + recommended that you say Y here and read through the help
98339 + for each option so that you fully understand the features and
98340 + can evaluate their usefulness for your machine.
98341 +
98342 +choice
98343 + prompt "Configuration Method"
98344 + depends on GRKERNSEC
98345 + default GRKERNSEC_CONFIG_CUSTOM
98346 + help
98347 +
98348 +config GRKERNSEC_CONFIG_AUTO
98349 + bool "Automatic"
98350 + help
98351 + If you choose this configuration method, you'll be able to answer a small
98352 + number of simple questions about how you plan to use this kernel.
98353 + The settings of grsecurity and PaX will be automatically configured for
98354 + the highest commonly-used settings within the provided constraints.
98355 +
98356 + If you require additional configuration, custom changes can still be made
98357 + from the "custom configuration" menu.
98358 +
98359 +config GRKERNSEC_CONFIG_CUSTOM
98360 + bool "Custom"
98361 + help
98362 + If you choose this configuration method, you'll be able to configure all
98363 + grsecurity and PaX settings manually. Via this method, no options are
98364 + automatically enabled.
98365 +
98366 +endchoice
98367 +
98368 +choice
98369 + prompt "Usage Type"
98370 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98371 + default GRKERNSEC_CONFIG_SERVER
98372 + help
98373 +
98374 +config GRKERNSEC_CONFIG_SERVER
98375 + bool "Server"
98376 + help
98377 + Choose this option if you plan to use this kernel on a server.
98378 +
98379 +config GRKERNSEC_CONFIG_DESKTOP
98380 + bool "Desktop"
98381 + help
98382 + Choose this option if you plan to use this kernel on a desktop.
98383 +
98384 +endchoice
98385 +
98386 +choice
98387 + prompt "Virtualization Type"
98388 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
98389 + default GRKERNSEC_CONFIG_VIRT_NONE
98390 + help
98391 +
98392 +config GRKERNSEC_CONFIG_VIRT_NONE
98393 + bool "None"
98394 + help
98395 + Choose this option if this kernel will be run on bare metal.
98396 +
98397 +config GRKERNSEC_CONFIG_VIRT_GUEST
98398 + bool "Guest"
98399 + help
98400 + Choose this option if this kernel will be run as a VM guest.
98401 +
98402 +config GRKERNSEC_CONFIG_VIRT_HOST
98403 + bool "Host"
98404 + help
98405 + Choose this option if this kernel will be run as a VM host.
98406 +
98407 +endchoice
98408 +
98409 +choice
98410 + prompt "Virtualization Hardware"
98411 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98412 + help
98413 +
98414 +config GRKERNSEC_CONFIG_VIRT_EPT
98415 + bool "EPT/RVI Processor Support"
98416 + depends on X86
98417 + help
98418 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
98419 + hardware virtualization. This allows for additional kernel hardening protections
98420 + to operate without additional performance impact.
98421 +
98422 + To see if your Intel processor supports EPT, see:
98423 + http://ark.intel.com/Products/VirtualizationTechnology
98424 + (Most Core i3/5/7 support EPT)
98425 +
98426 + To see if your AMD processor supports RVI, see:
98427 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
98428 +
98429 +config GRKERNSEC_CONFIG_VIRT_SOFT
98430 + bool "First-gen/No Hardware Virtualization"
98431 + help
98432 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
98433 + support hardware virtualization or doesn't support the EPT/RVI extensions.
98434 +
98435 +endchoice
98436 +
98437 +choice
98438 + prompt "Virtualization Software"
98439 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98440 + help
98441 +
98442 +config GRKERNSEC_CONFIG_VIRT_XEN
98443 + bool "Xen"
98444 + help
98445 + Choose this option if this kernel is running as a Xen guest or host.
98446 +
98447 +config GRKERNSEC_CONFIG_VIRT_VMWARE
98448 + bool "VMWare"
98449 + help
98450 + Choose this option if this kernel is running as a VMWare guest or host.
98451 +
98452 +config GRKERNSEC_CONFIG_VIRT_KVM
98453 + bool "KVM"
98454 + help
98455 + Choose this option if this kernel is running as a KVM guest or host.
98456 +
98457 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
98458 + bool "VirtualBox"
98459 + help
98460 + Choose this option if this kernel is running as a VirtualBox guest or host.
98461 +
98462 +endchoice
98463 +
98464 +choice
98465 + prompt "Required Priorities"
98466 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98467 + default GRKERNSEC_CONFIG_PRIORITY_PERF
98468 + help
98469 +
98470 +config GRKERNSEC_CONFIG_PRIORITY_PERF
98471 + bool "Performance"
98472 + help
98473 + Choose this option if performance is of highest priority for this deployment
98474 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
98475 + clearing of structures intended for userland, and freed memory sanitizing will
98476 + be disabled.
98477 +
98478 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
98479 + bool "Security"
98480 + help
98481 + Choose this option if security is of highest priority for this deployment of
98482 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
98483 + for userland, and freed memory sanitizing will be enabled for this kernel.
98484 + In a worst-case scenario, these features can introduce a 20% performance hit
98485 + (UDEREF on x64 contributing half of this hit).
98486 +
98487 +endchoice
98488 +
98489 +menu "Default Special Groups"
98490 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98491 +
98492 +config GRKERNSEC_PROC_GID
98493 + int "GID exempted from /proc restrictions"
98494 + default 1001
98495 + help
98496 + Setting this GID determines which group will be exempted from
98497 + grsecurity's /proc restrictions, allowing users of the specified
98498 + group to view network statistics and the existence of other users'
98499 + processes on the system. This GID may also be chosen at boot time
98500 + via "grsec_proc_gid=" on the kernel commandline.
98501 +
98502 +config GRKERNSEC_TPE_UNTRUSTED_GID
98503 + int "GID for TPE-untrusted users"
98504 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
98505 + default 1005
98506 + help
98507 + Setting this GID determines which group untrusted users should
98508 + be added to. These users will be placed under grsecurity's Trusted Path
98509 + Execution mechanism, preventing them from executing their own binaries.
98510 + The users will only be able to execute binaries in directories owned and
98511 + writable only by the root user. If the sysctl option is enabled, a sysctl
98512 + option with name "tpe_gid" is created.
98513 +
98514 +config GRKERNSEC_TPE_TRUSTED_GID
98515 + int "GID for TPE-trusted users"
98516 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
98517 + default 1005
98518 + help
98519 + Setting this GID determines what group TPE restrictions will be
98520 + *disabled* for. If the sysctl option is enabled, a sysctl option
98521 + with name "tpe_gid" is created.
98522 +
98523 +config GRKERNSEC_SYMLINKOWN_GID
98524 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
98525 + depends on GRKERNSEC_CONFIG_SERVER
98526 + default 1006
98527 + help
98528 + Setting this GID determines what group kernel-enforced
98529 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
98530 + is enabled, a sysctl option with name "symlinkown_gid" is created.
98531 +
98532 +
98533 +endmenu
98534 +
98535 +menu "Customize Configuration"
98536 +depends on GRKERNSEC
98537 +
98538 +menu "PaX"
98539 +
98540 +config PAX
98541 + bool "Enable various PaX features"
98542 + default y if GRKERNSEC_CONFIG_AUTO
98543 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
98544 + help
98545 + This allows you to enable various PaX features. PaX adds
98546 + intrusion prevention mechanisms to the kernel that reduce
98547 + the risks posed by exploitable memory corruption bugs.
98548 +
98549 +menu "PaX Control"
98550 + depends on PAX
98551 +
98552 +config PAX_SOFTMODE
98553 + bool 'Support soft mode'
98554 + help
98555 + Enabling this option will allow you to run PaX in soft mode, that
98556 + is, PaX features will not be enforced by default, only on executables
98557 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
98558 + support as they are the only way to mark executables for soft mode use.
98559 +
98560 + Soft mode can be activated by using the "pax_softmode=1" kernel command
98561 + line option on boot. Furthermore you can control various PaX features
98562 + at runtime via the entries in /proc/sys/kernel/pax.
98563 +
98564 +config PAX_EI_PAX
98565 + bool 'Use legacy ELF header marking'
98566 + default y if GRKERNSEC_CONFIG_AUTO
98567 + help
98568 + Enabling this option will allow you to control PaX features on
98569 + a per executable basis via the 'chpax' utility available at
98570 + http://pax.grsecurity.net/. The control flags will be read from
98571 + an otherwise reserved part of the ELF header. This marking has
98572 + numerous drawbacks (no support for soft-mode, toolchain does not
98573 + know about the non-standard use of the ELF header) therefore it
98574 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
98575 + support.
98576 +
98577 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
98578 + support as well, they will override the legacy EI_PAX marks.
98579 +
98580 + If you enable none of the marking options then all applications
98581 + will run with PaX enabled on them by default.
98582 +
98583 +config PAX_PT_PAX_FLAGS
98584 + bool 'Use ELF program header marking'
98585 + default y if GRKERNSEC_CONFIG_AUTO
98586 + help
98587 + Enabling this option will allow you to control PaX features on
98588 + a per executable basis via the 'paxctl' utility available at
98589 + http://pax.grsecurity.net/. The control flags will be read from
98590 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
98591 + has the benefits of supporting both soft mode and being fully
98592 + integrated into the toolchain (the binutils patch is available
98593 + from http://pax.grsecurity.net).
98594 +
98595 + Note that if you enable the legacy EI_PAX marking support as well,
98596 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
98597 +
98598 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98599 + must make sure that the marks are the same if a binary has both marks.
98600 +
98601 + If you enable none of the marking options then all applications
98602 + will run with PaX enabled on them by default.
98603 +
98604 +config PAX_XATTR_PAX_FLAGS
98605 + bool 'Use filesystem extended attributes marking'
98606 + default y if GRKERNSEC_CONFIG_AUTO
98607 + select CIFS_XATTR if CIFS
98608 + select EXT2_FS_XATTR if EXT2_FS
98609 + select EXT3_FS_XATTR if EXT3_FS
98610 + select EXT4_FS_XATTR if EXT4_FS
98611 + select JFFS2_FS_XATTR if JFFS2_FS
98612 + select REISERFS_FS_XATTR if REISERFS_FS
98613 + select SQUASHFS_XATTR if SQUASHFS
98614 + select TMPFS_XATTR if TMPFS
98615 + select UBIFS_FS_XATTR if UBIFS_FS
98616 + help
98617 + Enabling this option will allow you to control PaX features on
98618 + a per executable basis via the 'setfattr' utility. The control
98619 + flags will be read from the user.pax.flags extended attribute of
98620 + the file. This marking has the benefit of supporting binary-only
98621 + applications that self-check themselves (e.g., skype) and would
98622 + not tolerate chpax/paxctl changes. The main drawback is that
98623 + extended attributes are not supported by some filesystems (e.g.,
98624 + isofs, udf, vfat) so copying files through such filesystems will
98625 + lose the extended attributes and these PaX markings.
98626 +
98627 + Note that if you enable the legacy EI_PAX marking support as well,
98628 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
98629 +
98630 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98631 + must make sure that the marks are the same if a binary has both marks.
98632 +
98633 + If you enable none of the marking options then all applications
98634 + will run with PaX enabled on them by default.
98635 +
98636 +choice
98637 + prompt 'MAC system integration'
98638 + default PAX_HAVE_ACL_FLAGS
98639 + help
98640 + Mandatory Access Control systems have the option of controlling
98641 + PaX flags on a per executable basis, choose the method supported
98642 + by your particular system.
98643 +
98644 + - "none": if your MAC system does not interact with PaX,
98645 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
98646 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
98647 +
98648 + NOTE: this option is for developers/integrators only.
98649 +
98650 + config PAX_NO_ACL_FLAGS
98651 + bool 'none'
98652 +
98653 + config PAX_HAVE_ACL_FLAGS
98654 + bool 'direct'
98655 +
98656 + config PAX_HOOK_ACL_FLAGS
98657 + bool 'hook'
98658 +endchoice
98659 +
98660 +endmenu
98661 +
98662 +menu "Non-executable pages"
98663 + depends on PAX
98664 +
98665 +config PAX_NOEXEC
98666 + bool "Enforce non-executable pages"
98667 + default y if GRKERNSEC_CONFIG_AUTO
98668 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
98669 + help
98670 + By design some architectures do not allow for protecting memory
98671 + pages against execution or even if they do, Linux does not make
98672 + use of this feature. In practice this means that if a page is
98673 + readable (such as the stack or heap) it is also executable.
98674 +
98675 + There is a well known exploit technique that makes use of this
98676 + fact and a common programming mistake where an attacker can
98677 + introduce code of his choice somewhere in the attacked program's
98678 + memory (typically the stack or the heap) and then execute it.
98679 +
98680 + If the attacked program was running with different (typically
98681 + higher) privileges than that of the attacker, then he can elevate
98682 + his own privilege level (e.g. get a root shell, write to files for
98683 + which he does not have write access to, etc).
98684 +
98685 + Enabling this option will let you choose from various features
98686 + that prevent the injection and execution of 'foreign' code in
98687 + a program.
98688 +
98689 + This will also break programs that rely on the old behaviour and
98690 + expect that dynamically allocated memory via the malloc() family
98691 + of functions is executable (which it is not). Notable examples
98692 + are the XFree86 4.x server, the java runtime and wine.
98693 +
98694 +config PAX_PAGEEXEC
98695 + bool "Paging based non-executable pages"
98696 + default y if GRKERNSEC_CONFIG_AUTO
98697 + 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)
98698 + select ARCH_TRACK_EXEC_LIMIT if X86_32
98699 + help
98700 + This implementation is based on the paging feature of the CPU.
98701 + On i386 without hardware non-executable bit support there is a
98702 + variable but usually low performance impact, however on Intel's
98703 + P4 core based CPUs it is very high so you should not enable this
98704 + for kernels meant to be used on such CPUs.
98705 +
98706 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
98707 + with hardware non-executable bit support there is no performance
98708 + impact, on ppc the impact is negligible.
98709 +
98710 + Note that several architectures require various emulations due to
98711 + badly designed userland ABIs, this will cause a performance impact
98712 + but will disappear as soon as userland is fixed. For example, ppc
98713 + userland MUST have been built with secure-plt by a recent toolchain.
98714 +
98715 +config PAX_SEGMEXEC
98716 + bool "Segmentation based non-executable pages"
98717 + default y if GRKERNSEC_CONFIG_AUTO
98718 + depends on PAX_NOEXEC && X86_32
98719 + help
98720 + This implementation is based on the segmentation feature of the
98721 + CPU and has a very small performance impact, however applications
98722 + will be limited to a 1.5 GB address space instead of the normal
98723 + 3 GB.
98724 +
98725 +config PAX_EMUTRAMP
98726 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98727 + default y if PARISC
98728 + help
98729 + There are some programs and libraries that for one reason or
98730 + another attempt to execute special small code snippets from
98731 + non-executable memory pages. Most notable examples are the
98732 + signal handler return code generated by the kernel itself and
98733 + the GCC trampolines.
98734 +
98735 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98736 + such programs will no longer work under your kernel.
98737 +
98738 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98739 + utilities to enable trampoline emulation for the affected programs
98740 + yet still have the protection provided by the non-executable pages.
98741 +
98742 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98743 + your system will not even boot.
98744 +
98745 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98746 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98747 + for the affected files.
98748 +
98749 + NOTE: enabling this feature *may* open up a loophole in the
98750 + protection provided by non-executable pages that an attacker
98751 + could abuse. Therefore the best solution is to not have any
98752 + files on your system that would require this option. This can
98753 + be achieved by not using libc5 (which relies on the kernel
98754 + signal handler return code) and not using or rewriting programs
98755 + that make use of the nested function implementation of GCC.
98756 + Skilled users can just fix GCC itself so that it implements
98757 + nested function calls in a way that does not interfere with PaX.
98758 +
98759 +config PAX_EMUSIGRT
98760 + bool "Automatically emulate sigreturn trampolines"
98761 + depends on PAX_EMUTRAMP && PARISC
98762 + default y
98763 + help
98764 + Enabling this option will have the kernel automatically detect
98765 + and emulate signal return trampolines executing on the stack
98766 + that would otherwise lead to task termination.
98767 +
98768 + This solution is intended as a temporary one for users with
98769 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98770 + Modula-3 runtime, etc) or executables linked to such, basically
98771 + everything that does not specify its own SA_RESTORER function in
98772 + normal executable memory like glibc 2.1+ does.
98773 +
98774 + On parisc you MUST enable this option, otherwise your system will
98775 + not even boot.
98776 +
98777 + NOTE: this feature cannot be disabled on a per executable basis
98778 + and since it *does* open up a loophole in the protection provided
98779 + by non-executable pages, the best solution is to not have any
98780 + files on your system that would require this option.
98781 +
98782 +config PAX_MPROTECT
98783 + bool "Restrict mprotect()"
98784 + default y if GRKERNSEC_CONFIG_AUTO
98785 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98786 + help
98787 + Enabling this option will prevent programs from
98788 + - changing the executable status of memory pages that were
98789 + not originally created as executable,
98790 + - making read-only executable pages writable again,
98791 + - creating executable pages from anonymous memory,
98792 + - making read-only-after-relocations (RELRO) data pages writable again.
98793 +
98794 + You should say Y here to complete the protection provided by
98795 + the enforcement of non-executable pages.
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_MPROTECT_COMPAT
98801 + bool "Use legacy/compat protection demoting (read help)"
98802 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98803 + depends on PAX_MPROTECT
98804 + help
98805 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98806 + by sending the proper error code to the application. For some broken
98807 + userland, this can cause problems with Python or other applications. The
98808 + current implementation however allows for applications like clamav to
98809 + detect if JIT compilation/execution is allowed and to fall back gracefully
98810 + to an interpreter-based mode if it does not. While we encourage everyone
98811 + to use the current implementation as-is and push upstream to fix broken
98812 + userland (note that the RWX logging option can assist with this), in some
98813 + environments this may not be possible. Having to disable MPROTECT
98814 + completely on certain binaries reduces the security benefit of PaX,
98815 + so this option is provided for those environments to revert to the old
98816 + behavior.
98817 +
98818 +config PAX_ELFRELOCS
98819 + bool "Allow ELF text relocations (read help)"
98820 + depends on PAX_MPROTECT
98821 + default n
98822 + help
98823 + Non-executable pages and mprotect() restrictions are effective
98824 + in preventing the introduction of new executable code into an
98825 + attacked task's address space. There remain only two venues
98826 + for this kind of attack: if the attacker can execute already
98827 + existing code in the attacked task then he can either have it
98828 + create and mmap() a file containing his code or have it mmap()
98829 + an already existing ELF library that does not have position
98830 + independent code in it and use mprotect() on it to make it
98831 + writable and copy his code there. While protecting against
98832 + the former approach is beyond PaX, the latter can be prevented
98833 + by having only PIC ELF libraries on one's system (which do not
98834 + need to relocate their code). If you are sure this is your case,
98835 + as is the case with all modern Linux distributions, then leave
98836 + this option disabled. You should say 'n' here.
98837 +
98838 +config PAX_ETEXECRELOCS
98839 + bool "Allow ELF ET_EXEC text relocations"
98840 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98841 + select PAX_ELFRELOCS
98842 + default y
98843 + help
98844 + On some architectures there are incorrectly created applications
98845 + that require text relocations and would not work without enabling
98846 + this option. If you are an alpha, ia64 or parisc user, you should
98847 + enable this option and disable it once you have made sure that
98848 + none of your applications need it.
98849 +
98850 +config PAX_EMUPLT
98851 + bool "Automatically emulate ELF PLT"
98852 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98853 + default y
98854 + help
98855 + Enabling this option will have the kernel automatically detect
98856 + and emulate the Procedure Linkage Table entries in ELF files.
98857 + On some architectures such entries are in writable memory, and
98858 + become non-executable leading to task termination. Therefore
98859 + it is mandatory that you enable this option on alpha, parisc,
98860 + sparc and sparc64, otherwise your system would not even boot.
98861 +
98862 + NOTE: this feature *does* open up a loophole in the protection
98863 + provided by the non-executable pages, therefore the proper
98864 + solution is to modify the toolchain to produce a PLT that does
98865 + not need to be writable.
98866 +
98867 +config PAX_DLRESOLVE
98868 + bool 'Emulate old glibc resolver stub'
98869 + depends on PAX_EMUPLT && SPARC
98870 + default n
98871 + help
98872 + This option is needed if userland has an old glibc (before 2.4)
98873 + that puts a 'save' instruction into the runtime generated resolver
98874 + stub that needs special emulation.
98875 +
98876 +config PAX_KERNEXEC
98877 + bool "Enforce non-executable kernel pages"
98878 + 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))
98879 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98880 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98881 + select PAX_KERNEXEC_PLUGIN if X86_64
98882 + help
98883 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98884 + that is, enabling this option will make it harder to inject
98885 + and execute 'foreign' code in kernel memory itself.
98886 +
98887 +choice
98888 + prompt "Return Address Instrumentation Method"
98889 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98890 + depends on PAX_KERNEXEC_PLUGIN
98891 + help
98892 + Select the method used to instrument function pointer dereferences.
98893 + Note that binary modules cannot be instrumented by this approach.
98894 +
98895 + Note that the implementation requires a gcc with plugin support,
98896 + i.e., gcc 4.5 or newer. You may need to install the supporting
98897 + headers explicitly in addition to the normal gcc package.
98898 +
98899 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98900 + bool "bts"
98901 + help
98902 + This method is compatible with binary only modules but has
98903 + a higher runtime overhead.
98904 +
98905 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98906 + bool "or"
98907 + depends on !PARAVIRT
98908 + help
98909 + This method is incompatible with binary only modules but has
98910 + a lower runtime overhead.
98911 +endchoice
98912 +
98913 +config PAX_KERNEXEC_PLUGIN_METHOD
98914 + string
98915 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98916 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98917 + default ""
98918 +
98919 +config PAX_KERNEXEC_MODULE_TEXT
98920 + int "Minimum amount of memory reserved for module code"
98921 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98922 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98923 + depends on PAX_KERNEXEC && X86_32
98924 + help
98925 + Due to implementation details the kernel must reserve a fixed
98926 + amount of memory for runtime allocated code (such as modules)
98927 + at compile time that cannot be changed at runtime. Here you
98928 + can specify the minimum amount in MB that will be reserved.
98929 + Due to the same implementation details this size will always
98930 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98931 + the actually available memory for runtime allocated code will
98932 + usually be more than this minimum.
98933 +
98934 + The default 4 MB should be enough for most users but if you have
98935 + an excessive number of modules (e.g., most distribution configs
98936 + compile many drivers as modules) or use huge modules such as
98937 + nvidia's kernel driver, you will need to adjust this amount.
98938 + A good rule of thumb is to look at your currently loaded kernel
98939 + modules and add up their sizes.
98940 +
98941 +endmenu
98942 +
98943 +menu "Address Space Layout Randomization"
98944 + depends on PAX
98945 +
98946 +config PAX_ASLR
98947 + bool "Address Space Layout Randomization"
98948 + default y if GRKERNSEC_CONFIG_AUTO
98949 + help
98950 + Many if not most exploit techniques rely on the knowledge of
98951 + certain addresses in the attacked program. The following options
98952 + will allow the kernel to apply a certain amount of randomization
98953 + to specific parts of the program thereby forcing an attacker to
98954 + guess them in most cases. Any failed guess will most likely crash
98955 + the attacked program which allows the kernel to detect such attempts
98956 + and react on them. PaX itself provides no reaction mechanisms,
98957 + instead it is strongly encouraged that you make use of Nergal's
98958 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98959 + (http://www.grsecurity.net/) built-in crash detection features or
98960 + develop one yourself.
98961 +
98962 + By saying Y here you can choose to randomize the following areas:
98963 + - top of the task's kernel stack
98964 + - top of the task's userland stack
98965 + - base address for mmap() requests that do not specify one
98966 + (this includes all libraries)
98967 + - base address of the main executable
98968 +
98969 + It is strongly recommended to say Y here as address space layout
98970 + randomization has negligible impact on performance yet it provides
98971 + a very effective protection.
98972 +
98973 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98974 + this feature on a per file basis.
98975 +
98976 +config PAX_RANDKSTACK
98977 + bool "Randomize kernel stack base"
98978 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98979 + depends on X86_TSC && X86
98980 + help
98981 + By saying Y here the kernel will randomize every task's kernel
98982 + stack on every system call. This will not only force an attacker
98983 + to guess it but also prevent him from making use of possible
98984 + leaked information about it.
98985 +
98986 + Since the kernel stack is a rather scarce resource, randomization
98987 + may cause unexpected stack overflows, therefore you should very
98988 + carefully test your system. Note that once enabled in the kernel
98989 + configuration, this feature cannot be disabled on a per file basis.
98990 +
98991 +config PAX_RANDUSTACK
98992 + bool "Randomize user stack base"
98993 + default y if GRKERNSEC_CONFIG_AUTO
98994 + depends on PAX_ASLR
98995 + help
98996 + By saying Y here the kernel will randomize every task's userland
98997 + stack. The randomization is done in two steps where the second
98998 + one may apply a big amount of shift to the top of the stack and
98999 + cause problems for programs that want to use lots of memory (more
99000 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
99001 + For this reason the second step can be controlled by 'chpax' or
99002 + 'paxctl' on a per file basis.
99003 +
99004 +config PAX_RANDMMAP
99005 + bool "Randomize mmap() base"
99006 + default y if GRKERNSEC_CONFIG_AUTO
99007 + depends on PAX_ASLR
99008 + help
99009 + By saying Y here the kernel will use a randomized base address for
99010 + mmap() requests that do not specify one themselves. As a result
99011 + all dynamically loaded libraries will appear at random addresses
99012 + and therefore be harder to exploit by a technique where an attacker
99013 + attempts to execute library code for his purposes (e.g. spawn a
99014 + shell from an exploited program that is running at an elevated
99015 + privilege level).
99016 +
99017 + Furthermore, if a program is relinked as a dynamic ELF file, its
99018 + base address will be randomized as well, completing the full
99019 + randomization of the address space layout. Attacking such programs
99020 + becomes a guess game. You can find an example of doing this at
99021 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99022 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99023 +
99024 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
99025 + feature on a per file basis.
99026 +
99027 +endmenu
99028 +
99029 +menu "Miscellaneous hardening features"
99030 +
99031 +config PAX_MEMORY_SANITIZE
99032 + bool "Sanitize all freed memory"
99033 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99034 + depends on !HIBERNATION
99035 + help
99036 + By saying Y here the kernel will erase memory pages and slab objects
99037 + as soon as they are freed. This in turn reduces the lifetime of data
99038 + stored in them, making it less likely that sensitive information such
99039 + as passwords, cryptographic secrets, etc stay in memory for too long.
99040 +
99041 + This is especially useful for programs whose runtime is short, long
99042 + lived processes and the kernel itself benefit from this as long as
99043 + they ensure timely freeing of memory that may hold sensitive
99044 + information.
99045 +
99046 + A nice side effect of the sanitization of slab objects is the
99047 + reduction of possible info leaks caused by padding bytes within the
99048 + leaky structures. Use-after-free bugs for structures containing
99049 + pointers can also be detected as dereferencing the sanitized pointer
99050 + will generate an access violation.
99051 +
99052 + The tradeoff is performance impact, on a single CPU system kernel
99053 + compilation sees a 3% slowdown, other systems and workloads may vary
99054 + and you are advised to test this feature on your expected workload
99055 + before deploying it.
99056 +
99057 + To reduce the performance penalty by sanitizing pages only, albeit
99058 + limiting the effectiveness of this feature at the same time, slab
99059 + sanitization can be disabled with the kernel commandline parameter
99060 + "pax_sanitize_slab=0".
99061 +
99062 + Note that this feature does not protect data stored in live pages,
99063 + e.g., process memory swapped to disk may stay there for a long time.
99064 +
99065 +config PAX_MEMORY_STACKLEAK
99066 + bool "Sanitize kernel stack"
99067 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99068 + depends on X86
99069 + help
99070 + By saying Y here the kernel will erase the kernel stack before it
99071 + returns from a system call. This in turn reduces the information
99072 + that a kernel stack leak bug can reveal.
99073 +
99074 + Note that such a bug can still leak information that was put on
99075 + the stack by the current system call (the one eventually triggering
99076 + the bug) but traces of earlier system calls on the kernel stack
99077 + cannot leak anymore.
99078 +
99079 + The tradeoff is performance impact: on a single CPU system kernel
99080 + compilation sees a 1% slowdown, other systems and workloads may vary
99081 + and you are advised to test this feature on your expected workload
99082 + before deploying it.
99083 +
99084 + Note that the full feature requires a gcc with plugin support,
99085 + i.e., gcc 4.5 or newer. You may need to install the supporting
99086 + headers explicitly in addition to the normal gcc package. Using
99087 + older gcc versions means that functions with large enough stack
99088 + frames may leave uninitialized memory behind that may be exposed
99089 + to a later syscall leaking the stack.
99090 +
99091 +config PAX_MEMORY_STRUCTLEAK
99092 + bool "Forcibly initialize local variables copied to userland"
99093 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99094 + help
99095 + By saying Y here the kernel will zero initialize some local
99096 + variables that are going to be copied to userland. This in
99097 + turn prevents unintended information leakage from the kernel
99098 + stack should later code forget to explicitly set all parts of
99099 + the copied variable.
99100 +
99101 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
99102 + at a much smaller coverage.
99103 +
99104 + Note that the implementation requires a gcc with plugin support,
99105 + i.e., gcc 4.5 or newer. You may need to install the supporting
99106 + headers explicitly in addition to the normal gcc package.
99107 +
99108 +config PAX_MEMORY_UDEREF
99109 + bool "Prevent invalid userland pointer dereference"
99110 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
99111 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
99112 + select PAX_PER_CPU_PGD if X86_64
99113 + help
99114 + By saying Y here the kernel will be prevented from dereferencing
99115 + userland pointers in contexts where the kernel expects only kernel
99116 + pointers. This is both a useful runtime debugging feature and a
99117 + security measure that prevents exploiting a class of kernel bugs.
99118 +
99119 + The tradeoff is that some virtualization solutions may experience
99120 + a huge slowdown and therefore you should not enable this feature
99121 + for kernels meant to run in such environments. Whether a given VM
99122 + solution is affected or not is best determined by simply trying it
99123 + out, the performance impact will be obvious right on boot as this
99124 + mechanism engages from very early on. A good rule of thumb is that
99125 + VMs running on CPUs without hardware virtualization support (i.e.,
99126 + the majority of IA-32 CPUs) will likely experience the slowdown.
99127 +
99128 + On X86_64 the kernel will make use of PCID support when available
99129 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
99130 + or performance impact. Pass pax_weakuderef on the kernel command
99131 + line to choose the latter.
99132 +
99133 +config PAX_REFCOUNT
99134 + bool "Prevent various kernel object reference counter overflows"
99135 + default y if GRKERNSEC_CONFIG_AUTO
99136 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
99137 + help
99138 + By saying Y here the kernel will detect and prevent overflowing
99139 + various (but not all) kinds of object reference counters. Such
99140 + overflows can normally occur due to bugs only and are often, if
99141 + not always, exploitable.
99142 +
99143 + The tradeoff is that data structures protected by an overflowed
99144 + refcount will never be freed and therefore will leak memory. Note
99145 + that this leak also happens even without this protection but in
99146 + that case the overflow can eventually trigger the freeing of the
99147 + data structure while it is still being used elsewhere, resulting
99148 + in the exploitable situation that this feature prevents.
99149 +
99150 + Since this has a negligible performance impact, you should enable
99151 + this feature.
99152 +
99153 +config PAX_CONSTIFY_PLUGIN
99154 + bool "Automatically constify eligible structures"
99155 + default y
99156 + depends on !UML && PAX_KERNEXEC
99157 + help
99158 + By saying Y here the compiler will automatically constify a class
99159 + of types that contain only function pointers. This reduces the
99160 + kernel's attack surface and also produces a better memory layout.
99161 +
99162 + Note that the implementation requires a gcc with plugin support,
99163 + i.e., gcc 4.5 or newer. You may need to install the supporting
99164 + headers explicitly in addition to the normal gcc package.
99165 +
99166 + Note that if some code really has to modify constified variables
99167 + then the source code will have to be patched to allow it. Examples
99168 + can be found in PaX itself (the no_const attribute) and for some
99169 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
99170 +
99171 +config PAX_USERCOPY
99172 + bool "Harden heap object copies between kernel and userland"
99173 + default y if GRKERNSEC_CONFIG_AUTO
99174 + depends on ARM || IA64 || PPC || SPARC || X86
99175 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
99176 + select PAX_USERCOPY_SLABS
99177 + help
99178 + By saying Y here the kernel will enforce the size of heap objects
99179 + when they are copied in either direction between the kernel and
99180 + userland, even if only a part of the heap object is copied.
99181 +
99182 + Specifically, this checking prevents information leaking from the
99183 + kernel heap during kernel to userland copies (if the kernel heap
99184 + object is otherwise fully initialized) and prevents kernel heap
99185 + overflows during userland to kernel copies.
99186 +
99187 + Note that the current implementation provides the strictest bounds
99188 + checks for the SLUB allocator.
99189 +
99190 + Enabling this option also enables per-slab cache protection against
99191 + data in a given cache being copied into/out of via userland
99192 + accessors. Though the whitelist of regions will be reduced over
99193 + time, it notably protects important data structures like task structs.
99194 +
99195 + If frame pointers are enabled on x86, this option will also restrict
99196 + copies into and out of the kernel stack to local variables within a
99197 + single frame.
99198 +
99199 + Since this has a negligible performance impact, you should enable
99200 + this feature.
99201 +
99202 +config PAX_USERCOPY_DEBUG
99203 + bool
99204 + depends on X86 && PAX_USERCOPY
99205 + default n
99206 +
99207 +config PAX_SIZE_OVERFLOW
99208 + bool "Prevent various integer overflows in function size parameters"
99209 + default y if GRKERNSEC_CONFIG_AUTO
99210 + depends on X86
99211 + help
99212 + By saying Y here the kernel recomputes expressions of function
99213 + arguments marked by a size_overflow attribute with double integer
99214 + precision (DImode/TImode for 32/64 bit integer types).
99215 +
99216 + The recomputed argument is checked against TYPE_MAX and an event
99217 + is logged on overflow and the triggering process is killed.
99218 +
99219 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
99220 +
99221 + Note that the implementation requires a gcc with plugin support,
99222 + i.e., gcc 4.5 or newer. You may need to install the supporting
99223 + headers explicitly in addition to the normal gcc package.
99224 +
99225 +config PAX_LATENT_ENTROPY
99226 + bool "Generate some entropy during boot and runtime"
99227 + default y if GRKERNSEC_CONFIG_AUTO
99228 + help
99229 + By saying Y here the kernel will instrument some kernel code to
99230 + extract some entropy from both original and artificially created
99231 + program state. This will help especially embedded systems where
99232 + there is little 'natural' source of entropy normally. The cost
99233 + is some slowdown of the boot process and fork and irq processing.
99234 +
99235 + When pax_extra_latent_entropy is passed on the kernel command line,
99236 + entropy will be extracted from up to the first 4GB of RAM while the
99237 + runtime memory allocator is being initialized. This costs even more
99238 + slowdown of the boot process.
99239 +
99240 + Note that the implementation requires a gcc with plugin support,
99241 + i.e., gcc 4.5 or newer. You may need to install the supporting
99242 + headers explicitly in addition to the normal gcc package.
99243 +
99244 + Note that entropy extracted this way is not cryptographically
99245 + secure!
99246 +
99247 +endmenu
99248 +
99249 +endmenu
99250 +
99251 +source grsecurity/Kconfig
99252 +
99253 +endmenu
99254 +
99255 +endmenu
99256 +
99257 source security/keys/Kconfig
99258
99259 config SECURITY_DMESG_RESTRICT
99260 @@ -103,7 +1057,7 @@ config INTEL_TXT
99261 config LSM_MMAP_MIN_ADDR
99262 int "Low address space for LSM to protect from user allocation"
99263 depends on SECURITY && SECURITY_SELINUX
99264 - default 32768 if ARM
99265 + default 32768 if ALPHA || ARM || PARISC || SPARC32
99266 default 65536
99267 help
99268 This is the portion of low virtual memory which should be protected
99269 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
99270 index fb99e18..b3e0bbb 100644
99271 --- a/security/apparmor/lsm.c
99272 +++ b/security/apparmor/lsm.c
99273 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
99274 return error;
99275 }
99276
99277 -static struct security_operations apparmor_ops = {
99278 +static struct security_operations apparmor_ops __read_only = {
99279 .name = "apparmor",
99280
99281 .ptrace_access_check = apparmor_ptrace_access_check,
99282 diff --git a/security/commoncap.c b/security/commoncap.c
99283 index b9d613e..f68305c 100644
99284 --- a/security/commoncap.c
99285 +++ b/security/commoncap.c
99286 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
99287 return 0;
99288 }
99289
99290 +/* returns:
99291 + 1 for suid privilege
99292 + 2 for sgid privilege
99293 + 3 for fscap privilege
99294 +*/
99295 +int is_privileged_binary(const struct dentry *dentry)
99296 +{
99297 + struct cpu_vfs_cap_data capdata;
99298 + struct inode *inode = dentry->d_inode;
99299 +
99300 + if (!inode || S_ISDIR(inode->i_mode))
99301 + return 0;
99302 +
99303 + if (inode->i_mode & S_ISUID)
99304 + return 1;
99305 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
99306 + return 2;
99307 +
99308 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
99309 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
99310 + return 3;
99311 + }
99312 +
99313 + return 0;
99314 +}
99315 +
99316 /*
99317 * Attempt to get the on-exec apply capability sets for an executable file from
99318 * its xattrs and, if present, apply them to the proposed credentials being
99319 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
99320 const struct cred *cred = current_cred();
99321 kuid_t root_uid = make_kuid(cred->user_ns, 0);
99322
99323 + if (gr_acl_enable_at_secure())
99324 + return 1;
99325 +
99326 if (!uid_eq(cred->uid, root_uid)) {
99327 if (bprm->cap_effective)
99328 return 1;
99329 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
99330 index b3dd616..4bb17f3 100644
99331 --- a/security/integrity/ima/ima.h
99332 +++ b/security/integrity/ima/ima.h
99333 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
99334 extern spinlock_t ima_queue_lock;
99335
99336 struct ima_h_table {
99337 - atomic_long_t len; /* number of stored measurements in the list */
99338 - atomic_long_t violations;
99339 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
99340 + atomic_long_unchecked_t violations;
99341 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
99342 };
99343 extern struct ima_h_table ima_htable;
99344 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
99345 index 1c03e8f1..398a941 100644
99346 --- a/security/integrity/ima/ima_api.c
99347 +++ b/security/integrity/ima/ima_api.c
99348 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
99349 int result;
99350
99351 /* can overflow, only indicator */
99352 - atomic_long_inc(&ima_htable.violations);
99353 + atomic_long_inc_unchecked(&ima_htable.violations);
99354
99355 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
99356 if (!entry) {
99357 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
99358 index 38477c9..87a60c7 100644
99359 --- a/security/integrity/ima/ima_fs.c
99360 +++ b/security/integrity/ima/ima_fs.c
99361 @@ -28,12 +28,12 @@
99362 static int valid_policy = 1;
99363 #define TMPBUFLEN 12
99364 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
99365 - loff_t *ppos, atomic_long_t *val)
99366 + loff_t *ppos, atomic_long_unchecked_t *val)
99367 {
99368 char tmpbuf[TMPBUFLEN];
99369 ssize_t len;
99370
99371 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
99372 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
99373 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
99374 }
99375
99376 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
99377 index ff63fe0..809cd96 100644
99378 --- a/security/integrity/ima/ima_queue.c
99379 +++ b/security/integrity/ima/ima_queue.c
99380 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
99381 INIT_LIST_HEAD(&qe->later);
99382 list_add_tail_rcu(&qe->later, &ima_measurements);
99383
99384 - atomic_long_inc(&ima_htable.len);
99385 + atomic_long_inc_unchecked(&ima_htable.len);
99386 key = ima_hash_key(entry->digest);
99387 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
99388 return 0;
99389 diff --git a/security/keys/compat.c b/security/keys/compat.c
99390 index d65fa7f..cbfe366 100644
99391 --- a/security/keys/compat.c
99392 +++ b/security/keys/compat.c
99393 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
99394 if (ret == 0)
99395 goto no_payload_free;
99396
99397 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99398 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99399 err:
99400 if (iov != iovstack)
99401 kfree(iov);
99402 diff --git a/security/keys/internal.h b/security/keys/internal.h
99403 index d4f1468..cc52f92 100644
99404 --- a/security/keys/internal.h
99405 +++ b/security/keys/internal.h
99406 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99407 extern long keyctl_invalidate_key(key_serial_t);
99408
99409 extern long keyctl_instantiate_key_common(key_serial_t,
99410 - const struct iovec *,
99411 + const struct iovec __user *,
99412 unsigned, size_t, key_serial_t);
99413
99414 /*
99415 diff --git a/security/keys/key.c b/security/keys/key.c
99416 index 8fb7c7b..ba3610d 100644
99417 --- a/security/keys/key.c
99418 +++ b/security/keys/key.c
99419 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
99420
99421 atomic_set(&key->usage, 1);
99422 init_rwsem(&key->sem);
99423 - lockdep_set_class(&key->sem, &type->lock_class);
99424 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
99425 key->type = type;
99426 key->user = user;
99427 key->quotalen = quotalen;
99428 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
99429 struct key_type *p;
99430 int ret;
99431
99432 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
99433 + pax_open_kernel();
99434 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
99435 + pax_close_kernel();
99436
99437 ret = -EEXIST;
99438 down_write(&key_types_sem);
99439 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
99440 }
99441
99442 /* store the type */
99443 - list_add(&ktype->link, &key_types_list);
99444 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
99445
99446 pr_notice("Key type %s registered\n", ktype->name);
99447 ret = 0;
99448 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
99449 void unregister_key_type(struct key_type *ktype)
99450 {
99451 down_write(&key_types_sem);
99452 - list_del_init(&ktype->link);
99453 + pax_list_del_init((struct list_head *)&ktype->link);
99454 downgrade_write(&key_types_sem);
99455 key_gc_keytype(ktype);
99456 pr_notice("Key type %s unregistered\n", ktype->name);
99457 @@ -1084,10 +1086,10 @@ void __init key_init(void)
99458 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
99459
99460 /* add the special key types */
99461 - list_add_tail(&key_type_keyring.link, &key_types_list);
99462 - list_add_tail(&key_type_dead.link, &key_types_list);
99463 - list_add_tail(&key_type_user.link, &key_types_list);
99464 - list_add_tail(&key_type_logon.link, &key_types_list);
99465 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99466 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99467 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99468 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99469
99470 /* record the root user tracking */
99471 rb_link_node(&root_key_user.node,
99472 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99473 index 33cfd27..842fc5a 100644
99474 --- a/security/keys/keyctl.c
99475 +++ b/security/keys/keyctl.c
99476 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99477 /*
99478 * Copy the iovec data from userspace
99479 */
99480 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99481 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99482 unsigned ioc)
99483 {
99484 for (; ioc > 0; ioc--) {
99485 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99486 * If successful, 0 will be returned.
99487 */
99488 long keyctl_instantiate_key_common(key_serial_t id,
99489 - const struct iovec *payload_iov,
99490 + const struct iovec __user *payload_iov,
99491 unsigned ioc,
99492 size_t plen,
99493 key_serial_t ringid)
99494 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99495 [0].iov_len = plen
99496 };
99497
99498 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99499 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99500 }
99501
99502 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99503 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99504 if (ret == 0)
99505 goto no_payload_free;
99506
99507 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99508 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99509 err:
99510 if (iov != iovstack)
99511 kfree(iov);
99512 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99513 index 6ece7f2..ecdb55c 100644
99514 --- a/security/keys/keyring.c
99515 +++ b/security/keys/keyring.c
99516 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99517 ret = -EFAULT;
99518
99519 for (loop = 0; loop < klist->nkeys; loop++) {
99520 + key_serial_t serial;
99521 key = rcu_deref_link_locked(klist, loop,
99522 keyring);
99523 + serial = key->serial;
99524
99525 tmp = sizeof(key_serial_t);
99526 if (tmp > buflen)
99527 tmp = buflen;
99528
99529 - if (copy_to_user(buffer,
99530 - &key->serial,
99531 - tmp) != 0)
99532 + if (copy_to_user(buffer, &serial, tmp))
99533 goto error;
99534
99535 buflen -= tmp;
99536 diff --git a/security/min_addr.c b/security/min_addr.c
99537 index f728728..6457a0c 100644
99538 --- a/security/min_addr.c
99539 +++ b/security/min_addr.c
99540 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99541 */
99542 static void update_mmap_min_addr(void)
99543 {
99544 +#ifndef SPARC
99545 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99546 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99547 mmap_min_addr = dac_mmap_min_addr;
99548 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99549 #else
99550 mmap_min_addr = dac_mmap_min_addr;
99551 #endif
99552 +#endif
99553 }
99554
99555 /*
99556 diff --git a/security/security.c b/security/security.c
99557 index 4dc31f4..eabcf41 100644
99558 --- a/security/security.c
99559 +++ b/security/security.c
99560 @@ -33,8 +33,8 @@
99561 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99562 CONFIG_DEFAULT_SECURITY;
99563
99564 -static struct security_operations *security_ops;
99565 -static struct security_operations default_security_ops = {
99566 +struct security_operations *security_ops __read_only;
99567 +struct security_operations default_security_ops __read_only = {
99568 .name = "default",
99569 };
99570
99571 @@ -73,11 +73,6 @@ int __init security_init(void)
99572 return 0;
99573 }
99574
99575 -void reset_security_ops(void)
99576 -{
99577 - security_ops = &default_security_ops;
99578 -}
99579 -
99580 /* Save user chosen LSM */
99581 static int __init choose_lsm(char *str)
99582 {
99583 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99584 index fc3e662..7844c60 100644
99585 --- a/security/selinux/avc.c
99586 +++ b/security/selinux/avc.c
99587 @@ -59,7 +59,7 @@ struct avc_node {
99588 struct avc_cache {
99589 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99590 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99591 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99592 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99593 atomic_t active_nodes;
99594 u32 latest_notif; /* latest revocation notification */
99595 };
99596 @@ -167,7 +167,7 @@ void __init avc_init(void)
99597 spin_lock_init(&avc_cache.slots_lock[i]);
99598 }
99599 atomic_set(&avc_cache.active_nodes, 0);
99600 - atomic_set(&avc_cache.lru_hint, 0);
99601 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99602
99603 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99604 0, SLAB_PANIC, NULL);
99605 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99606 spinlock_t *lock;
99607
99608 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99609 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99610 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99611 head = &avc_cache.slots[hvalue];
99612 lock = &avc_cache.slots_lock[hvalue];
99613
99614 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99615 index 5b52310..da3bf8e 100644
99616 --- a/security/selinux/hooks.c
99617 +++ b/security/selinux/hooks.c
99618 @@ -5603,7 +5603,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99619
99620 #endif
99621
99622 -static struct security_operations selinux_ops = {
99623 +static struct security_operations selinux_ops __read_only = {
99624 .name = "selinux",
99625
99626 .ptrace_access_check = selinux_ptrace_access_check,
99627 @@ -5955,6 +5955,9 @@ static void selinux_nf_ip_exit(void)
99628 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99629 static int selinux_disabled;
99630
99631 +extern struct security_operations *security_ops;
99632 +extern struct security_operations default_security_ops;
99633 +
99634 int selinux_disable(void)
99635 {
99636 if (ss_initialized) {
99637 @@ -5972,7 +5975,9 @@ int selinux_disable(void)
99638 selinux_disabled = 1;
99639 selinux_enabled = 0;
99640
99641 - reset_security_ops();
99642 + pax_open_kernel();
99643 + security_ops = &default_security_ops;
99644 + pax_close_kernel();
99645
99646 /* Try to destroy the avc node cache */
99647 avc_disable();
99648 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99649 index 6713f04..c57ecef 100644
99650 --- a/security/selinux/include/xfrm.h
99651 +++ b/security/selinux/include/xfrm.h
99652 @@ -52,7 +52,7 @@ static inline void selinux_xfrm_notify_policyload(void)
99653 {
99654 struct net *net;
99655
99656 - atomic_inc(&flow_cache_genid);
99657 + atomic_inc_unchecked(&flow_cache_genid);
99658 rtnl_lock();
99659 for_each_net(net)
99660 rt_genid_bump_all(net);
99661 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99662 index 8825375..97a623b 100644
99663 --- a/security/smack/smack_lsm.c
99664 +++ b/security/smack/smack_lsm.c
99665 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99666 return 0;
99667 }
99668
99669 -struct security_operations smack_ops = {
99670 +struct security_operations smack_ops __read_only = {
99671 .name = "smack",
99672
99673 .ptrace_access_check = smack_ptrace_access_check,
99674 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99675 index 390c646..f2f8db3 100644
99676 --- a/security/tomoyo/mount.c
99677 +++ b/security/tomoyo/mount.c
99678 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99679 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99680 need_dev = -1; /* dev_name is a directory */
99681 } else {
99682 + if (!capable(CAP_SYS_ADMIN)) {
99683 + error = -EPERM;
99684 + goto out;
99685 + }
99686 fstype = get_fs_type(type);
99687 if (!fstype) {
99688 error = -ENODEV;
99689 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99690 index f0b756e..b129202 100644
99691 --- a/security/tomoyo/tomoyo.c
99692 +++ b/security/tomoyo/tomoyo.c
99693 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99694 * tomoyo_security_ops is a "struct security_operations" which is used for
99695 * registering TOMOYO.
99696 */
99697 -static struct security_operations tomoyo_security_ops = {
99698 +static struct security_operations tomoyo_security_ops __read_only = {
99699 .name = "tomoyo",
99700 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99701 .cred_prepare = tomoyo_cred_prepare,
99702 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99703 index 20ef514..4182bed 100644
99704 --- a/security/yama/Kconfig
99705 +++ b/security/yama/Kconfig
99706 @@ -1,6 +1,6 @@
99707 config SECURITY_YAMA
99708 bool "Yama support"
99709 - depends on SECURITY
99710 + depends on SECURITY && !GRKERNSEC
99711 select SECURITYFS
99712 select SECURITY_PATH
99713 default n
99714 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99715 index 13c88fbc..f8c115e 100644
99716 --- a/security/yama/yama_lsm.c
99717 +++ b/security/yama/yama_lsm.c
99718 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99719 }
99720
99721 #ifndef CONFIG_SECURITY_YAMA_STACKED
99722 -static struct security_operations yama_ops = {
99723 +static struct security_operations yama_ops __read_only = {
99724 .name = "yama",
99725
99726 .ptrace_access_check = yama_ptrace_access_check,
99727 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99728 #endif
99729
99730 #ifdef CONFIG_SYSCTL
99731 +static int zero __read_only;
99732 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99733 +
99734 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99735 void __user *buffer, size_t *lenp, loff_t *ppos)
99736 {
99737 - int rc;
99738 + ctl_table_no_const yama_table;
99739
99740 if (write && !capable(CAP_SYS_PTRACE))
99741 return -EPERM;
99742
99743 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99744 - if (rc)
99745 - return rc;
99746 -
99747 + yama_table = *table;
99748 /* Lock the max value if it ever gets set. */
99749 - if (write && *(int *)table->data == *(int *)table->extra2)
99750 - table->extra1 = table->extra2;
99751 -
99752 - return rc;
99753 + if (ptrace_scope == max_scope)
99754 + yama_table.extra1 = &max_scope;
99755 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99756 }
99757
99758 -static int zero;
99759 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99760 -
99761 struct ctl_path yama_sysctl_path[] = {
99762 { .procname = "kernel", },
99763 { .procname = "yama", },
99764 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99765 index 4cedc69..e59d8a3 100644
99766 --- a/sound/aoa/codecs/onyx.c
99767 +++ b/sound/aoa/codecs/onyx.c
99768 @@ -54,7 +54,7 @@ struct onyx {
99769 spdif_locked:1,
99770 analog_locked:1,
99771 original_mute:2;
99772 - int open_count;
99773 + local_t open_count;
99774 struct codec_info *codec_info;
99775
99776 /* mutex serializes concurrent access to the device
99777 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99778 struct onyx *onyx = cii->codec_data;
99779
99780 mutex_lock(&onyx->mutex);
99781 - onyx->open_count++;
99782 + local_inc(&onyx->open_count);
99783 mutex_unlock(&onyx->mutex);
99784
99785 return 0;
99786 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99787 struct onyx *onyx = cii->codec_data;
99788
99789 mutex_lock(&onyx->mutex);
99790 - onyx->open_count--;
99791 - if (!onyx->open_count)
99792 + if (local_dec_and_test(&onyx->open_count))
99793 onyx->spdif_locked = onyx->analog_locked = 0;
99794 mutex_unlock(&onyx->mutex);
99795
99796 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99797 index ffd2025..df062c9 100644
99798 --- a/sound/aoa/codecs/onyx.h
99799 +++ b/sound/aoa/codecs/onyx.h
99800 @@ -11,6 +11,7 @@
99801 #include <linux/i2c.h>
99802 #include <asm/pmac_low_i2c.h>
99803 #include <asm/prom.h>
99804 +#include <asm/local.h>
99805
99806 /* PCM3052 register definitions */
99807
99808 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99809 index 4c1cc51..16040040 100644
99810 --- a/sound/core/oss/pcm_oss.c
99811 +++ b/sound/core/oss/pcm_oss.c
99812 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99813 if (in_kernel) {
99814 mm_segment_t fs;
99815 fs = snd_enter_user();
99816 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99817 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99818 snd_leave_user(fs);
99819 } else {
99820 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99821 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99822 }
99823 if (ret != -EPIPE && ret != -ESTRPIPE)
99824 break;
99825 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99826 if (in_kernel) {
99827 mm_segment_t fs;
99828 fs = snd_enter_user();
99829 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99830 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99831 snd_leave_user(fs);
99832 } else {
99833 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99834 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99835 }
99836 if (ret == -EPIPE) {
99837 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99838 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99839 struct snd_pcm_plugin_channel *channels;
99840 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99841 if (!in_kernel) {
99842 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99843 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99844 return -EFAULT;
99845 buf = runtime->oss.buffer;
99846 }
99847 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99848 }
99849 } else {
99850 tmp = snd_pcm_oss_write2(substream,
99851 - (const char __force *)buf,
99852 + (const char __force_kernel *)buf,
99853 runtime->oss.period_bytes, 0);
99854 if (tmp <= 0)
99855 goto err;
99856 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99857 struct snd_pcm_runtime *runtime = substream->runtime;
99858 snd_pcm_sframes_t frames, frames1;
99859 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99860 - char __user *final_dst = (char __force __user *)buf;
99861 + char __user *final_dst = (char __force_user *)buf;
99862 if (runtime->oss.plugin_first) {
99863 struct snd_pcm_plugin_channel *channels;
99864 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99865 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99866 xfer += tmp;
99867 runtime->oss.buffer_used -= tmp;
99868 } else {
99869 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99870 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99871 runtime->oss.period_bytes, 0);
99872 if (tmp <= 0)
99873 goto err;
99874 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99875 size1);
99876 size1 /= runtime->channels; /* frames */
99877 fs = snd_enter_user();
99878 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99879 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99880 snd_leave_user(fs);
99881 }
99882 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99883 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99884 index af49721..e85058e 100644
99885 --- a/sound/core/pcm_compat.c
99886 +++ b/sound/core/pcm_compat.c
99887 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99888 int err;
99889
99890 fs = snd_enter_user();
99891 - err = snd_pcm_delay(substream, &delay);
99892 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99893 snd_leave_user(fs);
99894 if (err < 0)
99895 return err;
99896 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99897 index a68d4c6..72af3cf 100644
99898 --- a/sound/core/pcm_native.c
99899 +++ b/sound/core/pcm_native.c
99900 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99901 switch (substream->stream) {
99902 case SNDRV_PCM_STREAM_PLAYBACK:
99903 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99904 - (void __user *)arg);
99905 + (void __force_user *)arg);
99906 break;
99907 case SNDRV_PCM_STREAM_CAPTURE:
99908 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99909 - (void __user *)arg);
99910 + (void __force_user *)arg);
99911 break;
99912 default:
99913 result = -EINVAL;
99914 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99915 index 040c60e..989a19a 100644
99916 --- a/sound/core/seq/seq_device.c
99917 +++ b/sound/core/seq/seq_device.c
99918 @@ -64,7 +64,7 @@ struct ops_list {
99919 int argsize; /* argument size */
99920
99921 /* operators */
99922 - struct snd_seq_dev_ops ops;
99923 + struct snd_seq_dev_ops *ops;
99924
99925 /* registered devices */
99926 struct list_head dev_list; /* list of devices */
99927 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99928
99929 mutex_lock(&ops->reg_mutex);
99930 /* copy driver operators */
99931 - ops->ops = *entry;
99932 + ops->ops = entry;
99933 ops->driver |= DRIVER_LOADED;
99934 ops->argsize = argsize;
99935
99936 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99937 dev->name, ops->id, ops->argsize, dev->argsize);
99938 return -EINVAL;
99939 }
99940 - if (ops->ops.init_device(dev) >= 0) {
99941 + if (ops->ops->init_device(dev) >= 0) {
99942 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99943 ops->num_init_devices++;
99944 } else {
99945 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99946 dev->name, ops->id, ops->argsize, dev->argsize);
99947 return -EINVAL;
99948 }
99949 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99950 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99951 dev->status = SNDRV_SEQ_DEVICE_FREE;
99952 dev->driver_data = NULL;
99953 ops->num_init_devices--;
99954 diff --git a/sound/core/sound.c b/sound/core/sound.c
99955 index f002bd9..c462985 100644
99956 --- a/sound/core/sound.c
99957 +++ b/sound/core/sound.c
99958 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99959 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99960 default: return;
99961 }
99962 - request_module(str);
99963 + request_module("%s", str);
99964 }
99965
99966 #endif /* modular kernel */
99967 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99968 index 4e0dd22..7a1f32c 100644
99969 --- a/sound/drivers/mts64.c
99970 +++ b/sound/drivers/mts64.c
99971 @@ -29,6 +29,7 @@
99972 #include <sound/initval.h>
99973 #include <sound/rawmidi.h>
99974 #include <sound/control.h>
99975 +#include <asm/local.h>
99976
99977 #define CARD_NAME "Miditerminal 4140"
99978 #define DRIVER_NAME "MTS64"
99979 @@ -67,7 +68,7 @@ struct mts64 {
99980 struct pardevice *pardev;
99981 int pardev_claimed;
99982
99983 - int open_count;
99984 + local_t open_count;
99985 int current_midi_output_port;
99986 int current_midi_input_port;
99987 u8 mode[MTS64_NUM_INPUT_PORTS];
99988 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99989 {
99990 struct mts64 *mts = substream->rmidi->private_data;
99991
99992 - if (mts->open_count == 0) {
99993 + if (local_read(&mts->open_count) == 0) {
99994 /* We don't need a spinlock here, because this is just called
99995 if the device has not been opened before.
99996 So there aren't any IRQs from the device */
99997 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99998
99999 msleep(50);
100000 }
100001 - ++(mts->open_count);
100002 + local_inc(&mts->open_count);
100003
100004 return 0;
100005 }
100006 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100007 struct mts64 *mts = substream->rmidi->private_data;
100008 unsigned long flags;
100009
100010 - --(mts->open_count);
100011 - if (mts->open_count == 0) {
100012 + if (local_dec_return(&mts->open_count) == 0) {
100013 /* We need the spinlock_irqsave here because we can still
100014 have IRQs at this point */
100015 spin_lock_irqsave(&mts->lock, flags);
100016 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100017
100018 msleep(500);
100019
100020 - } else if (mts->open_count < 0)
100021 - mts->open_count = 0;
100022 + } else if (local_read(&mts->open_count) < 0)
100023 + local_set(&mts->open_count, 0);
100024
100025 return 0;
100026 }
100027 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
100028 index b953fb4..1999c01 100644
100029 --- a/sound/drivers/opl4/opl4_lib.c
100030 +++ b/sound/drivers/opl4/opl4_lib.c
100031 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
100032 MODULE_DESCRIPTION("OPL4 driver");
100033 MODULE_LICENSE("GPL");
100034
100035 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
100036 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
100037 {
100038 int timeout = 10;
100039 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
100040 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
100041 index 991018d..8984740 100644
100042 --- a/sound/drivers/portman2x4.c
100043 +++ b/sound/drivers/portman2x4.c
100044 @@ -48,6 +48,7 @@
100045 #include <sound/initval.h>
100046 #include <sound/rawmidi.h>
100047 #include <sound/control.h>
100048 +#include <asm/local.h>
100049
100050 #define CARD_NAME "Portman 2x4"
100051 #define DRIVER_NAME "portman"
100052 @@ -85,7 +86,7 @@ struct portman {
100053 struct pardevice *pardev;
100054 int pardev_claimed;
100055
100056 - int open_count;
100057 + local_t open_count;
100058 int mode[PORTMAN_NUM_INPUT_PORTS];
100059 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
100060 };
100061 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
100062 index ea995af..f1bfa37 100644
100063 --- a/sound/firewire/amdtp.c
100064 +++ b/sound/firewire/amdtp.c
100065 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
100066 ptr = s->pcm_buffer_pointer + data_blocks;
100067 if (ptr >= pcm->runtime->buffer_size)
100068 ptr -= pcm->runtime->buffer_size;
100069 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
100070 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
100071
100072 s->pcm_period_pointer += data_blocks;
100073 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
100074 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
100075 */
100076 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100077 {
100078 - ACCESS_ONCE(s->source_node_id_field) =
100079 + ACCESS_ONCE_RW(s->source_node_id_field) =
100080 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100081 }
100082 EXPORT_SYMBOL(amdtp_out_stream_update);
100083 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100084 index f6103d6..4843fbf 100644
100085 --- a/sound/firewire/amdtp.h
100086 +++ b/sound/firewire/amdtp.h
100087 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100088 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100089 struct snd_pcm_substream *pcm)
100090 {
100091 - ACCESS_ONCE(s->pcm) = pcm;
100092 + ACCESS_ONCE_RW(s->pcm) = pcm;
100093 }
100094
100095 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
100096 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
100097 index 58a5afe..af5bd64 100644
100098 --- a/sound/firewire/isight.c
100099 +++ b/sound/firewire/isight.c
100100 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
100101 ptr += count;
100102 if (ptr >= runtime->buffer_size)
100103 ptr -= runtime->buffer_size;
100104 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
100105 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
100106
100107 isight->period_counter += count;
100108 if (isight->period_counter >= runtime->period_size) {
100109 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
100110 if (err < 0)
100111 return err;
100112
100113 - ACCESS_ONCE(isight->pcm_active) = true;
100114 + ACCESS_ONCE_RW(isight->pcm_active) = true;
100115
100116 return 0;
100117 }
100118 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
100119 {
100120 struct isight *isight = substream->private_data;
100121
100122 - ACCESS_ONCE(isight->pcm_active) = false;
100123 + ACCESS_ONCE_RW(isight->pcm_active) = false;
100124
100125 mutex_lock(&isight->mutex);
100126 isight_stop_streaming(isight);
100127 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
100128
100129 switch (cmd) {
100130 case SNDRV_PCM_TRIGGER_START:
100131 - ACCESS_ONCE(isight->pcm_running) = true;
100132 + ACCESS_ONCE_RW(isight->pcm_running) = true;
100133 break;
100134 case SNDRV_PCM_TRIGGER_STOP:
100135 - ACCESS_ONCE(isight->pcm_running) = false;
100136 + ACCESS_ONCE_RW(isight->pcm_running) = false;
100137 break;
100138 default:
100139 return -EINVAL;
100140 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
100141 index 505fc81..62e569e 100644
100142 --- a/sound/firewire/scs1x.c
100143 +++ b/sound/firewire/scs1x.c
100144 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
100145 {
100146 struct scs *scs = stream->rmidi->private_data;
100147
100148 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
100149 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
100150 if (up) {
100151 scs->output_idle = false;
100152 tasklet_schedule(&scs->tasklet);
100153 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
100154 {
100155 struct scs *scs = stream->rmidi->private_data;
100156
100157 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
100158 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
100159 }
100160
100161 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
100162 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
100163
100164 snd_card_disconnect(scs->card);
100165
100166 - ACCESS_ONCE(scs->output) = NULL;
100167 - ACCESS_ONCE(scs->input) = NULL;
100168 + ACCESS_ONCE_RW(scs->output) = NULL;
100169 + ACCESS_ONCE_RW(scs->input) = NULL;
100170
100171 wait_event(scs->idle_wait, scs->output_idle);
100172
100173 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
100174 index 048439a..3be9f6f 100644
100175 --- a/sound/oss/sb_audio.c
100176 +++ b/sound/oss/sb_audio.c
100177 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
100178 buf16 = (signed short *)(localbuf + localoffs);
100179 while (c)
100180 {
100181 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100182 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100183 if (copy_from_user(lbuf8,
100184 userbuf+useroffs + p,
100185 locallen))
100186 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
100187 index 7d8803a..559f8d0 100644
100188 --- a/sound/oss/swarm_cs4297a.c
100189 +++ b/sound/oss/swarm_cs4297a.c
100190 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
100191 {
100192 struct cs4297a_state *s;
100193 u32 pwr, id;
100194 - mm_segment_t fs;
100195 int rval;
100196 #ifndef CONFIG_BCM_CS4297A_CSWARM
100197 u64 cfg;
100198 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
100199 if (!rval) {
100200 char *sb1250_duart_present;
100201
100202 +#if 0
100203 + mm_segment_t fs;
100204 fs = get_fs();
100205 set_fs(KERNEL_DS);
100206 -#if 0
100207 val = SOUND_MASK_LINE;
100208 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
100209 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
100210 val = initvol[i].vol;
100211 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
100212 }
100213 + set_fs(fs);
100214 // cs4297a_write_ac97(s, 0x18, 0x0808);
100215 #else
100216 // cs4297a_write_ac97(s, 0x5e, 0x180);
100217 cs4297a_write_ac97(s, 0x02, 0x0808);
100218 cs4297a_write_ac97(s, 0x18, 0x0808);
100219 #endif
100220 - set_fs(fs);
100221
100222 list_add(&s->list, &cs4297a_devs);
100223
100224 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
100225 index 748c6a9..a27725a 100644
100226 --- a/sound/pci/hda/hda_codec.c
100227 +++ b/sound/pci/hda/hda_codec.c
100228 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
100229 mutex_unlock(&preset_mutex);
100230
100231 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
100232 - char name[32];
100233 if (!mod_requested)
100234 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
100235 - codec->vendor_id);
100236 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
100237 else
100238 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
100239 - (codec->vendor_id >> 16) & 0xffff);
100240 - request_module(name);
100241 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
100242 mod_requested++;
100243 goto again;
100244 }
100245 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
100246 index 4631a23..001ae57 100644
100247 --- a/sound/pci/ymfpci/ymfpci.h
100248 +++ b/sound/pci/ymfpci/ymfpci.h
100249 @@ -358,7 +358,7 @@ struct snd_ymfpci {
100250 spinlock_t reg_lock;
100251 spinlock_t voice_lock;
100252 wait_queue_head_t interrupt_sleep;
100253 - atomic_t interrupt_sleep_count;
100254 + atomic_unchecked_t interrupt_sleep_count;
100255 struct snd_info_entry *proc_entry;
100256 const struct firmware *dsp_microcode;
100257 const struct firmware *controller_microcode;
100258 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
100259 index d591c15..8cb8f94 100644
100260 --- a/sound/pci/ymfpci/ymfpci_main.c
100261 +++ b/sound/pci/ymfpci/ymfpci_main.c
100262 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
100263 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
100264 break;
100265 }
100266 - if (atomic_read(&chip->interrupt_sleep_count)) {
100267 - atomic_set(&chip->interrupt_sleep_count, 0);
100268 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100269 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100270 wake_up(&chip->interrupt_sleep);
100271 }
100272 __end:
100273 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
100274 continue;
100275 init_waitqueue_entry(&wait, current);
100276 add_wait_queue(&chip->interrupt_sleep, &wait);
100277 - atomic_inc(&chip->interrupt_sleep_count);
100278 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
100279 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
100280 remove_wait_queue(&chip->interrupt_sleep, &wait);
100281 }
100282 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
100283 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
100284 spin_unlock(&chip->reg_lock);
100285
100286 - if (atomic_read(&chip->interrupt_sleep_count)) {
100287 - atomic_set(&chip->interrupt_sleep_count, 0);
100288 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100289 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100290 wake_up(&chip->interrupt_sleep);
100291 }
100292 }
100293 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
100294 spin_lock_init(&chip->reg_lock);
100295 spin_lock_init(&chip->voice_lock);
100296 init_waitqueue_head(&chip->interrupt_sleep);
100297 - atomic_set(&chip->interrupt_sleep_count, 0);
100298 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100299 chip->card = card;
100300 chip->pci = pci;
100301 chip->irq = -1;
100302 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
100303 index 6b81d0c..031c056 100644
100304 --- a/sound/soc/fsl/fsl_ssi.c
100305 +++ b/sound/soc/fsl/fsl_ssi.c
100306 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
100307 {
100308 struct fsl_ssi_private *ssi_private;
100309 int ret = 0;
100310 - struct device_attribute *dev_attr = NULL;
100311 + device_attribute_no_const *dev_attr = NULL;
100312 struct device_node *np = pdev->dev.of_node;
100313 const char *p, *sprop;
100314 const uint32_t *iprop;
100315 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
100316 index 1a38be0..66809d1 100644
100317 --- a/sound/soc/soc-core.c
100318 +++ b/sound/soc/soc-core.c
100319 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
100320 if (ret)
100321 return ret;
100322
100323 - ops->warm_reset = snd_soc_ac97_warm_reset;
100324 - ops->reset = snd_soc_ac97_reset;
100325 + pax_open_kernel();
100326 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
100327 + *(void **)&ops->reset = snd_soc_ac97_reset;
100328 + pax_close_kernel();
100329
100330 snd_ac97_rst_cfg = cfg;
100331 return 0;
100332 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
100333 new file mode 100644
100334 index 0000000..50f2f2f
100335 --- /dev/null
100336 +++ b/tools/gcc/.gitignore
100337 @@ -0,0 +1 @@
100338 +size_overflow_hash.h
100339 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
100340 new file mode 100644
100341 index 0000000..144dbee
100342 --- /dev/null
100343 +++ b/tools/gcc/Makefile
100344 @@ -0,0 +1,45 @@
100345 +#CC := gcc
100346 +#PLUGIN_SOURCE_FILES := pax_plugin.c
100347 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
100348 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
100349 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
100350 +
100351 +ifeq ($(PLUGINCC),$(HOSTCC))
100352 +HOSTLIBS := hostlibs
100353 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
100354 +else
100355 +HOSTLIBS := hostcxxlibs
100356 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
100357 +endif
100358 +
100359 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
100360 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
100361 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
100362 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
100363 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
100364 +$(HOSTLIBS)-y += colorize_plugin.so
100365 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
100366 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
100367 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
100368 +
100369 +always := $($(HOSTLIBS)-y)
100370 +
100371 +constify_plugin-objs := constify_plugin.o
100372 +stackleak_plugin-objs := stackleak_plugin.o
100373 +kallocstat_plugin-objs := kallocstat_plugin.o
100374 +kernexec_plugin-objs := kernexec_plugin.o
100375 +checker_plugin-objs := checker_plugin.o
100376 +colorize_plugin-objs := colorize_plugin.o
100377 +size_overflow_plugin-objs := size_overflow_plugin.o
100378 +latent_entropy_plugin-objs := latent_entropy_plugin.o
100379 +structleak_plugin-objs := structleak_plugin.o
100380 +
100381 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
100382 +
100383 +quiet_cmd_build_size_overflow_hash = GENHASH $@
100384 + cmd_build_size_overflow_hash = \
100385 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
100386 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
100387 + $(call if_changed,build_size_overflow_hash)
100388 +
100389 +targets += size_overflow_hash.h
100390 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
100391 new file mode 100644
100392 index 0000000..22f03c0
100393 --- /dev/null
100394 +++ b/tools/gcc/checker_plugin.c
100395 @@ -0,0 +1,172 @@
100396 +/*
100397 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
100398 + * Licensed under the GPL v2
100399 + *
100400 + * Note: the choice of the license means that the compilation process is
100401 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100402 + * but for the kernel it doesn't matter since it doesn't link against
100403 + * any of the gcc libraries
100404 + *
100405 + * gcc plugin to implement various sparse (source code checker) features
100406 + *
100407 + * TODO:
100408 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100409 + *
100410 + * BUGS:
100411 + * - none known
100412 + */
100413 +#include "gcc-plugin.h"
100414 +#include "config.h"
100415 +#include "system.h"
100416 +#include "coretypes.h"
100417 +#include "tree.h"
100418 +#include "tree-pass.h"
100419 +#include "flags.h"
100420 +#include "intl.h"
100421 +#include "toplev.h"
100422 +#include "plugin.h"
100423 +//#include "expr.h" where are you...
100424 +#include "diagnostic.h"
100425 +#include "plugin-version.h"
100426 +#include "tm.h"
100427 +#include "function.h"
100428 +#include "basic-block.h"
100429 +#include "gimple.h"
100430 +#include "rtl.h"
100431 +#include "emit-rtl.h"
100432 +#include "tree-flow.h"
100433 +#include "target.h"
100434 +
100435 +extern void c_register_addr_space (const char *str, addr_space_t as);
100436 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
100437 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
100438 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
100439 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
100440 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
100441 +
100442 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100443 +extern rtx emit_move_insn(rtx x, rtx y);
100444 +
100445 +int plugin_is_GPL_compatible;
100446 +
100447 +static struct plugin_info checker_plugin_info = {
100448 + .version = "201111150100",
100449 + .help = NULL,
100450 +};
100451 +
100452 +#define ADDR_SPACE_KERNEL 0
100453 +#define ADDR_SPACE_FORCE_KERNEL 1
100454 +#define ADDR_SPACE_USER 2
100455 +#define ADDR_SPACE_FORCE_USER 3
100456 +#define ADDR_SPACE_IOMEM 0
100457 +#define ADDR_SPACE_FORCE_IOMEM 0
100458 +#define ADDR_SPACE_PERCPU 0
100459 +#define ADDR_SPACE_FORCE_PERCPU 0
100460 +#define ADDR_SPACE_RCU 0
100461 +#define ADDR_SPACE_FORCE_RCU 0
100462 +
100463 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
100464 +{
100465 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
100466 +}
100467 +
100468 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100469 +{
100470 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100471 +}
100472 +
100473 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100474 +{
100475 + return default_addr_space_valid_pointer_mode(mode, as);
100476 +}
100477 +
100478 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100479 +{
100480 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100481 +}
100482 +
100483 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100484 +{
100485 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100486 +}
100487 +
100488 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100489 +{
100490 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100491 + return true;
100492 +
100493 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100494 + return true;
100495 +
100496 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100497 + return true;
100498 +
100499 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100500 + return true;
100501 +
100502 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100503 + return true;
100504 +
100505 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100506 + return true;
100507 +
100508 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100509 + return true;
100510 +
100511 + return subset == superset;
100512 +}
100513 +
100514 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100515 +{
100516 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100517 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100518 +
100519 + return op;
100520 +}
100521 +
100522 +static void register_checker_address_spaces(void *event_data, void *data)
100523 +{
100524 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100525 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100526 + c_register_addr_space("__user", ADDR_SPACE_USER);
100527 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100528 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100529 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100530 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100531 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100532 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100533 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100534 +
100535 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100536 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100537 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100538 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100539 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100540 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100541 + targetm.addr_space.convert = checker_addr_space_convert;
100542 +}
100543 +
100544 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100545 +{
100546 + const char * const plugin_name = plugin_info->base_name;
100547 + const int argc = plugin_info->argc;
100548 + const struct plugin_argument * const argv = plugin_info->argv;
100549 + int i;
100550 +
100551 + if (!plugin_default_version_check(version, &gcc_version)) {
100552 + error(G_("incompatible gcc/plugin versions"));
100553 + return 1;
100554 + }
100555 +
100556 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100557 +
100558 + for (i = 0; i < argc; ++i)
100559 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100560 +
100561 + if (TARGET_64BIT == 0)
100562 + return 0;
100563 +
100564 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100565 +
100566 + return 0;
100567 +}
100568 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100569 new file mode 100644
100570 index 0000000..414fe5e
100571 --- /dev/null
100572 +++ b/tools/gcc/colorize_plugin.c
100573 @@ -0,0 +1,151 @@
100574 +/*
100575 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100576 + * Licensed under the GPL v2
100577 + *
100578 + * Note: the choice of the license means that the compilation process is
100579 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100580 + * but for the kernel it doesn't matter since it doesn't link against
100581 + * any of the gcc libraries
100582 + *
100583 + * gcc plugin to colorize diagnostic output
100584 + *
100585 + */
100586 +
100587 +#include "gcc-plugin.h"
100588 +#include "config.h"
100589 +#include "system.h"
100590 +#include "coretypes.h"
100591 +#include "tree.h"
100592 +#include "tree-pass.h"
100593 +#include "flags.h"
100594 +#include "intl.h"
100595 +#include "toplev.h"
100596 +#include "plugin.h"
100597 +#include "diagnostic.h"
100598 +#include "plugin-version.h"
100599 +#include "tm.h"
100600 +
100601 +int plugin_is_GPL_compatible;
100602 +
100603 +static struct plugin_info colorize_plugin_info = {
100604 + .version = "201302112000",
100605 + .help = NULL,
100606 +};
100607 +
100608 +#define GREEN "\033[32m\033[2m"
100609 +#define LIGHTGREEN "\033[32m\033[1m"
100610 +#define YELLOW "\033[33m\033[2m"
100611 +#define LIGHTYELLOW "\033[33m\033[1m"
100612 +#define RED "\033[31m\033[2m"
100613 +#define LIGHTRED "\033[31m\033[1m"
100614 +#define BLUE "\033[34m\033[2m"
100615 +#define LIGHTBLUE "\033[34m\033[1m"
100616 +#define BRIGHT "\033[m\033[1m"
100617 +#define NORMAL "\033[m"
100618 +
100619 +static diagnostic_starter_fn old_starter;
100620 +static diagnostic_finalizer_fn old_finalizer;
100621 +
100622 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100623 +{
100624 + const char *color;
100625 + char *newprefix;
100626 +
100627 + switch (diagnostic->kind) {
100628 + case DK_NOTE:
100629 + color = LIGHTBLUE;
100630 + break;
100631 +
100632 + case DK_PEDWARN:
100633 + case DK_WARNING:
100634 + color = LIGHTYELLOW;
100635 + break;
100636 +
100637 + case DK_ERROR:
100638 + case DK_FATAL:
100639 + case DK_ICE:
100640 + case DK_PERMERROR:
100641 + case DK_SORRY:
100642 + color = LIGHTRED;
100643 + break;
100644 +
100645 + default:
100646 + color = NORMAL;
100647 + }
100648 +
100649 + old_starter(context, diagnostic);
100650 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100651 + return;
100652 + pp_destroy_prefix(context->printer);
100653 + pp_set_prefix(context->printer, newprefix);
100654 +}
100655 +
100656 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100657 +{
100658 + old_finalizer(context, diagnostic);
100659 +}
100660 +
100661 +static void colorize_arm(void)
100662 +{
100663 + old_starter = diagnostic_starter(global_dc);
100664 + old_finalizer = diagnostic_finalizer(global_dc);
100665 +
100666 + diagnostic_starter(global_dc) = start_colorize;
100667 + diagnostic_finalizer(global_dc) = finalize_colorize;
100668 +}
100669 +
100670 +static unsigned int execute_colorize_rearm(void)
100671 +{
100672 + if (diagnostic_starter(global_dc) == start_colorize)
100673 + return 0;
100674 +
100675 + colorize_arm();
100676 + return 0;
100677 +}
100678 +
100679 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100680 + .pass = {
100681 + .type = SIMPLE_IPA_PASS,
100682 + .name = "colorize_rearm",
100683 +#if BUILDING_GCC_VERSION >= 4008
100684 + .optinfo_flags = OPTGROUP_NONE,
100685 +#endif
100686 + .gate = NULL,
100687 + .execute = execute_colorize_rearm,
100688 + .sub = NULL,
100689 + .next = NULL,
100690 + .static_pass_number = 0,
100691 + .tv_id = TV_NONE,
100692 + .properties_required = 0,
100693 + .properties_provided = 0,
100694 + .properties_destroyed = 0,
100695 + .todo_flags_start = 0,
100696 + .todo_flags_finish = 0
100697 + }
100698 +};
100699 +
100700 +static void colorize_start_unit(void *gcc_data, void *user_data)
100701 +{
100702 + colorize_arm();
100703 +}
100704 +
100705 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100706 +{
100707 + const char * const plugin_name = plugin_info->base_name;
100708 + struct register_pass_info colorize_rearm_pass_info = {
100709 + .pass = &pass_ipa_colorize_rearm.pass,
100710 + .reference_pass_name = "*free_lang_data",
100711 + .ref_pass_instance_number = 1,
100712 + .pos_op = PASS_POS_INSERT_AFTER
100713 + };
100714 +
100715 + if (!plugin_default_version_check(version, &gcc_version)) {
100716 + error(G_("incompatible gcc/plugin versions"));
100717 + return 1;
100718 + }
100719 +
100720 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100721 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100722 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100723 + return 0;
100724 +}
100725 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100726 new file mode 100644
100727 index 0000000..c17312d
100728 --- /dev/null
100729 +++ b/tools/gcc/constify_plugin.c
100730 @@ -0,0 +1,560 @@
100731 +/*
100732 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100733 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100734 + * Licensed under the GPL v2, or (at your option) v3
100735 + *
100736 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100737 + *
100738 + * Homepage:
100739 + * http://www.grsecurity.net/~ephox/const_plugin/
100740 + *
100741 + * Usage:
100742 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100743 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100744 + */
100745 +
100746 +#include "gcc-plugin.h"
100747 +#include "config.h"
100748 +#include "system.h"
100749 +#include "coretypes.h"
100750 +#include "tree.h"
100751 +#include "tree-pass.h"
100752 +#include "flags.h"
100753 +#include "intl.h"
100754 +#include "toplev.h"
100755 +#include "plugin.h"
100756 +#include "diagnostic.h"
100757 +#include "plugin-version.h"
100758 +#include "tm.h"
100759 +#include "function.h"
100760 +#include "basic-block.h"
100761 +#include "gimple.h"
100762 +#include "rtl.h"
100763 +#include "emit-rtl.h"
100764 +#include "tree-flow.h"
100765 +#include "target.h"
100766 +#include "langhooks.h"
100767 +
100768 +// should come from c-tree.h if only it were installed for gcc 4.5...
100769 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100770 +
100771 +// unused type flag in all versions 4.5-4.8
100772 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100773 +
100774 +int plugin_is_GPL_compatible;
100775 +
100776 +static struct plugin_info const_plugin_info = {
100777 + .version = "201305231310",
100778 + .help = "no-constify\tturn off constification\n",
100779 +};
100780 +
100781 +typedef struct {
100782 + bool has_fptr_field;
100783 + bool has_writable_field;
100784 + bool has_do_const_field;
100785 + bool has_no_const_field;
100786 +} constify_info;
100787 +
100788 +static const_tree get_field_type(const_tree field)
100789 +{
100790 + return strip_array_types(TREE_TYPE(field));
100791 +}
100792 +
100793 +static bool is_fptr(const_tree field)
100794 +{
100795 + const_tree ptr = get_field_type(field);
100796 +
100797 + if (TREE_CODE(ptr) != POINTER_TYPE)
100798 + return false;
100799 +
100800 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100801 +}
100802 +
100803 +/*
100804 + * determine whether the given structure type meets the requirements for automatic constification,
100805 + * including the constification attributes on nested structure types
100806 + */
100807 +static void constifiable(const_tree node, constify_info *cinfo)
100808 +{
100809 + const_tree field;
100810 +
100811 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100812 +
100813 + // e.g., pointer to structure fields while still constructing the structure type
100814 + if (TYPE_FIELDS(node) == NULL_TREE)
100815 + return;
100816 +
100817 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100818 + const_tree type = get_field_type(field);
100819 + enum tree_code code = TREE_CODE(type);
100820 +
100821 + if (node == type)
100822 + continue;
100823 +
100824 + if (is_fptr(field))
100825 + cinfo->has_fptr_field = true;
100826 + else if (!TREE_READONLY(field))
100827 + cinfo->has_writable_field = true;
100828 +
100829 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100830 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100831 + cinfo->has_do_const_field = true;
100832 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100833 + cinfo->has_no_const_field = true;
100834 + else
100835 + constifiable(type, cinfo);
100836 + }
100837 + }
100838 +}
100839 +
100840 +static bool constified(const_tree node)
100841 +{
100842 + constify_info cinfo = {
100843 + .has_fptr_field = false,
100844 + .has_writable_field = false,
100845 + .has_do_const_field = false,
100846 + .has_no_const_field = false
100847 + };
100848 +
100849 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100850 +
100851 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100852 + gcc_assert(!TYPE_READONLY(node));
100853 + return false;
100854 + }
100855 +
100856 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100857 + gcc_assert(TYPE_READONLY(node));
100858 + return true;
100859 + }
100860 +
100861 + constifiable(node, &cinfo);
100862 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100863 + return false;
100864 +
100865 + return TYPE_READONLY(node);
100866 +}
100867 +
100868 +static void deconstify_tree(tree node);
100869 +
100870 +static void deconstify_type(tree type)
100871 +{
100872 + tree field;
100873 +
100874 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100875 +
100876 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100877 + const_tree fieldtype = get_field_type(field);
100878 +
100879 + // special case handling of simple ptr-to-same-array-type members
100880 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100881 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100882 +
100883 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100884 + continue;
100885 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100886 + continue;
100887 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100888 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100889 + TREE_TYPE(TREE_TYPE(field)) = type;
100890 + }
100891 + continue;
100892 + }
100893 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100894 + continue;
100895 + if (!constified(fieldtype))
100896 + continue;
100897 +
100898 + deconstify_tree(field);
100899 + TREE_READONLY(field) = 0;
100900 + }
100901 + TYPE_READONLY(type) = 0;
100902 + C_TYPE_FIELDS_READONLY(type) = 0;
100903 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100904 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100905 +}
100906 +
100907 +static void deconstify_tree(tree node)
100908 +{
100909 + tree old_type, new_type, field;
100910 +
100911 + old_type = TREE_TYPE(node);
100912 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100913 + node = TREE_TYPE(node) = copy_node(old_type);
100914 + old_type = TREE_TYPE(old_type);
100915 + }
100916 +
100917 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100918 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100919 +
100920 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100921 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100922 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100923 + DECL_FIELD_CONTEXT(field) = new_type;
100924 +
100925 + deconstify_type(new_type);
100926 +
100927 + TREE_TYPE(node) = new_type;
100928 +}
100929 +
100930 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100931 +{
100932 + tree type;
100933 + constify_info cinfo = {
100934 + .has_fptr_field = false,
100935 + .has_writable_field = false,
100936 + .has_do_const_field = false,
100937 + .has_no_const_field = false
100938 + };
100939 +
100940 + *no_add_attrs = true;
100941 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100942 + error("%qE attribute does not apply to functions", name);
100943 + return NULL_TREE;
100944 + }
100945 +
100946 + if (TREE_CODE(*node) == PARM_DECL) {
100947 + error("%qE attribute does not apply to function parameters", name);
100948 + return NULL_TREE;
100949 + }
100950 +
100951 + if (TREE_CODE(*node) == VAR_DECL) {
100952 + error("%qE attribute does not apply to variables", name);
100953 + return NULL_TREE;
100954 + }
100955 +
100956 + if (TYPE_P(*node)) {
100957 + *no_add_attrs = false;
100958 + type = *node;
100959 + } else {
100960 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100961 + type = TREE_TYPE(*node);
100962 + }
100963 +
100964 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100965 + error("%qE attribute applies to struct and union types only", name);
100966 + return NULL_TREE;
100967 + }
100968 +
100969 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100970 + error("%qE attribute is already applied to the type", name);
100971 + return NULL_TREE;
100972 + }
100973 +
100974 + if (TYPE_P(*node)) {
100975 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100976 + error("%qE attribute is incompatible with 'do_const'", name);
100977 + return NULL_TREE;
100978 + }
100979 +
100980 + constifiable(type, &cinfo);
100981 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100982 + deconstify_tree(*node);
100983 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100984 + return NULL_TREE;
100985 + }
100986 +
100987 + error("%qE attribute used on type that is not constified", name);
100988 + return NULL_TREE;
100989 +}
100990 +
100991 +static void constify_type(tree type)
100992 +{
100993 + TYPE_READONLY(type) = 1;
100994 + C_TYPE_FIELDS_READONLY(type) = 1;
100995 + TYPE_CONSTIFY_VISITED(type) = 1;
100996 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100997 +}
100998 +
100999 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101000 +{
101001 + *no_add_attrs = true;
101002 + if (!TYPE_P(*node)) {
101003 + error("%qE attribute applies to types only", name);
101004 + return NULL_TREE;
101005 + }
101006 +
101007 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
101008 + error("%qE attribute applies to struct and union types only", name);
101009 + return NULL_TREE;
101010 + }
101011 +
101012 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
101013 + error("%qE attribute is already applied to the type", name);
101014 + return NULL_TREE;
101015 + }
101016 +
101017 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
101018 + error("%qE attribute is incompatible with 'no_const'", name);
101019 + return NULL_TREE;
101020 + }
101021 +
101022 + *no_add_attrs = false;
101023 + return NULL_TREE;
101024 +}
101025 +
101026 +static struct attribute_spec no_const_attr = {
101027 + .name = "no_const",
101028 + .min_length = 0,
101029 + .max_length = 0,
101030 + .decl_required = false,
101031 + .type_required = false,
101032 + .function_type_required = false,
101033 + .handler = handle_no_const_attribute,
101034 +#if BUILDING_GCC_VERSION >= 4007
101035 + .affects_type_identity = true
101036 +#endif
101037 +};
101038 +
101039 +static struct attribute_spec do_const_attr = {
101040 + .name = "do_const",
101041 + .min_length = 0,
101042 + .max_length = 0,
101043 + .decl_required = false,
101044 + .type_required = false,
101045 + .function_type_required = false,
101046 + .handler = handle_do_const_attribute,
101047 +#if BUILDING_GCC_VERSION >= 4007
101048 + .affects_type_identity = true
101049 +#endif
101050 +};
101051 +
101052 +static void register_attributes(void *event_data, void *data)
101053 +{
101054 + register_attribute(&no_const_attr);
101055 + register_attribute(&do_const_attr);
101056 +}
101057 +
101058 +static void finish_type(void *event_data, void *data)
101059 +{
101060 + tree type = (tree)event_data;
101061 + constify_info cinfo = {
101062 + .has_fptr_field = false,
101063 + .has_writable_field = false,
101064 + .has_do_const_field = false,
101065 + .has_no_const_field = false
101066 + };
101067 +
101068 + if (type == NULL_TREE || type == error_mark_node)
101069 + return;
101070 +
101071 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
101072 + return;
101073 +
101074 + constifiable(type, &cinfo);
101075 +
101076 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
101077 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101078 + return;
101079 + if (cinfo.has_writable_field)
101080 + return;
101081 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
101082 + return;
101083 + }
101084 +
101085 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
101086 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
101087 + deconstify_type(type);
101088 + TYPE_CONSTIFY_VISITED(type) = 1;
101089 + } else
101090 + error("'no_const' attribute used on type that is not constified");
101091 + return;
101092 + }
101093 +
101094 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101095 + constify_type(type);
101096 + return;
101097 + }
101098 +
101099 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
101100 + constify_type(type);
101101 + return;
101102 + }
101103 +
101104 + deconstify_type(type);
101105 + TYPE_CONSTIFY_VISITED(type) = 1;
101106 +}
101107 +
101108 +static void check_global_variables(void)
101109 +{
101110 + struct varpool_node *node;
101111 +
101112 +#if BUILDING_GCC_VERSION <= 4007
101113 + for (node = varpool_nodes; node; node = node->next) {
101114 + tree var = node->decl;
101115 +#else
101116 + FOR_EACH_VARIABLE(node) {
101117 + tree var = node->symbol.decl;
101118 +#endif
101119 + tree type = TREE_TYPE(var);
101120 +
101121 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101122 + continue;
101123 +
101124 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101125 + continue;
101126 +
101127 + if (!TYPE_CONSTIFY_VISITED(type))
101128 + continue;
101129 +
101130 + if (DECL_EXTERNAL(var))
101131 + continue;
101132 +
101133 + if (DECL_INITIAL(var))
101134 + continue;
101135 +
101136 + // this works around a gcc bug/feature where uninitialized globals
101137 + // are moved into the .bss section regardless of any constification
101138 + DECL_INITIAL(var) = build_constructor(type, NULL);
101139 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
101140 + }
101141 +}
101142 +
101143 +static unsigned int check_local_variables(void)
101144 +{
101145 + unsigned int ret = 0;
101146 + tree var;
101147 +
101148 +#if BUILDING_GCC_VERSION == 4005
101149 + tree vars;
101150 +#else
101151 + unsigned int i;
101152 +#endif
101153 +
101154 +#if BUILDING_GCC_VERSION == 4005
101155 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
101156 + var = TREE_VALUE(vars);
101157 +#else
101158 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
101159 +#endif
101160 + tree type = TREE_TYPE(var);
101161 +
101162 + gcc_assert(DECL_P(var));
101163 + if (is_global_var(var))
101164 + continue;
101165 +
101166 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101167 + continue;
101168 +
101169 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101170 + continue;
101171 +
101172 + if (!TYPE_CONSTIFY_VISITED(type))
101173 + continue;
101174 +
101175 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
101176 + ret = 1;
101177 + }
101178 + return ret;
101179 +}
101180 +
101181 +static unsigned int check_variables(void)
101182 +{
101183 + check_global_variables();
101184 + return check_local_variables();
101185 +}
101186 +
101187 + unsigned int ret = 0;
101188 +static struct gimple_opt_pass pass_local_variable = {
101189 + {
101190 + .type = GIMPLE_PASS,
101191 + .name = "check_variables",
101192 +#if BUILDING_GCC_VERSION >= 4008
101193 + .optinfo_flags = OPTGROUP_NONE,
101194 +#endif
101195 + .gate = NULL,
101196 + .execute = check_variables,
101197 + .sub = NULL,
101198 + .next = NULL,
101199 + .static_pass_number = 0,
101200 + .tv_id = TV_NONE,
101201 + .properties_required = 0,
101202 + .properties_provided = 0,
101203 + .properties_destroyed = 0,
101204 + .todo_flags_start = 0,
101205 + .todo_flags_finish = 0
101206 + }
101207 +};
101208 +
101209 +static struct {
101210 + const char *name;
101211 + const char *asm_op;
101212 +} sections[] = {
101213 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
101214 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
101215 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
101216 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
101217 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
101218 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
101219 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
101220 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
101221 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
101222 +};
101223 +
101224 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
101225 +
101226 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
101227 +{
101228 + size_t i;
101229 +
101230 + for (i = 0; i < ARRAY_SIZE(sections); i++)
101231 + if (!strcmp(sections[i].name, name))
101232 + return 0;
101233 + return old_section_type_flags(decl, name, reloc);
101234 +}
101235 +
101236 +static void constify_start_unit(void *gcc_data, void *user_data)
101237 +{
101238 +// size_t i;
101239 +
101240 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
101241 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
101242 +// sections[i].section = get_section(sections[i].name, 0, NULL);
101243 +
101244 + old_section_type_flags = targetm.section_type_flags;
101245 + targetm.section_type_flags = constify_section_type_flags;
101246 +}
101247 +
101248 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101249 +{
101250 + const char * const plugin_name = plugin_info->base_name;
101251 + const int argc = plugin_info->argc;
101252 + const struct plugin_argument * const argv = plugin_info->argv;
101253 + int i;
101254 + bool constify = true;
101255 +
101256 + struct register_pass_info local_variable_pass_info = {
101257 + .pass = &pass_local_variable.pass,
101258 + .reference_pass_name = "ssa",
101259 + .ref_pass_instance_number = 1,
101260 + .pos_op = PASS_POS_INSERT_BEFORE
101261 + };
101262 +
101263 + if (!plugin_default_version_check(version, &gcc_version)) {
101264 + error(G_("incompatible gcc/plugin versions"));
101265 + return 1;
101266 + }
101267 +
101268 + for (i = 0; i < argc; ++i) {
101269 + if (!(strcmp(argv[i].key, "no-constify"))) {
101270 + constify = false;
101271 + continue;
101272 + }
101273 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101274 + }
101275 +
101276 + if (strcmp(lang_hooks.name, "GNU C")) {
101277 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
101278 + constify = false;
101279 + }
101280 +
101281 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
101282 + if (constify) {
101283 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
101284 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
101285 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
101286 + }
101287 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101288 +
101289 + return 0;
101290 +}
101291 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
101292 new file mode 100644
101293 index 0000000..e518932
101294 --- /dev/null
101295 +++ b/tools/gcc/generate_size_overflow_hash.sh
101296 @@ -0,0 +1,94 @@
101297 +#!/bin/bash
101298 +
101299 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
101300 +
101301 +header1="size_overflow_hash.h"
101302 +database="size_overflow_hash.data"
101303 +n=65536
101304 +
101305 +usage() {
101306 +cat <<EOF
101307 +usage: $0 options
101308 +OPTIONS:
101309 + -h|--help help
101310 + -o header file
101311 + -d database file
101312 + -n hash array size
101313 +EOF
101314 + return 0
101315 +}
101316 +
101317 +while true
101318 +do
101319 + case "$1" in
101320 + -h|--help) usage && exit 0;;
101321 + -n) n=$2; shift 2;;
101322 + -o) header1="$2"; shift 2;;
101323 + -d) database="$2"; shift 2;;
101324 + --) shift 1; break ;;
101325 + *) break ;;
101326 + esac
101327 +done
101328 +
101329 +create_defines() {
101330 + for i in `seq 0 31`
101331 + do
101332 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
101333 + done
101334 + echo >> "$header1"
101335 +}
101336 +
101337 +create_structs() {
101338 + rm -f "$header1"
101339 +
101340 + create_defines
101341 +
101342 + cat "$database" | while read data
101343 + do
101344 + data_array=($data)
101345 + struct_hash_name="${data_array[0]}"
101346 + funcn="${data_array[1]}"
101347 + params="${data_array[2]}"
101348 + next="${data_array[4]}"
101349 +
101350 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
101351 +
101352 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
101353 + echo -en "\t.param\t= " >> "$header1"
101354 + line=
101355 + for param_num in ${params//-/ };
101356 + do
101357 + line="${line}PARAM"$param_num"|"
101358 + done
101359 +
101360 + echo -e "${line%?},\n};\n" >> "$header1"
101361 + done
101362 +}
101363 +
101364 +create_headers() {
101365 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
101366 +}
101367 +
101368 +create_array_elements() {
101369 + index=0
101370 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
101371 + do
101372 + data_array=($data)
101373 + i="${data_array[3]}"
101374 + hash="${data_array[0]}"
101375 + while [[ $index -lt $i ]]
101376 + do
101377 + echo -e "\t["$index"]\t= NULL," >> "$header1"
101378 + index=$(($index + 1))
101379 + done
101380 + index=$(($index + 1))
101381 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
101382 + done
101383 + echo '};' >> $header1
101384 +}
101385 +
101386 +create_structs
101387 +create_headers
101388 +create_array_elements
101389 +
101390 +exit 0
101391 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
101392 new file mode 100644
101393 index 0000000..568b360
101394 --- /dev/null
101395 +++ b/tools/gcc/kallocstat_plugin.c
101396 @@ -0,0 +1,170 @@
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 find the distribution of k*alloc sizes
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 +
101433 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101434 +
101435 +int plugin_is_GPL_compatible;
101436 +
101437 +static const char * const kalloc_functions[] = {
101438 + "__kmalloc",
101439 + "kmalloc",
101440 + "kmalloc_large",
101441 + "kmalloc_node",
101442 + "kmalloc_order",
101443 + "kmalloc_order_trace",
101444 + "kmalloc_slab",
101445 + "kzalloc",
101446 + "kzalloc_node",
101447 +};
101448 +
101449 +static struct plugin_info kallocstat_plugin_info = {
101450 + .version = "201302112000",
101451 +};
101452 +
101453 +static unsigned int execute_kallocstat(void);
101454 +
101455 +static struct gimple_opt_pass kallocstat_pass = {
101456 + .pass = {
101457 + .type = GIMPLE_PASS,
101458 + .name = "kallocstat",
101459 +#if BUILDING_GCC_VERSION >= 4008
101460 + .optinfo_flags = OPTGROUP_NONE,
101461 +#endif
101462 + .gate = NULL,
101463 + .execute = execute_kallocstat,
101464 + .sub = NULL,
101465 + .next = NULL,
101466 + .static_pass_number = 0,
101467 + .tv_id = TV_NONE,
101468 + .properties_required = 0,
101469 + .properties_provided = 0,
101470 + .properties_destroyed = 0,
101471 + .todo_flags_start = 0,
101472 + .todo_flags_finish = 0
101473 + }
101474 +};
101475 +
101476 +static bool is_kalloc(const char *fnname)
101477 +{
101478 + size_t i;
101479 +
101480 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101481 + if (!strcmp(fnname, kalloc_functions[i]))
101482 + return true;
101483 + return false;
101484 +}
101485 +
101486 +static unsigned int execute_kallocstat(void)
101487 +{
101488 + basic_block bb;
101489 +
101490 + // 1. loop through BBs and GIMPLE statements
101491 + FOR_EACH_BB(bb) {
101492 + gimple_stmt_iterator gsi;
101493 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101494 + // gimple match:
101495 + tree fndecl, size;
101496 + gimple call_stmt;
101497 + const char *fnname;
101498 +
101499 + // is it a call
101500 + call_stmt = gsi_stmt(gsi);
101501 + if (!is_gimple_call(call_stmt))
101502 + continue;
101503 + fndecl = gimple_call_fndecl(call_stmt);
101504 + if (fndecl == NULL_TREE)
101505 + continue;
101506 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101507 + continue;
101508 +
101509 + // is it a call to k*alloc
101510 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101511 + if (!is_kalloc(fnname))
101512 + continue;
101513 +
101514 + // is the size arg the result of a simple const assignment
101515 + size = gimple_call_arg(call_stmt, 0);
101516 + while (true) {
101517 + gimple def_stmt;
101518 + expanded_location xloc;
101519 + size_t size_val;
101520 +
101521 + if (TREE_CODE(size) != SSA_NAME)
101522 + break;
101523 + def_stmt = SSA_NAME_DEF_STMT(size);
101524 + if (!def_stmt || !is_gimple_assign(def_stmt))
101525 + break;
101526 + if (gimple_num_ops(def_stmt) != 2)
101527 + break;
101528 + size = gimple_assign_rhs1(def_stmt);
101529 + if (!TREE_CONSTANT(size))
101530 + continue;
101531 + xloc = expand_location(gimple_location(def_stmt));
101532 + if (!xloc.file)
101533 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101534 + size_val = TREE_INT_CST_LOW(size);
101535 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101536 + break;
101537 + }
101538 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101539 +//debug_tree(gimple_call_fn(call_stmt));
101540 +//print_node(stderr, "pax", fndecl, 4);
101541 + }
101542 + }
101543 +
101544 + return 0;
101545 +}
101546 +
101547 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101548 +{
101549 + const char * const plugin_name = plugin_info->base_name;
101550 + struct register_pass_info kallocstat_pass_info = {
101551 + .pass = &kallocstat_pass.pass,
101552 + .reference_pass_name = "ssa",
101553 + .ref_pass_instance_number = 1,
101554 + .pos_op = PASS_POS_INSERT_AFTER
101555 + };
101556 +
101557 + if (!plugin_default_version_check(version, &gcc_version)) {
101558 + error(G_("incompatible gcc/plugin versions"));
101559 + return 1;
101560 + }
101561 +
101562 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101563 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101564 +
101565 + return 0;
101566 +}
101567 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101568 new file mode 100644
101569 index 0000000..698da67
101570 --- /dev/null
101571 +++ b/tools/gcc/kernexec_plugin.c
101572 @@ -0,0 +1,471 @@
101573 +/*
101574 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101575 + * Licensed under the GPL v2
101576 + *
101577 + * Note: the choice of the license means that the compilation process is
101578 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101579 + * but for the kernel it doesn't matter since it doesn't link against
101580 + * any of the gcc libraries
101581 + *
101582 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101583 + *
101584 + * TODO:
101585 + *
101586 + * BUGS:
101587 + * - none known
101588 + */
101589 +#include "gcc-plugin.h"
101590 +#include "config.h"
101591 +#include "system.h"
101592 +#include "coretypes.h"
101593 +#include "tree.h"
101594 +#include "tree-pass.h"
101595 +#include "flags.h"
101596 +#include "intl.h"
101597 +#include "toplev.h"
101598 +#include "plugin.h"
101599 +//#include "expr.h" where are you...
101600 +#include "diagnostic.h"
101601 +#include "plugin-version.h"
101602 +#include "tm.h"
101603 +#include "function.h"
101604 +#include "basic-block.h"
101605 +#include "gimple.h"
101606 +#include "rtl.h"
101607 +#include "emit-rtl.h"
101608 +#include "tree-flow.h"
101609 +
101610 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101611 +extern rtx emit_move_insn(rtx x, rtx y);
101612 +
101613 +#if BUILDING_GCC_VERSION <= 4006
101614 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101615 +#endif
101616 +
101617 +#if BUILDING_GCC_VERSION >= 4008
101618 +#define TODO_dump_func 0
101619 +#endif
101620 +
101621 +int plugin_is_GPL_compatible;
101622 +
101623 +static struct plugin_info kernexec_plugin_info = {
101624 + .version = "201308230150",
101625 + .help = "method=[bts|or]\tinstrumentation method\n"
101626 +};
101627 +
101628 +static unsigned int execute_kernexec_reload(void);
101629 +static unsigned int execute_kernexec_fptr(void);
101630 +static unsigned int execute_kernexec_retaddr(void);
101631 +static bool kernexec_cmodel_check(void);
101632 +
101633 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101634 +static void (*kernexec_instrument_retaddr)(rtx);
101635 +
101636 +static struct gimple_opt_pass kernexec_reload_pass = {
101637 + .pass = {
101638 + .type = GIMPLE_PASS,
101639 + .name = "kernexec_reload",
101640 +#if BUILDING_GCC_VERSION >= 4008
101641 + .optinfo_flags = OPTGROUP_NONE,
101642 +#endif
101643 + .gate = kernexec_cmodel_check,
101644 + .execute = execute_kernexec_reload,
101645 + .sub = NULL,
101646 + .next = NULL,
101647 + .static_pass_number = 0,
101648 + .tv_id = TV_NONE,
101649 + .properties_required = 0,
101650 + .properties_provided = 0,
101651 + .properties_destroyed = 0,
101652 + .todo_flags_start = 0,
101653 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101654 + }
101655 +};
101656 +
101657 +static struct gimple_opt_pass kernexec_fptr_pass = {
101658 + .pass = {
101659 + .type = GIMPLE_PASS,
101660 + .name = "kernexec_fptr",
101661 +#if BUILDING_GCC_VERSION >= 4008
101662 + .optinfo_flags = OPTGROUP_NONE,
101663 +#endif
101664 + .gate = kernexec_cmodel_check,
101665 + .execute = execute_kernexec_fptr,
101666 + .sub = NULL,
101667 + .next = NULL,
101668 + .static_pass_number = 0,
101669 + .tv_id = TV_NONE,
101670 + .properties_required = 0,
101671 + .properties_provided = 0,
101672 + .properties_destroyed = 0,
101673 + .todo_flags_start = 0,
101674 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101675 + }
101676 +};
101677 +
101678 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101679 + .pass = {
101680 + .type = RTL_PASS,
101681 + .name = "kernexec_retaddr",
101682 +#if BUILDING_GCC_VERSION >= 4008
101683 + .optinfo_flags = OPTGROUP_NONE,
101684 +#endif
101685 + .gate = kernexec_cmodel_check,
101686 + .execute = execute_kernexec_retaddr,
101687 + .sub = NULL,
101688 + .next = NULL,
101689 + .static_pass_number = 0,
101690 + .tv_id = TV_NONE,
101691 + .properties_required = 0,
101692 + .properties_provided = 0,
101693 + .properties_destroyed = 0,
101694 + .todo_flags_start = 0,
101695 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101696 + }
101697 +};
101698 +
101699 +static bool kernexec_cmodel_check(void)
101700 +{
101701 + tree section;
101702 +
101703 + if (ix86_cmodel != CM_KERNEL)
101704 + return false;
101705 +
101706 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101707 + if (!section || !TREE_VALUE(section))
101708 + return true;
101709 +
101710 + section = TREE_VALUE(TREE_VALUE(section));
101711 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101712 + return true;
101713 +
101714 + return false;
101715 +}
101716 +
101717 +/*
101718 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101719 + */
101720 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101721 +{
101722 + gimple asm_movabs_stmt;
101723 +
101724 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101725 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101726 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101727 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101728 + update_stmt(asm_movabs_stmt);
101729 +}
101730 +
101731 +/*
101732 + * find all asm() stmts that clobber r10 and add a reload of r10
101733 + */
101734 +static unsigned int execute_kernexec_reload(void)
101735 +{
101736 + basic_block bb;
101737 +
101738 + // 1. loop through BBs and GIMPLE statements
101739 + FOR_EACH_BB(bb) {
101740 + gimple_stmt_iterator gsi;
101741 +
101742 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101743 + // gimple match: __asm__ ("" : : : "r10");
101744 + gimple asm_stmt;
101745 + size_t nclobbers;
101746 +
101747 + // is it an asm ...
101748 + asm_stmt = gsi_stmt(gsi);
101749 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101750 + continue;
101751 +
101752 + // ... clobbering r10
101753 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101754 + while (nclobbers--) {
101755 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101756 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101757 + continue;
101758 + kernexec_reload_fptr_mask(&gsi);
101759 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101760 + break;
101761 + }
101762 + }
101763 + }
101764 +
101765 + return 0;
101766 +}
101767 +
101768 +/*
101769 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101770 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101771 + */
101772 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101773 +{
101774 + gimple assign_intptr, assign_new_fptr, call_stmt;
101775 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101776 +
101777 + call_stmt = gsi_stmt(*gsi);
101778 + old_fptr = gimple_call_fn(call_stmt);
101779 +
101780 + // create temporary unsigned long variable used for bitops and cast fptr to it
101781 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101782 +#if BUILDING_GCC_VERSION <= 4007
101783 + add_referenced_var(intptr);
101784 +#endif
101785 + intptr = make_ssa_name(intptr, NULL);
101786 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101787 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101788 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101789 + update_stmt(assign_intptr);
101790 +
101791 + // apply logical or to temporary unsigned long and bitmask
101792 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101793 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101794 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101795 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101796 + assign_intptr = gimple_build_assign(intptr, orptr);
101797 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101798 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101799 + update_stmt(assign_intptr);
101800 +
101801 + // cast temporary unsigned long back to a temporary fptr variable
101802 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101803 +#if BUILDING_GCC_VERSION <= 4007
101804 + add_referenced_var(new_fptr);
101805 +#endif
101806 + new_fptr = make_ssa_name(new_fptr, NULL);
101807 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101808 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101809 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101810 + update_stmt(assign_new_fptr);
101811 +
101812 + // replace call stmt fn with the new fptr
101813 + gimple_call_set_fn(call_stmt, new_fptr);
101814 + update_stmt(call_stmt);
101815 +}
101816 +
101817 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101818 +{
101819 + gimple asm_or_stmt, call_stmt;
101820 + tree old_fptr, new_fptr, input, output;
101821 +#if BUILDING_GCC_VERSION <= 4007
101822 + VEC(tree, gc) *inputs = NULL;
101823 + VEC(tree, gc) *outputs = NULL;
101824 +#else
101825 + vec<tree, va_gc> *inputs = NULL;
101826 + vec<tree, va_gc> *outputs = NULL;
101827 +#endif
101828 +
101829 + call_stmt = gsi_stmt(*gsi);
101830 + old_fptr = gimple_call_fn(call_stmt);
101831 +
101832 + // create temporary fptr variable
101833 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101834 +#if BUILDING_GCC_VERSION <= 4007
101835 + add_referenced_var(new_fptr);
101836 +#endif
101837 + new_fptr = make_ssa_name(new_fptr, NULL);
101838 +
101839 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101840 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101841 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101842 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101843 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101844 +#if BUILDING_GCC_VERSION <= 4007
101845 + VEC_safe_push(tree, gc, inputs, input);
101846 + VEC_safe_push(tree, gc, outputs, output);
101847 +#else
101848 + vec_safe_push(inputs, input);
101849 + vec_safe_push(outputs, output);
101850 +#endif
101851 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101852 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101853 + gimple_asm_set_volatile(asm_or_stmt, true);
101854 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101855 + update_stmt(asm_or_stmt);
101856 +
101857 + // replace call stmt fn with the new fptr
101858 + gimple_call_set_fn(call_stmt, new_fptr);
101859 + update_stmt(call_stmt);
101860 +}
101861 +
101862 +/*
101863 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101864 + */
101865 +static unsigned int execute_kernexec_fptr(void)
101866 +{
101867 + basic_block bb;
101868 +
101869 + // 1. loop through BBs and GIMPLE statements
101870 + FOR_EACH_BB(bb) {
101871 + gimple_stmt_iterator gsi;
101872 +
101873 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101874 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101875 + tree fn;
101876 + gimple call_stmt;
101877 +
101878 + // is it a call ...
101879 + call_stmt = gsi_stmt(gsi);
101880 + if (!is_gimple_call(call_stmt))
101881 + continue;
101882 + fn = gimple_call_fn(call_stmt);
101883 + if (TREE_CODE(fn) == ADDR_EXPR)
101884 + continue;
101885 + if (TREE_CODE(fn) != SSA_NAME)
101886 + gcc_unreachable();
101887 +
101888 + // ... through a function pointer
101889 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101890 + fn = SSA_NAME_VAR(fn);
101891 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101892 + debug_tree(fn);
101893 + gcc_unreachable();
101894 + }
101895 + }
101896 + fn = TREE_TYPE(fn);
101897 + if (TREE_CODE(fn) != POINTER_TYPE)
101898 + continue;
101899 + fn = TREE_TYPE(fn);
101900 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101901 + continue;
101902 +
101903 + kernexec_instrument_fptr(&gsi);
101904 +
101905 +//debug_tree(gimple_call_fn(call_stmt));
101906 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101907 + }
101908 + }
101909 +
101910 + return 0;
101911 +}
101912 +
101913 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101914 +static void kernexec_instrument_retaddr_bts(rtx insn)
101915 +{
101916 + rtx btsq;
101917 + rtvec argvec, constraintvec, labelvec;
101918 + int line;
101919 +
101920 + // create asm volatile("btsq $63,(%%rsp)":::)
101921 + argvec = rtvec_alloc(0);
101922 + constraintvec = rtvec_alloc(0);
101923 + labelvec = rtvec_alloc(0);
101924 + line = expand_location(RTL_LOCATION(insn)).line;
101925 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101926 + MEM_VOLATILE_P(btsq) = 1;
101927 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101928 + emit_insn_before(btsq, insn);
101929 +}
101930 +
101931 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101932 +static void kernexec_instrument_retaddr_or(rtx insn)
101933 +{
101934 + rtx orq;
101935 + rtvec argvec, constraintvec, labelvec;
101936 + int line;
101937 +
101938 + // create asm volatile("orq %%r10,(%%rsp)":::)
101939 + argvec = rtvec_alloc(0);
101940 + constraintvec = rtvec_alloc(0);
101941 + labelvec = rtvec_alloc(0);
101942 + line = expand_location(RTL_LOCATION(insn)).line;
101943 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101944 + MEM_VOLATILE_P(orq) = 1;
101945 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101946 + emit_insn_before(orq, insn);
101947 +}
101948 +
101949 +/*
101950 + * find all asm level function returns and forcibly set the highest bit of the return address
101951 + */
101952 +static unsigned int execute_kernexec_retaddr(void)
101953 +{
101954 + rtx insn;
101955 +
101956 + // 1. find function returns
101957 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101958 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101959 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101960 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101961 + rtx body;
101962 +
101963 + // is it a retn
101964 + if (!JUMP_P(insn))
101965 + continue;
101966 + body = PATTERN(insn);
101967 + if (GET_CODE(body) == PARALLEL)
101968 + body = XVECEXP(body, 0, 0);
101969 + if (!ANY_RETURN_P(body))
101970 + continue;
101971 + kernexec_instrument_retaddr(insn);
101972 + }
101973 +
101974 +// print_simple_rtl(stderr, get_insns());
101975 +// print_rtl(stderr, get_insns());
101976 +
101977 + return 0;
101978 +}
101979 +
101980 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101981 +{
101982 + const char * const plugin_name = plugin_info->base_name;
101983 + const int argc = plugin_info->argc;
101984 + const struct plugin_argument * const argv = plugin_info->argv;
101985 + int i;
101986 + struct register_pass_info kernexec_reload_pass_info = {
101987 + .pass = &kernexec_reload_pass.pass,
101988 + .reference_pass_name = "ssa",
101989 + .ref_pass_instance_number = 1,
101990 + .pos_op = PASS_POS_INSERT_AFTER
101991 + };
101992 + struct register_pass_info kernexec_fptr_pass_info = {
101993 + .pass = &kernexec_fptr_pass.pass,
101994 + .reference_pass_name = "ssa",
101995 + .ref_pass_instance_number = 1,
101996 + .pos_op = PASS_POS_INSERT_AFTER
101997 + };
101998 + struct register_pass_info kernexec_retaddr_pass_info = {
101999 + .pass = &kernexec_retaddr_pass.pass,
102000 + .reference_pass_name = "pro_and_epilogue",
102001 + .ref_pass_instance_number = 1,
102002 + .pos_op = PASS_POS_INSERT_AFTER
102003 + };
102004 +
102005 + if (!plugin_default_version_check(version, &gcc_version)) {
102006 + error(G_("incompatible gcc/plugin versions"));
102007 + return 1;
102008 + }
102009 +
102010 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
102011 +
102012 + if (TARGET_64BIT == 0)
102013 + return 0;
102014 +
102015 + for (i = 0; i < argc; ++i) {
102016 + if (!strcmp(argv[i].key, "method")) {
102017 + if (!argv[i].value) {
102018 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102019 + continue;
102020 + }
102021 + if (!strcmp(argv[i].value, "bts")) {
102022 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102023 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102024 + } else if (!strcmp(argv[i].value, "or")) {
102025 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
102026 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
102027 + fix_register("r10", 1, 1);
102028 + } else
102029 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102030 + continue;
102031 + }
102032 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102033 + }
102034 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
102035 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
102036 +
102037 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
102038 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
102039 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
102040 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
102041 +
102042 + return 0;
102043 +}
102044 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
102045 new file mode 100644
102046 index 0000000..679b9ef
102047 --- /dev/null
102048 +++ b/tools/gcc/latent_entropy_plugin.c
102049 @@ -0,0 +1,335 @@
102050 +/*
102051 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
102052 + * Licensed under the GPL v2
102053 + *
102054 + * Note: the choice of the license means that the compilation process is
102055 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102056 + * but for the kernel it doesn't matter since it doesn't link against
102057 + * any of the gcc libraries
102058 + *
102059 + * gcc plugin to help generate a little bit of entropy from program state,
102060 + * used during boot in the kernel
102061 + *
102062 + * TODO:
102063 + * - add ipa pass to identify not explicitly marked candidate functions
102064 + * - mix in more program state (function arguments/return values, loop variables, etc)
102065 + * - more instrumentation control via attribute parameters
102066 + *
102067 + * BUGS:
102068 + * - LTO needs -flto-partition=none for now
102069 + */
102070 +#include "gcc-plugin.h"
102071 +#include "config.h"
102072 +#include "system.h"
102073 +#include "coretypes.h"
102074 +#include "tree.h"
102075 +#include "tree-pass.h"
102076 +#include "flags.h"
102077 +#include "intl.h"
102078 +#include "toplev.h"
102079 +#include "plugin.h"
102080 +//#include "expr.h" where are you...
102081 +#include "diagnostic.h"
102082 +#include "plugin-version.h"
102083 +#include "tm.h"
102084 +#include "function.h"
102085 +#include "basic-block.h"
102086 +#include "gimple.h"
102087 +#include "rtl.h"
102088 +#include "emit-rtl.h"
102089 +#include "tree-flow.h"
102090 +#include "langhooks.h"
102091 +
102092 +#if BUILDING_GCC_VERSION >= 4008
102093 +#define TODO_dump_func 0
102094 +#endif
102095 +
102096 +int plugin_is_GPL_compatible;
102097 +
102098 +static tree latent_entropy_decl;
102099 +
102100 +static struct plugin_info latent_entropy_plugin_info = {
102101 + .version = "201308230230",
102102 + .help = NULL
102103 +};
102104 +
102105 +static unsigned int execute_latent_entropy(void);
102106 +static bool gate_latent_entropy(void);
102107 +
102108 +static struct gimple_opt_pass latent_entropy_pass = {
102109 + .pass = {
102110 + .type = GIMPLE_PASS,
102111 + .name = "latent_entropy",
102112 +#if BUILDING_GCC_VERSION >= 4008
102113 + .optinfo_flags = OPTGROUP_NONE,
102114 +#endif
102115 + .gate = gate_latent_entropy,
102116 + .execute = execute_latent_entropy,
102117 + .sub = NULL,
102118 + .next = NULL,
102119 + .static_pass_number = 0,
102120 + .tv_id = TV_NONE,
102121 + .properties_required = PROP_gimple_leh | PROP_cfg,
102122 + .properties_provided = 0,
102123 + .properties_destroyed = 0,
102124 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102125 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102126 + }
102127 +};
102128 +
102129 +static unsigned HOST_WIDE_INT seed;
102130 +static unsigned HOST_WIDE_INT get_random_const(void)
102131 +{
102132 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
102133 + return seed;
102134 +}
102135 +
102136 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102137 +{
102138 + switch (TREE_CODE(*node)) {
102139 + default:
102140 + *no_add_attrs = true;
102141 + error("%qE attribute only applies to functions and variables", name);
102142 + break;
102143 +
102144 + case VAR_DECL:
102145 + if (DECL_INITIAL(*node)) {
102146 + *no_add_attrs = true;
102147 + error("variable %qD with %qE attribute must not be initialized", *node, name);
102148 + break;
102149 + }
102150 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
102151 + break;
102152 +
102153 + case FUNCTION_DECL:
102154 + break;
102155 + }
102156 +
102157 + return NULL_TREE;
102158 +}
102159 +
102160 +static struct attribute_spec latent_entropy_attr = {
102161 + .name = "latent_entropy",
102162 + .min_length = 0,
102163 + .max_length = 0,
102164 + .decl_required = true,
102165 + .type_required = false,
102166 + .function_type_required = false,
102167 + .handler = handle_latent_entropy_attribute,
102168 +#if BUILDING_GCC_VERSION >= 4007
102169 + .affects_type_identity = false
102170 +#endif
102171 +};
102172 +
102173 +static void register_attributes(void *event_data, void *data)
102174 +{
102175 + register_attribute(&latent_entropy_attr);
102176 +}
102177 +
102178 +static bool gate_latent_entropy(void)
102179 +{
102180 + tree latent_entropy_attr;
102181 +
102182 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
102183 + return latent_entropy_attr != NULL_TREE;
102184 +}
102185 +
102186 +static enum tree_code get_op(tree *rhs)
102187 +{
102188 + static enum tree_code op;
102189 + unsigned HOST_WIDE_INT random_const;
102190 +
102191 + random_const = get_random_const();
102192 +
102193 + switch (op) {
102194 + case BIT_XOR_EXPR:
102195 + op = PLUS_EXPR;
102196 + break;
102197 +
102198 + case PLUS_EXPR:
102199 + if (rhs) {
102200 + op = LROTATE_EXPR;
102201 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
102202 + break;
102203 + }
102204 +
102205 + case LROTATE_EXPR:
102206 + default:
102207 + op = BIT_XOR_EXPR;
102208 + break;
102209 + }
102210 + if (rhs)
102211 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
102212 + return op;
102213 +}
102214 +
102215 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
102216 +{
102217 + gimple_stmt_iterator gsi;
102218 + gimple assign;
102219 + tree addxorrol, rhs;
102220 + enum tree_code op;
102221 +
102222 + op = get_op(&rhs);
102223 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
102224 + assign = gimple_build_assign(local_entropy, addxorrol);
102225 + gsi = gsi_after_labels(bb);
102226 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102227 + update_stmt(assign);
102228 +//debug_bb(bb);
102229 +}
102230 +
102231 +static void perturb_latent_entropy(basic_block bb, tree rhs)
102232 +{
102233 + gimple_stmt_iterator gsi;
102234 + gimple assign;
102235 + tree addxorrol, temp;
102236 +
102237 + // 1. create temporary copy of latent_entropy
102238 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
102239 +#if BUILDING_GCC_VERSION <= 4007
102240 + add_referenced_var(temp);
102241 +#endif
102242 +
102243 + // 2. read...
102244 + temp = make_ssa_name(temp, NULL);
102245 + assign = gimple_build_assign(temp, latent_entropy_decl);
102246 + SSA_NAME_DEF_STMT(temp) = assign;
102247 +#if BUILDING_GCC_VERSION <= 4007
102248 + add_referenced_var(latent_entropy_decl);
102249 +#endif
102250 + gsi = gsi_after_labels(bb);
102251 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102252 + update_stmt(assign);
102253 +
102254 + // 3. ...modify...
102255 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
102256 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
102257 + assign = gimple_build_assign(temp, addxorrol);
102258 + SSA_NAME_DEF_STMT(temp) = assign;
102259 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102260 + update_stmt(assign);
102261 +
102262 + // 4. ...write latent_entropy
102263 + assign = gimple_build_assign(latent_entropy_decl, temp);
102264 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102265 + update_stmt(assign);
102266 +}
102267 +
102268 +static unsigned int execute_latent_entropy(void)
102269 +{
102270 + basic_block bb;
102271 + gimple assign;
102272 + gimple_stmt_iterator gsi;
102273 + tree local_entropy;
102274 +
102275 + if (!latent_entropy_decl) {
102276 + struct varpool_node *node;
102277 +
102278 +#if BUILDING_GCC_VERSION <= 4007
102279 + for (node = varpool_nodes; node; node = node->next) {
102280 + tree var = node->decl;
102281 +#else
102282 + FOR_EACH_VARIABLE(node) {
102283 + tree var = node->symbol.decl;
102284 +#endif
102285 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
102286 + continue;
102287 + latent_entropy_decl = var;
102288 +// debug_tree(var);
102289 + break;
102290 + }
102291 + if (!latent_entropy_decl) {
102292 +// debug_tree(current_function_decl);
102293 + return 0;
102294 + }
102295 + }
102296 +
102297 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102298 +
102299 + // 1. create local entropy variable
102300 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
102301 +#if BUILDING_GCC_VERSION <= 4007
102302 + add_referenced_var(local_entropy);
102303 + mark_sym_for_renaming(local_entropy);
102304 +#endif
102305 +
102306 + // 2. initialize local entropy variable
102307 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102308 + if (dom_info_available_p(CDI_DOMINATORS))
102309 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102310 + gsi = gsi_start_bb(bb);
102311 +
102312 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
102313 +// gimple_set_location(assign, loc);
102314 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102315 + update_stmt(assign);
102316 +//debug_bb(bb);
102317 + bb = bb->next_bb;
102318 +
102319 + // 3. instrument each BB with an operation on the local entropy variable
102320 + while (bb != EXIT_BLOCK_PTR) {
102321 + perturb_local_entropy(bb, local_entropy);
102322 +//debug_bb(bb);
102323 + bb = bb->next_bb;
102324 + };
102325 +
102326 + // 4. mix local entropy into the global entropy variable
102327 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
102328 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
102329 + return 0;
102330 +}
102331 +
102332 +static void start_unit_callback(void *gcc_data, void *user_data)
102333 +{
102334 + tree latent_entropy_type;
102335 +
102336 +#if BUILDING_GCC_VERSION >= 4007
102337 + seed = get_random_seed(false);
102338 +#else
102339 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
102340 + seed *= seed;
102341 +#endif
102342 +
102343 + if (in_lto_p)
102344 + return;
102345 +
102346 + // extern volatile u64 latent_entropy
102347 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
102348 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
102349 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
102350 +
102351 + TREE_STATIC(latent_entropy_decl) = 1;
102352 + TREE_PUBLIC(latent_entropy_decl) = 1;
102353 + TREE_USED(latent_entropy_decl) = 1;
102354 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
102355 + DECL_EXTERNAL(latent_entropy_decl) = 1;
102356 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
102357 + lang_hooks.decls.pushdecl(latent_entropy_decl);
102358 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
102359 +// varpool_finalize_decl(latent_entropy_decl);
102360 +// varpool_mark_needed_node(latent_entropy_decl);
102361 +}
102362 +
102363 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102364 +{
102365 + const char * const plugin_name = plugin_info->base_name;
102366 + struct register_pass_info latent_entropy_pass_info = {
102367 + .pass = &latent_entropy_pass.pass,
102368 + .reference_pass_name = "optimized",
102369 + .ref_pass_instance_number = 1,
102370 + .pos_op = PASS_POS_INSERT_BEFORE
102371 + };
102372 +
102373 + if (!plugin_default_version_check(version, &gcc_version)) {
102374 + error(G_("incompatible gcc/plugin versions"));
102375 + return 1;
102376 + }
102377 +
102378 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
102379 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102380 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
102381 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102382 +
102383 + return 0;
102384 +}
102385 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
102386 new file mode 100644
102387 index 0000000..0a9d518
102388 --- /dev/null
102389 +++ b/tools/gcc/size_overflow_hash.data
102390 @@ -0,0 +1,7637 @@
102391 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
102392 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
102393 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
102394 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
102395 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
102396 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
102397 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
102398 +padzero_55 padzero 1 55 &sel_read_policyvers_55
102399 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
102400 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
102401 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
102402 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
102403 +load_msg_95 load_msg 2 95 NULL
102404 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
102405 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 NULL nohasharray
102406 +write_all_supers_117 write_all_supers 0 117 &ipath_verbs_send_117
102407 +init_q_132 init_q 4 132 NULL
102408 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
102409 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
102410 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
102411 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
102412 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
102413 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
102414 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
102415 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
102416 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
102417 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
102418 +br_port_info_size_268 br_port_info_size 0 268 NULL
102419 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
102420 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
102421 +SYSC_connect_304 SYSC_connect 3 304 NULL
102422 +syslog_print_307 syslog_print 2 307 NULL
102423 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
102424 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
102425 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
102426 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
102427 +get_more_blocks_367 get_more_blocks 0 367 NULL
102428 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
102429 +hw_device_state_409 hw_device_state 0 409 NULL
102430 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
102431 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
102432 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
102433 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
102434 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
102435 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
102436 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
102437 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
102438 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
102439 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
102440 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
102441 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
102442 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
102443 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
102444 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
102445 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
102446 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
102447 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
102448 +cl_page_own0_599 cl_page_own0 0 599 NULL
102449 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
102450 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
102451 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
102452 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
102453 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
102454 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
102455 +clone_split_bio_633 clone_split_bio 6 633 NULL
102456 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
102457 +remap_to_cache_640 remap_to_cache 3 640 NULL
102458 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
102459 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
102460 +unlink_queued_645 unlink_queued 4 645 NULL
102461 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
102462 +div_u64_rem_672 div_u64_rem 0 672 NULL
102463 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
102464 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
102465 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
102466 +disk_max_parts_719 disk_max_parts 0 719 NULL
102467 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
102468 +dvb_video_write_754 dvb_video_write 3 754 NULL
102469 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
102470 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
102471 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
102472 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
102473 +if_writecmd_815 if_writecmd 2 815 NULL
102474 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
102475 +SyS_write_846 SyS_write 3 846 NULL
102476 +um_idi_read_850 um_idi_read 3 850 NULL
102477 +error_state_read_859 error_state_read 6 859 NULL
102478 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
102479 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
102480 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
102481 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
102482 +readw_931 readw 0 931 NULL
102483 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102484 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102485 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
102486 +memcmp_990 memcmp 0 990 NULL
102487 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
102488 +free_ind_block_999 free_ind_block 0 999 NULL
102489 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102490 +readreg_1017 readreg 0-1 1017 NULL
102491 +_do_truncate_1019 _do_truncate 2 1019 NULL
102492 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102493 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102494 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102495 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102496 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
102497 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102498 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102499 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
102500 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
102501 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102502 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
102503 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
102504 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
102505 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102506 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102507 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102508 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
102509 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102510 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102511 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
102512 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102513 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102514 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102515 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
102516 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102517 +nested_get_page_1252 nested_get_page 2 1252 NULL
102518 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102519 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102520 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102521 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102522 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
102523 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102524 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
102525 +ffs_1322 ffs 0 1322 NULL
102526 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
102527 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
102528 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102529 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102530 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
102531 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102532 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102533 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102534 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102535 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102536 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102537 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102538 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
102539 +zone_page_state_1393 zone_page_state 0 1393 NULL
102540 +file_read_actor_1401 file_read_actor 4 1401 NULL
102541 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
102542 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
102543 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
102544 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102545 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102546 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102547 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102548 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102549 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102550 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102551 +fpregs_set_1497 fpregs_set 4 1497 NULL
102552 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
102553 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102554 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102555 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102556 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
102557 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102558 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
102559 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102560 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102561 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102562 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
102563 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102564 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
102565 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102566 +rmap_add_1677 rmap_add 3 1677 NULL
102567 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102568 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
102569 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
102570 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
102571 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102572 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102573 +internal_create_group_1733 internal_create_group 0 1733 NULL
102574 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
102575 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102576 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102577 +cosa_write_1774 cosa_write 3 1774 NULL
102578 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102579 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
102580 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
102581 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102582 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102583 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102584 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
102585 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102586 +bdev_erase_1933 bdev_erase 3 1933 NULL
102587 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
102588 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102589 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102590 +read_swap_header_1957 read_swap_header 0 1957 NULL
102591 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102592 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102593 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
102594 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
102595 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102596 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
102597 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102598 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102599 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102600 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102601 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102602 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
102603 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102604 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102605 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
102606 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
102607 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
102608 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102609 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
102610 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102611 +audit_expand_2098 audit_expand 0 2098 NULL
102612 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102613 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
102614 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102615 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102616 +enable_read_2117 enable_read 3 2117 NULL
102617 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102618 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
102619 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102620 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102621 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102622 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
102623 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
102624 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
102625 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102626 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
102627 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102628 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102629 +vhci_write_2224 vhci_write 3 2224 NULL
102630 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
102631 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102632 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102633 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102634 +do_update_counters_2259 do_update_counters 4 2259 NULL
102635 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102636 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102637 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
102638 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
102639 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102640 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
102641 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
102642 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
102643 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102644 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102645 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102646 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
102647 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
102648 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
102649 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102650 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102651 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
102652 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102653 +raid1_size_2419 raid1_size 0-2 2419 NULL
102654 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
102655 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102656 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102657 +wiphy_new_2482 wiphy_new 2 2482 NULL
102658 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102659 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
102660 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102661 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102662 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102663 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102664 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102665 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102666 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
102667 +slot_bytes_2609 slot_bytes 0 2609 NULL
102668 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102669 +switch_status_2629 switch_status 5 2629 NULL
102670 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
102671 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102672 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
102673 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
102674 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
102675 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
102676 +oti6858_write_2692 oti6858_write 4 2692 NULL
102677 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102678 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
102679 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
102680 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
102681 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
102682 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
102683 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
102684 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102685 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102686 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
102687 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102688 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
102689 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
102690 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102691 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
102692 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
102693 +sock_create_2838 sock_create 0 2838 NULL
102694 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102695 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102696 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102697 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
102698 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102699 +mq_map_2871 mq_map 2 2871 NULL
102700 +__swab64p_2875 __swab64p 0 2875 NULL
102701 +nla_padlen_2883 nla_padlen 1 2883 NULL
102702 +cmm_write_2896 cmm_write 3 2896 NULL
102703 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102704 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
102705 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102706 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102707 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102708 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
102709 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102710 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
102711 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102712 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
102713 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102714 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
102715 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
102716 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102717 +depth_write_3021 depth_write 3 3021 NULL
102718 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102719 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
102720 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102721 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
102722 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
102723 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102724 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102725 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102726 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
102727 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102728 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
102729 +free_coherent_3082 free_coherent 4-2 3082 NULL
102730 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
102731 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102732 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102733 +rb_alloc_3102 rb_alloc 1 3102 NULL
102734 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
102735 +print_time_3132 print_time 0 3132 NULL
102736 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102737 +find_free_extent_3153 find_free_extent 5 3153 NULL
102738 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102739 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102740 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
102741 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102742 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102743 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102744 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
102745 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102746 +alloc_context_3194 alloc_context 1 3194 NULL
102747 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
102748 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
102749 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102750 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
102751 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
102752 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102753 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
102754 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102755 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102756 +key_key_read_3241 key_key_read 3 3241 NULL
102757 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
102758 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
102759 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102760 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
102761 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102762 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102763 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102764 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
102765 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102766 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102767 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102768 +scnprintf_3360 scnprintf 0-2 3360 NULL
102769 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
102770 +sr_read_3366 sr_read 3 3366 NULL
102771 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
102772 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102773 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102774 +send_stream_3397 send_stream 4 3397 NULL
102775 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102776 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102777 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102778 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102779 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102780 +send_unlink_3438 send_unlink 0 3438 NULL
102781 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102782 +map_single_3449 map_single 0 3449 NULL
102783 +softsynth_write_3455 softsynth_write 3 3455 NULL
102784 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102785 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
102786 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102787 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102788 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
102789 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
102790 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
102791 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
102792 +SyS_readv_3539 SyS_readv 3 3539 NULL
102793 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102794 +iommu_map_3554 iommu_map 3-2 3554 NULL
102795 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
102796 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
102797 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102798 +evtchn_read_3569 evtchn_read 3 3569 NULL
102799 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
102800 +vc_resize_3585 vc_resize 3-2 3585 NULL
102801 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
102802 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102803 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102804 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102805 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102806 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
102807 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102808 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102809 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
102810 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102811 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
102812 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102813 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102814 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102815 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
102816 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102817 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
102818 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102819 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
102820 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
102821 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
102822 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102823 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102824 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102825 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102826 +get_fd_set_3866 get_fd_set 1 3866 NULL
102827 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
102828 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102829 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102830 +nvram_write_3894 nvram_write 3 3894 NULL
102831 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102832 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102833 +vcs_write_3910 vcs_write 3 3910 NULL
102834 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
102835 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
102836 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102837 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
102838 +do_add_counters_3992 do_add_counters 3 3992 NULL
102839 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
102840 +userspace_status_4004 userspace_status 4 4004 NULL
102841 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102842 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102843 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102844 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
102845 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
102846 +blk_end_request_4024 blk_end_request 3 4024 NULL
102847 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102848 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
102849 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
102850 +read_file_queues_4078 read_file_queues 3 4078 NULL
102851 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102852 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
102853 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102854 +tm6000_read_4151 tm6000_read 3 4151 NULL
102855 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102856 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102857 +get_alua_req_4166 get_alua_req 3 4166 NULL
102858 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102859 +read_file_bool_4180 read_file_bool 3 4180 NULL
102860 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
102861 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102862 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102863 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102864 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
102865 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102866 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
102867 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102868 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102869 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102870 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102871 +__pool_find_4308 __pool_find 3 4308 NULL
102872 +count_strings_4315 count_strings 0 4315 NULL
102873 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102874 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102875 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
102876 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
102877 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
102878 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
102879 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102880 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
102881 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102882 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102883 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
102884 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102885 +memparse_4444 memparse 0 4444 NULL
102886 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
102887 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102888 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
102889 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
102890 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102891 +set_link_security_4502 set_link_security 4 4502 NULL
102892 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102893 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
102894 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
102895 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102896 +tty_register_device_4544 tty_register_device 2 4544 NULL
102897 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102898 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102899 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102900 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
102901 +bch_alloc_4593 bch_alloc 1 4593 NULL
102902 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
102903 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102904 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
102905 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102906 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
102907 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102908 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102909 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102910 +kone_receive_4690 kone_receive 4 4690 NULL
102911 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
102912 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102913 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102914 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102915 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102916 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
102917 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
102918 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
102919 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102920 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
102921 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
102922 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
102923 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
102924 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
102925 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102926 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
102927 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
102928 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102929 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102930 +get_new_location_4866 get_new_location 0 4866 NULL
102931 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
102932 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102933 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102934 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
102935 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102936 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
102937 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102938 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102939 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102940 +do_sync_read_4977 do_sync_read 0 4977 NULL
102941 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102942 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
102943 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
102944 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
102945 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
102946 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
102947 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102948 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102949 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102950 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
102951 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102952 +sound_write_5102 sound_write 3 5102 NULL
102953 +clear_dirty_5105 clear_dirty 3 5105 NULL
102954 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
102955 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
102956 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102957 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
102958 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102959 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102960 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102961 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
102962 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
102963 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102964 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102965 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
102966 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102967 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
102968 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
102969 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102970 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
102971 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102972 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
102973 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102974 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102975 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102976 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
102977 +cq_free_res_5355 cq_free_res 5 5355 NULL
102978 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102979 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
102980 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
102981 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102982 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
102983 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
102984 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102985 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
102986 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
102987 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102988 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102989 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102990 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102991 +tty_write_5494 tty_write 3 5494 NULL
102992 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102993 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102994 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102995 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102996 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
102997 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102998 +le_readq_5557 le_readq 0 5557 NULL
102999 +inw_5558 inw 0 5558 NULL
103000 +bioset_create_5580 bioset_create 1 5580 NULL
103001 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
103002 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
103003 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
103004 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
103005 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
103006 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
103007 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
103008 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
103009 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
103010 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
103011 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
103012 +get_arg_5694 get_arg 3 5694 NULL
103013 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
103014 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
103015 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
103016 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
103017 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
103018 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
103019 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
103020 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
103021 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
103022 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
103023 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
103024 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
103025 +setup_req_5848 setup_req 3 5848 NULL
103026 +ria_page_count_5849 ria_page_count 0 5849 NULL
103027 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
103028 +config_buf_5862 config_buf 0 5862 NULL
103029 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
103030 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
103031 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
103032 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
103033 +port_show_regs_5904 port_show_regs 3 5904 NULL
103034 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
103035 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
103036 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
103037 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
103038 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
103039 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
103040 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
103041 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
103042 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
103043 +native_pte_val_5978 native_pte_val 0 5978 NULL
103044 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
103045 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
103046 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
103047 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
103048 +alloc_msg_6072 alloc_msg 1 6072 NULL
103049 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
103050 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
103051 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
103052 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
103053 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
103054 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
103055 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
103056 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
103057 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
103058 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
103059 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
103060 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
103061 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
103062 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
103063 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
103064 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
103065 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
103066 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
103067 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
103068 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
103069 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
103070 +changed_ref_6242 changed_ref 0 6242 NULL
103071 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
103072 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
103073 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
103074 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
103075 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
103076 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
103077 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
103078 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
103079 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
103080 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
103081 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
103082 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
103083 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
103084 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
103085 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
103086 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
103087 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
103088 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
103089 +msb_write_block_6379 msb_write_block 3 6379 NULL
103090 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
103091 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
103092 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
103093 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
103094 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
103095 +add_to_list_6433 add_to_list 0 6433 NULL
103096 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
103097 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
103098 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
103099 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
103100 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
103101 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
103102 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
103103 +mei_read_6507 mei_read 3 6507 NULL
103104 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
103105 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
103106 +wdm_read_6549 wdm_read 3 6549 NULL
103107 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
103108 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
103109 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
103110 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
103111 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
103112 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
103113 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
103114 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
103115 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
103116 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
103117 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
103118 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
103119 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
103120 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
103121 +mpeg_read_6708 mpeg_read 3 6708 NULL
103122 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
103123 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
103124 +video_proc_write_6724 video_proc_write 3 6724 NULL
103125 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
103126 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
103127 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
103128 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
103129 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
103130 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
103131 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
103132 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
103133 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
103134 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
103135 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
103136 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
103137 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
103138 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
103139 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
103140 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
103141 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
103142 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
103143 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
103144 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
103145 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
103146 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
103147 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
103148 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
103149 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
103150 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
103151 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
103152 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
103153 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
103154 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
103155 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
103156 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
103157 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
103158 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
103159 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
103160 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
103161 +request_key_async_6990 request_key_async 4 6990 NULL
103162 +tpl_write_6998 tpl_write 3 6998 NULL
103163 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
103164 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
103165 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
103166 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
103167 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
103168 +wimax_msg_7030 wimax_msg 4 7030 NULL
103169 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
103170 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
103171 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
103172 +event_enable_read_7074 event_enable_read 3 7074 NULL
103173 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
103174 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
103175 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
103176 +check_header_7108 check_header 0 7108 NULL
103177 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
103178 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
103179 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
103180 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
103181 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
103182 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
103183 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
103184 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
103185 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
103186 +get_param_h_7247 get_param_h 0 7247 NULL
103187 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
103188 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
103189 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
103190 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
103191 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
103192 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
103193 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
103194 +get_string_7302 get_string 0 7302 NULL
103195 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
103196 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
103197 +mgmt_control_7349 mgmt_control 3 7349 NULL
103198 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
103199 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
103200 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
103201 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
103202 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
103203 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
103204 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
103205 +hweight_long_7388 hweight_long 1-0 7388 NULL
103206 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
103207 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
103208 +readb_7401 readb 0 7401 NULL
103209 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
103210 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
103211 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
103212 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
103213 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
103214 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
103215 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
103216 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
103217 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
103218 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
103219 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
103220 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
103221 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
103222 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
103223 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
103224 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
103225 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
103226 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
103227 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
103228 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
103229 +create_dir_7614 create_dir 0 7614 NULL nohasharray
103230 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
103231 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
103232 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
103233 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
103234 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103235 +dev_write_7708 dev_write 3 7708 NULL
103236 +unmap_region_7709 unmap_region 1 7709 NULL
103237 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
103238 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
103239 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103240 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103241 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
103242 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103243 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103244 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
103245 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
103246 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
103247 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103248 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
103249 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
103250 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
103251 +config_desc_7878 config_desc 0 7878 NULL
103252 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
103253 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
103254 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
103255 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
103256 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
103257 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
103258 +compare_refs_7938 compare_refs 0 7938 NULL
103259 +fsnotify_7943 fsnotify 0 7943 NULL
103260 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
103261 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
103262 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
103263 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
103264 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
103265 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
103266 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
103267 +vcs_read_8017 vcs_read 3 8017 NULL
103268 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
103269 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
103270 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
103271 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
103272 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
103273 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
103274 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
103275 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
103276 +venus_lookup_8121 venus_lookup 4 8121 NULL
103277 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
103278 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
103279 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
103280 +ore_truncate_8181 ore_truncate 3 8181 NULL
103281 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
103282 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
103283 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
103284 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
103285 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
103286 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
103287 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
103288 +play_iframe_8219 play_iframe 3 8219 NULL
103289 +create_log_8225 create_log 2 8225 NULL nohasharray
103290 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
103291 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
103292 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
103293 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
103294 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
103295 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
103296 +init_cdev_8274 init_cdev 1 8274 NULL
103297 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
103298 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
103299 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
103300 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
103301 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
103302 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
103303 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
103304 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
103305 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
103306 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
103307 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
103308 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
103309 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
103310 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
103311 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
103312 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
103313 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
103314 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
103315 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
103316 +dir_changed_8471 dir_changed 0 8471 NULL
103317 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
103318 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
103319 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
103320 +dev_config_8506 dev_config 3 8506 NULL
103321 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
103322 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
103323 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
103324 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
103325 +user_on_off_8552 user_on_off 2 8552 NULL
103326 +profile_remove_8556 profile_remove 3 8556 NULL
103327 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
103328 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
103329 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
103330 +tower_write_8580 tower_write 3 8580 NULL
103331 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
103332 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
103333 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
103334 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
103335 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
103336 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
103337 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
103338 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
103339 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
103340 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
103341 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
103342 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
103343 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
103344 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
103345 +arcfb_write_8702 arcfb_write 3 8702 NULL
103346 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
103347 +init_header_8703 init_header 0 8703 &i_size_read_8703
103348 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
103349 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
103350 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
103351 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
103352 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
103353 +f_dupfd_8730 f_dupfd 1 8730 NULL
103354 +__create_irqs_8733 __create_irqs 2-1-0 8733 NULL
103355 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
103356 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
103357 +compound_order_8750 compound_order 0 8750 NULL
103358 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
103359 +yurex_write_8761 yurex_write 3 8761 NULL
103360 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
103361 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
103362 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
103363 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
103364 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
103365 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
103366 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
103367 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
103368 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
103369 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
103370 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
103371 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
103372 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
103373 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
103374 +clear_bitset_8840 clear_bitset 2 8840 NULL
103375 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
103376 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
103377 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
103378 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
103379 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
103380 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
103381 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
103382 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
103383 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
103384 +write_file_ani_8918 write_file_ani 3 8918 NULL
103385 +layout_commit_8926 layout_commit 3 8926 NULL
103386 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
103387 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
103388 +lookup_zone_8956 lookup_zone 2 8956 NULL
103389 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
103390 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
103391 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
103392 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
103393 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
103394 +seq_open_net_8968 seq_open_net 4 8968 NULL nohasharray
103395 +vol_cdev_read_8968 vol_cdev_read 3 8968 &seq_open_net_8968
103396 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
103397 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
103398 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
103399 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
103400 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
103401 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
103402 +nla_put_9042 nla_put 3 9042 NULL
103403 +offset_il_node_9059 offset_il_node 0 9059 NULL
103404 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
103405 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
103406 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
103407 +create_queues_9088 create_queues 3-2 9088 NULL
103408 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
103409 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
103410 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
103411 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
103412 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
103413 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
103414 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
103415 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
103416 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
103417 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
103418 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
103419 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
103420 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
103421 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
103422 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
103423 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
103424 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
103425 +get_pfn_9207 get_pfn 1 9207 NULL
103426 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
103427 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
103428 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
103429 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
103430 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
103431 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
103432 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
103433 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
103434 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
103435 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
103436 +flakey_status_9274 flakey_status 5 9274 NULL
103437 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
103438 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
103439 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
103440 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
103441 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
103442 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
103443 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
103444 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
103445 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
103446 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
103447 +read_9397 read 3 9397 NULL
103448 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
103449 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
103450 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
103451 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
103452 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
103453 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
103454 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
103455 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
103456 +crypt_status_9492 crypt_status 5 9492 NULL
103457 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
103458 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
103459 +lp_write_9511 lp_write 3 9511 NULL
103460 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
103461 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
103462 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
103463 +read_file_dma_9530 read_file_dma 3 9530 NULL
103464 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
103465 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
103466 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 NULL
103467 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
103468 +readl_9557 readl 0 9557 NULL
103469 +fw_node_create_9559 fw_node_create 2 9559 NULL
103470 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
103471 +kobj_map_9566 kobj_map 3-2 9566 NULL
103472 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
103473 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
103474 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
103475 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
103476 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
103477 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
103478 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
103479 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
103480 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
103481 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
103482 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
103483 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
103484 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
103485 +dns_query_9676 dns_query 3 9676 NULL
103486 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
103487 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
103488 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
103489 +fnb_9703 fnb 2-3-0 9703 NULL
103490 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
103491 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
103492 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
103493 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
103494 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
103495 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
103496 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
103497 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
103498 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
103499 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
103500 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
103501 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
103502 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
103503 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
103504 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
103505 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
103506 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
103507 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
103508 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
103509 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
103510 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
103511 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
103512 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
103513 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
103514 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
103515 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
103516 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
103517 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
103518 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
103519 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
103520 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
103521 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
103522 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
103523 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
103524 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
103525 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
103526 +read_file_misc_9948 read_file_misc 3 9948 NULL
103527 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
103528 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
103529 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
103530 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
103531 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
103532 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
103533 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
103534 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
103535 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
103536 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
103537 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
103538 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
103539 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
103540 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
103541 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
103542 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
103543 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
103544 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
103545 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
103546 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
103547 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
103548 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
103549 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
103550 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
103551 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
103552 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
103553 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
103554 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
103555 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
103556 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
103557 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
103558 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
103559 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
103560 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
103561 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
103562 +read_emulate_10310 read_emulate 2-4 10310 NULL
103563 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
103564 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
103565 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
103566 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
103567 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
103568 +get_dump_page_10338 get_dump_page 1 10338 NULL
103569 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
103570 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
103571 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
103572 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
103573 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
103574 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
103575 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
103576 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
103577 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
103578 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
103579 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
103580 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
103581 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
103582 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
103583 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
103584 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
103585 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
103586 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
103587 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
103588 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
103589 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
103590 +SYSC_read_10545 SYSC_read 3 10545 NULL
103591 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
103592 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
103593 +otp_read_10594 otp_read 5-4-2 10594 NULL
103594 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
103595 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
103596 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
103597 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
103598 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
103599 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
103600 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
103601 +parport_write_10669 parport_write 0 10669 NULL
103602 +edge_write_10692 edge_write 4 10692 NULL
103603 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
103604 +inl_10708 inl 0 10708 NULL nohasharray
103605 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
103606 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
103607 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
103608 +spi_sync_10731 spi_sync 0 10731 NULL
103609 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
103610 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
103611 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
103612 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
103613 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
103614 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
103615 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
103616 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
103617 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
103618 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
103619 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
103620 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
103621 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
103622 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
103623 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
103624 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
103625 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
103626 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
103627 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
103628 +get_scq_10897 get_scq 2 10897 NULL
103629 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
103630 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
103631 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
103632 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
103633 +kobject_add_10919 kobject_add 0 10919 NULL
103634 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
103635 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
103636 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
103637 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
103638 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
103639 +lz4_compress_10986 lz4_compress 2 10986 NULL
103640 +do_switch_10994 do_switch 0 10994 NULL
103641 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
103642 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
103643 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
103644 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
103645 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
103646 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
103647 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
103648 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
103649 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
103650 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
103651 +count_argc_11083 count_argc 0 11083 NULL
103652 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
103653 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
103654 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
103655 +page_offset_11120 page_offset 0 11120 NULL
103656 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
103657 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
103658 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
103659 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
103660 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
103661 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
103662 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
103663 +mmap_region_11247 mmap_region 0-2 11247 NULL
103664 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
103665 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
103666 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
103667 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
103668 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
103669 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
103670 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
103671 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
103672 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
103673 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
103674 +construct_key_11329 construct_key 3 11329 NULL nohasharray
103675 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
103676 +next_segment_11330 next_segment 0-2-1 11330 NULL
103677 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
103678 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
103679 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
103680 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
103681 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103682 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103683 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103684 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103685 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
103686 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
103687 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
103688 +str_to_user_11411 str_to_user 2 11411 NULL
103689 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103690 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103691 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
103692 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103693 +trace_options_read_11419 trace_options_read 3 11419 NULL
103694 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
103695 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
103696 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
103697 +prepare_image_11424 prepare_image 0 11424 NULL
103698 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
103699 +bttv_read_11432 bttv_read 3 11432 NULL
103700 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103701 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
103702 +swp_offset_11475 swp_offset 0 11475 NULL
103703 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
103704 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
103705 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
103706 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103707 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103708 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103709 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
103710 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103711 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103712 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
103713 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
103714 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
103715 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
103716 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
103717 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103718 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103719 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103720 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
103721 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103722 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
103723 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103724 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103725 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103726 +slab_ksize_11664 slab_ksize 0 11664 NULL
103727 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
103728 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103729 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
103730 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103731 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103732 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103733 +split_11691 split 2 11691 NULL
103734 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103735 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103736 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103737 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103738 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
103739 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
103740 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103741 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103742 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103743 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
103744 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
103745 +umc_device_register_11824 umc_device_register 0 11824 NULL
103746 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103747 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103748 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103749 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103750 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103751 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103752 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
103753 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
103754 +ti_write_11916 ti_write 4 11916 NULL
103755 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103756 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103757 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103758 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
103759 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103760 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
103761 +split_node_11976 split_node 0 11976 &usc_InReg_11976
103762 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
103763 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103764 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
103765 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
103766 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103767 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
103768 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103769 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103770 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103771 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103772 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103773 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
103774 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
103775 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
103776 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103777 +set_powered_12129 set_powered 4 12129 NULL
103778 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103779 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103780 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103781 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103782 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
103783 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103784 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103785 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
103786 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103787 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103788 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
103789 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103790 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103791 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103792 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
103793 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103794 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103795 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103796 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
103797 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
103798 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103799 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103800 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103801 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103802 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 NULL nohasharray
103803 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 &il_dbgfs_nvm_read_12288
103804 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103805 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
103806 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103807 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
103808 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103809 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103810 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103811 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103812 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
103813 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
103814 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
103815 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
103816 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103817 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103818 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
103819 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103820 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103821 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103822 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103823 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
103824 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103825 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103826 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
103827 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103828 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103829 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103830 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
103831 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103832 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
103833 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
103834 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103835 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103836 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103837 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
103838 +wb_create_12651 wb_create 1 12651 NULL
103839 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
103840 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103841 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103842 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103843 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
103844 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
103845 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
103846 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103847 +ivtv_write_12721 ivtv_write 3 12721 NULL
103848 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103849 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103850 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
103851 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103852 +listxattr_12769 listxattr 3 12769 NULL
103853 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103854 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
103855 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103856 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103857 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
103858 +readq_12825 readq 0 12825 NULL
103859 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
103860 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103861 +spidev_sync_12842 spidev_sync 0 12842 NULL
103862 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103863 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103864 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103865 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103866 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103867 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
103868 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103869 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
103870 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103871 +bm_status_write_12964 bm_status_write 3 12964 NULL
103872 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103873 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103874 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103875 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103876 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
103877 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103878 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
103879 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103880 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
103881 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
103882 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103883 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
103884 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103885 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103886 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
103887 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
103888 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
103889 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103890 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103891 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103892 +blk_update_request_13146 blk_update_request 3 13146 NULL
103893 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103894 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103895 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103896 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103897 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103898 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103899 +comedi_read_13199 comedi_read 3 13199 NULL
103900 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103901 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103902 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
103903 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103904 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103905 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103906 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
103907 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103908 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103909 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
103910 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103911 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103912 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103913 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103914 +sd_major_13294 sd_major 0-1 13294 NULL
103915 +kempld_read16_13297 kempld_read16 0 13297 NULL
103916 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103917 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103918 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103919 +get_bits_13353 get_bits 0-2 13353 NULL
103920 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
103921 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103922 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103923 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
103924 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
103925 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
103926 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
103927 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
103928 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103929 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
103930 +keyring_read_13438 keyring_read 3 13438 NULL
103931 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
103932 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103933 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
103934 +data_read_13494 data_read 3 13494 NULL
103935 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
103936 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
103937 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
103938 +core_status_13515 core_status 4 13515 NULL
103939 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103940 +bm_init_13529 bm_init 2 13529 NULL
103941 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
103942 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
103943 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
103944 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
103945 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
103946 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103947 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103948 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103949 +cache_write_13589 cache_write 3 13589 NULL
103950 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
103951 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103952 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103953 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103954 +packet_snd_13634 packet_snd 3 13634 NULL
103955 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103956 +cache_downcall_13666 cache_downcall 3 13666 NULL
103957 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
103958 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
103959 +usb_get_string_13693 usb_get_string 0 13693 NULL
103960 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
103961 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103962 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
103963 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103964 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103965 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103966 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103967 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103968 +random_read_13815 random_read 3 13815 NULL
103969 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
103970 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103971 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103972 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
103973 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
103974 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
103975 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
103976 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
103977 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
103978 +window_alignment_13895 window_alignment 0 13895 NULL
103979 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103980 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
103981 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
103982 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103983 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103984 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103985 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103986 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103987 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
103988 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103989 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
103990 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
103991 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103992 +qcam_read_13977 qcam_read 3 13977 NULL
103993 +dsp_read_13980 dsp_read 2 13980 NULL
103994 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103995 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103996 +create_files_14003 create_files 0 14003 NULL
103997 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
103998 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103999 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
104000 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
104001 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
104002 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
104003 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
104004 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
104005 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
104006 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
104007 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
104008 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
104009 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
104010 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
104011 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
104012 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
104013 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
104014 +em_canid_change_14150 em_canid_change 3 14150 NULL
104015 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
104016 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
104017 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
104018 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
104019 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
104020 +do_splice_14196 do_splice 5 14196 NULL
104021 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
104022 +alloc_async_14208 alloc_async 1 14208 NULL
104023 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
104024 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
104025 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
104026 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
104027 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
104028 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
104029 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
104030 +rr_status_14293 rr_status 5 14293 NULL
104031 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
104032 +__readl_14308 __readl 0 14308 NULL
104033 +send_chown_14309 send_chown 0 14309 NULL
104034 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
104035 +oo_objects_14319 oo_objects 0 14319 NULL
104036 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
104037 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
104038 +down_write_failed_14331 down_write_failed 2 14331 NULL
104039 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
104040 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
104041 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
104042 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
104043 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
104044 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
104045 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
104046 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
104047 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
104048 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
104049 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
104050 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
104051 +block_size_14443 block_size 0 14443 NULL
104052 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
104053 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
104054 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
104055 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
104056 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
104057 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
104058 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
104059 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
104060 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
104061 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 &ep0_write_14536
104062 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
104063 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
104064 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
104065 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
104066 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
104067 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
104068 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
104069 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
104070 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
104071 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
104072 +dbJoin_14644 dbJoin 0 14644 NULL
104073 +profile_replace_14652 profile_replace 3 14652 NULL
104074 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
104075 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
104076 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
104077 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
104078 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
104079 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
104080 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
104081 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
104082 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
104083 +cgroup_path_14713 cgroup_path 3 14713 NULL
104084 +get_bio_block_14714 get_bio_block 0 14714 NULL
104085 +vfd_write_14717 vfd_write 3 14717 NULL
104086 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
104087 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
104088 +raid1_resize_14740 raid1_resize 2 14740 NULL
104089 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
104090 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
104091 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
104092 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
104093 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
104094 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
104095 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
104096 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
104097 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
104098 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
104099 +changed_cb_14819 changed_cb 0 14819 NULL
104100 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
104101 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
104102 +lcd_write_14857 lcd_write 3 14857 NULL
104103 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
104104 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
104105 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
104106 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
104107 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
104108 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
104109 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
104110 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
104111 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
104112 +queue_cnt_14951 queue_cnt 0 14951 NULL
104113 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
104114 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
104115 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
104116 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
104117 +setkey_14987 setkey 3 14987 NULL nohasharray
104118 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
104119 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
104120 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
104121 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
104122 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
104123 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
104124 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
104125 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
104126 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
104127 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
104128 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
104129 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
104130 +start_port_15124 start_port 0 15124 NULL
104131 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
104132 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
104133 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
104134 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
104135 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
104136 +reserve_resources_15194 reserve_resources 3 15194 NULL
104137 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
104138 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
104139 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
104140 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
104141 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
104142 +simple_strtol_15273 simple_strtol 0 15273 NULL
104143 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
104144 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
104145 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
104146 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
104147 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
104148 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
104149 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
104150 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
104151 +ioread16_15342 ioread16 0 15342 NULL
104152 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
104153 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
104154 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
104155 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
104156 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
104157 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
104158 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
104159 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
104160 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
104161 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
104162 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
104163 +get_modalias_15406 get_modalias 2 15406 NULL
104164 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
104165 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
104166 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
104167 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
104168 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
104169 +memweight_15450 memweight 2 15450 NULL
104170 +vmalloc_15464 vmalloc 1 15464 NULL
104171 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
104172 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
104173 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
104174 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
104175 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
104176 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
104177 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
104178 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
104179 +persistent_status_15574 persistent_status 4 15574 NULL
104180 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
104181 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
104182 +vme_user_write_15587 vme_user_write 3 15587 NULL
104183 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
104184 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
104185 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
104186 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
104187 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
104188 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
104189 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
104190 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
104191 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
104192 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
104193 +xsd_read_15653 xsd_read 3 15653 NULL
104194 +unix_bind_15668 unix_bind 3 15668 NULL
104195 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
104196 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
104197 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
104198 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL
104199 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
104200 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
104201 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
104202 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
104203 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
104204 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
104205 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
104206 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
104207 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
104208 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
104209 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
104210 +table_size_15851 table_size 0-1-2 15851 NULL
104211 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
104212 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
104213 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
104214 +profile_pc_15887 profile_pc 0 15887 NULL
104215 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
104216 +native_read_msr_15905 native_read_msr 0 15905 NULL
104217 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
104218 +power_read_15939 power_read 3 15939 NULL
104219 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
104220 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
104221 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
104222 +frame_alloc_15981 frame_alloc 4 15981 NULL
104223 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
104224 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
104225 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
104226 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
104227 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
104228 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
104229 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
104230 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
104231 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
104232 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
104233 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
104234 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
104235 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
104236 +fsm_init_16134 fsm_init 2 16134 NULL
104237 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
104238 +update_block_group_16155 update_block_group 0 16155 NULL
104239 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
104240 +mapping_level_16188 mapping_level 2 16188 NULL
104241 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
104242 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
104243 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
104244 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
104245 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
104246 +create_table_16213 create_table 2 16213 NULL
104247 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
104248 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
104249 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
104250 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
104251 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
104252 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
104253 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
104254 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
104255 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
104256 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
104257 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
104258 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
104259 +account_16283 account 0-4-2 16283 NULL nohasharray
104260 +mirror_status_16283 mirror_status 5 16283 &account_16283
104261 +retry_instruction_16285 retry_instruction 2 16285 NULL
104262 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
104263 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
104264 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
104265 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
104266 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
104267 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
104268 +wb_map_16301 wb_map 2 16301 NULL
104269 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
104270 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
104271 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
104272 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
104273 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
104274 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
104275 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
104276 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
104277 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
104278 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
104279 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
104280 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0 16452 NULL
104281 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
104282 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
104283 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
104284 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
104285 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
104286 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
104287 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
104288 +start_this_handle_16519 start_this_handle 0 16519 NULL
104289 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
104290 +raid10_resize_16537 raid10_resize 2 16537 NULL
104291 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
104292 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
104293 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
104294 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
104295 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
104296 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
104297 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
104298 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
104299 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
104300 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
104301 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
104302 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
104303 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
104304 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
104305 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
104306 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
104307 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
104308 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
104309 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
104310 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
104311 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
104312 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
104313 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
104314 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
104315 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
104316 +st_write_16874 st_write 3 16874 NULL
104317 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
104318 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
104319 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
104320 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
104321 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
104322 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
104323 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
104324 +wrm_16966 wrm 0 16966 NULL
104325 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
104326 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
104327 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
104328 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
104329 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
104330 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
104331 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
104332 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
104333 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
104334 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
104335 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
104336 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
104337 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
104338 +entry_length_17093 entry_length 0 17093 NULL
104339 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
104340 +write_mem_17114 write_mem 3 17114 NULL
104341 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
104342 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
104343 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
104344 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
104345 +sep_read_17161 sep_read 3 17161 NULL
104346 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
104347 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
104348 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
104349 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
104350 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
104351 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
104352 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
104353 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
104354 +sync_request_17208 sync_request 2 17208 NULL
104355 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
104356 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
104357 +to_oblock_17254 to_oblock 0-1 17254 NULL
104358 +unpack_value_17259 unpack_value 1 17259 NULL
104359 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
104360 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
104361 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
104362 +alloc_ep_17269 alloc_ep 1 17269 NULL
104363 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
104364 +pg_read_17276 pg_read 3 17276 NULL
104365 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
104366 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
104367 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
104368 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
104369 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
104370 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
104371 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
104372 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
104373 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
104374 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
104375 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
104376 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
104377 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
104378 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
104379 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
104380 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
104381 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
104382 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
104383 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
104384 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
104385 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
104386 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
104387 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
104388 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
104389 +qp_free_res_17541 qp_free_res 5 17541 NULL
104390 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
104391 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
104392 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
104393 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
104394 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
104395 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
104396 +__inode_info_17603 __inode_info 0 17603 NULL
104397 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
104398 +osst_execute_17607 osst_execute 7-6 17607 NULL
104399 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
104400 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
104401 +dma_map_page_17628 dma_map_page 0 17628 NULL
104402 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
104403 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
104404 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
104405 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
104406 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
104407 +kernel_write_17665 kernel_write 3 17665 NULL
104408 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
104409 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
104410 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
104411 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
104412 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
104413 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
104414 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
104415 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
104416 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
104417 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
104418 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
104419 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
104420 +perf_clock_17787 perf_clock 0 17787 NULL
104421 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
104422 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
104423 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
104424 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
104425 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
104426 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
104427 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
104428 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
104429 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
104430 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
104431 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
104432 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
104433 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
104434 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
104435 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
104436 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
104437 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
104438 +recover_head_17904 recover_head 3 17904 NULL
104439 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
104440 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
104441 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
104442 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
104443 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
104444 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
104445 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
104446 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
104447 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
104448 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
104449 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
104450 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
104451 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
104452 +fill_read_18019 fill_read 0 18019 NULL
104453 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
104454 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
104455 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
104456 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
104457 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
104458 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
104459 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
104460 +fpregs_get_18066 fpregs_get 4 18066 NULL
104461 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
104462 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
104463 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
104464 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
104465 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
104466 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
104467 +svc_getnl_18120 svc_getnl 0 18120 NULL
104468 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
104469 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
104470 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
104471 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
104472 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
104473 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
104474 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
104475 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
104476 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
104477 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
104478 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
104479 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
104480 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
104481 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
104482 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
104483 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
104484 +alloc_ring_18278 alloc_ring 4-2 18278 NULL
104485 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
104486 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
104487 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
104488 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
104489 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
104490 +um_idi_write_18293 um_idi_write 3 18293 NULL
104491 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
104492 +vga_r_18310 vga_r 0 18310 NULL
104493 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
104494 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
104495 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
104496 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
104497 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
104498 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
104499 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
104500 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
104501 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
104502 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
104503 +ep_io_18367 ep_io 0 18367 NULL
104504 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
104505 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
104506 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
104507 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
104508 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
104509 +__video_register_device_18399 __video_register_device 3 18399 NULL
104510 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
104511 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
104512 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
104513 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
104514 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
104515 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
104516 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
104517 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
104518 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
104519 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
104520 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
104521 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
104522 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
104523 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
104524 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
104525 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
104526 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
104527 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
104528 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
104529 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
104530 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
104531 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
104532 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
104533 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
104534 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
104535 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
104536 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
104537 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
104538 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
104539 +debug_output_18575 debug_output 3 18575 NULL
104540 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
104541 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
104542 +numa_node_id_18596 numa_node_id 0 18596 NULL
104543 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
104544 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
104545 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
104546 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
104547 +from_buffer_18625 from_buffer 3 18625 NULL
104548 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
104549 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
104550 +unmap_page_18665 unmap_page 2-3 18665 NULL
104551 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
104552 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
104553 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
104554 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
104555 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
104556 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
104557 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
104558 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
104559 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
104560 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
104561 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
104562 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
104563 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
104564 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
104565 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
104566 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
104567 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
104568 +prealloc_18800 prealloc 0 18800 NULL
104569 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
104570 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
104571 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
104572 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
104573 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
104574 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
104575 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
104576 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
104577 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
104578 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
104579 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
104580 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
104581 +overwrite_item_18896 overwrite_item 0 18896 NULL
104582 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
104583 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
104584 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
104585 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
104586 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
104587 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
104588 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
104589 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
104590 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
104591 +get_inode_path_18988 get_inode_path 0 18988 NULL
104592 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
104593 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
104594 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
104595 +huge_page_size_19008 huge_page_size 0 19008 NULL
104596 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
104597 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
104598 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
104599 +revalidate_19043 revalidate 2 19043 NULL
104600 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
104601 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
104602 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
104603 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
104604 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
104605 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
104606 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
104607 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
104608 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
104609 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
104610 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
104611 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
104612 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
104613 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
104614 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
104615 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
104616 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
104617 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
104618 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
104619 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
104620 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
104621 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
104622 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
104623 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
104624 +ucma_query_19260 ucma_query 4 19260 NULL
104625 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
104626 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
104627 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
104628 +qc_capture_19298 qc_capture 3 19298 NULL
104629 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
104630 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
104631 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
104632 +debug_read_19322 debug_read 3 19322 NULL
104633 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
104634 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
104635 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
104636 +closure_sub_19359 closure_sub 2 19359 NULL
104637 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
104638 +read_zero_19366 read_zero 3 19366 NULL
104639 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
104640 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
104641 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
104642 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
104643 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
104644 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
104645 +__phys_addr_19434 __phys_addr 0 19434 NULL
104646 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
104647 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
104648 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
104649 +sky2_read16_19475 sky2_read16 0 19475 NULL
104650 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
104651 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
104652 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
104653 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
104654 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
104655 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
104656 +howmany_64_19548 howmany_64 2 19548 NULL
104657 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
104658 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
104659 +kernel_read_19559 kernel_read 4-0 19559 NULL
104660 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
104661 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
104662 +nfsd_read_19568 nfsd_read 5 19568 NULL
104663 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
104664 +bm_status_read_19583 bm_status_read 3 19583 NULL
104665 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
104666 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
104667 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
104668 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
104669 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
104670 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
104671 +bio_detain_19690 bio_detain 2 19690 NULL
104672 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
104673 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
104674 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
104675 +read_reg_19723 read_reg 0 19723 NULL
104676 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
104677 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
104678 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
104679 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
104680 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
104681 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
104682 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
104683 +readhscx_19769 readhscx 0 19769 NULL
104684 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
104685 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
104686 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
104687 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
104688 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
104689 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
104690 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
104691 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
104692 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
104693 +__nla_put_19857 __nla_put 3 19857 NULL
104694 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
104695 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
104696 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
104697 +mangle_name_19923 mangle_name 0 19923 NULL
104698 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
104699 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
104700 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
104701 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
104702 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
104703 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
104704 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
104705 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
104706 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
104707 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
104708 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
104709 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
104710 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
104711 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
104712 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
104713 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
104714 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
104715 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
104716 +target_message_20072 target_message 2 20072 NULL
104717 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
104718 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
104719 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
104720 +team_options_register_20091 team_options_register 3 20091 NULL
104721 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
104722 +read_int_20098 read_int 0 20098 NULL
104723 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
104724 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
104725 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
104726 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
104727 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
104728 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
104729 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
104730 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
104731 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
104732 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
104733 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
104734 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
104735 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
104736 +resource_size_20256 resource_size 0 20256 NULL
104737 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
104738 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
104739 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
104740 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
104741 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
104742 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
104743 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
104744 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
104745 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
104746 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
104747 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
104748 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
104749 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
104750 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
104751 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
104752 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
104753 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
104754 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
104755 +read_buf_20469 read_buf 2 20469 NULL
104756 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
104757 +fast_user_write_20494 fast_user_write 5 20494 NULL
104758 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
104759 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
104760 +link_free_space_20512 link_free_space 0 20512 NULL
104761 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
104762 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
104763 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
104764 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
104765 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
104766 +venus_create_20555 venus_create 4 20555 NULL
104767 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
104768 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
104769 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
104770 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
104771 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
104772 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
104773 +lirc_write_20604 lirc_write 3 20604 NULL
104774 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
104775 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
104776 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
104777 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
104778 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
104779 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
104780 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
104781 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL nohasharray
104782 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 &snd_hdsp_playback_copy_20676
104783 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
104784 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
104785 +cpumask_size_20683 cpumask_size 0 20683 NULL
104786 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
104787 +gru_vtop_20689 gru_vtop 2 20689 NULL
104788 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
104789 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
104790 +__maestro_read_20700 __maestro_read 0 20700 NULL
104791 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
104792 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
104793 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
104794 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
104795 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
104796 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
104797 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
104798 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
104799 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
104800 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
104801 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
104802 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
104803 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
104804 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
104805 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
104806 +strndup_user_20819 strndup_user 2 20819 NULL
104807 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
104808 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
104809 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
104810 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
104811 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
104812 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
104813 +get_name_20855 get_name 4 20855 NULL
104814 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
104815 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
104816 +srq_free_res_20868 srq_free_res 5 20868 NULL
104817 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
104818 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
104819 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
104820 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
104821 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
104822 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
104823 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
104824 +htable_bits_20933 htable_bits 0 20933 NULL
104825 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
104826 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
104827 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
104828 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
104829 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
104830 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
104831 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
104832 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
104833 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
104834 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
104835 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
104836 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
104837 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
104838 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
104839 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
104840 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
104841 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
104842 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
104843 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
104844 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
104845 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
104846 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
104847 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
104848 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
104849 +chunk_size_21146 chunk_size 0 21146 NULL
104850 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
104851 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
104852 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
104853 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
104854 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
104855 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
104856 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
104857 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
104858 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
104859 +input_ff_create_21240 input_ff_create 2 21240 NULL
104860 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
104861 +fru_length_21257 fru_length 0 21257 NULL
104862 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
104863 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
104864 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
104865 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
104866 +add_res_range_21310 add_res_range 4 21310 NULL
104867 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
104868 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
104869 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
104870 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
104871 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
104872 +split_leaf_21378 split_leaf 0 21378 NULL
104873 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
104874 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
104875 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
104876 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
104877 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
104878 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104879 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104880 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104881 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104882 +ReadISAR_21453 ReadISAR 0 21453 NULL
104883 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104884 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104885 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104886 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
104887 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104888 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104889 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104890 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104891 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104892 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104893 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
104894 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104895 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
104896 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
104897 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
104898 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
104899 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104900 +validate_nnode_21638 validate_nnode 0 21638 NULL
104901 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3 21639 NULL
104902 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
104903 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104904 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104905 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
104906 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104907 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
104908 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
104909 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
104910 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
104911 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
104912 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
104913 +vm_brk_21739 vm_brk 1-2 21739 NULL
104914 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104915 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
104916 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
104917 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
104918 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
104919 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104920 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104921 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
104922 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104923 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104924 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
104925 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104926 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104927 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
104928 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
104929 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
104930 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104931 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104932 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104933 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
104934 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
104935 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104936 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104937 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104938 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104939 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
104940 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104941 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104942 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
104943 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104944 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104945 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
104946 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104947 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
104948 +write_opcode_22082 write_opcode 2 22082 NULL
104949 +mem_rw_22085 mem_rw 3 22085 NULL
104950 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
104951 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104952 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
104953 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
104954 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
104955 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
104956 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104957 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
104958 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
104959 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
104960 +fls_22210 fls 0 22210 NULL
104961 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
104962 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
104963 +mem_write_22232 mem_write 3 22232 NULL
104964 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104965 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
104966 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104967 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104968 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
104969 +add_res_tree_22263 add_res_tree 7 22263 NULL
104970 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104971 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104972 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
104973 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104974 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104975 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104976 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
104977 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
104978 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
104979 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
104980 +atomic_read_22342 atomic_read 0 22342 NULL
104981 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
104982 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104983 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104984 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104985 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104986 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104987 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104988 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
104989 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
104990 +zoran_write_22404 zoran_write 3 22404 NULL
104991 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
104992 +queue_reply_22416 queue_reply 3 22416 NULL
104993 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104994 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104995 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
104996 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104997 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104998 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
104999 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
105000 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
105001 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
105002 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
105003 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
105004 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
105005 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
105006 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
105007 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
105008 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
105009 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
105010 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
105011 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
105012 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
105013 +snapshot_read_22601 snapshot_read 3 22601 NULL
105014 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
105015 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
105016 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
105017 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
105018 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
105019 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
105020 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
105021 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
105022 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
105023 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
105024 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
105025 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
105026 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
105027 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
105028 +reg_umr_22686 reg_umr 5 22686 NULL
105029 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
105030 +map_22700 map 2 22700 NULL nohasharray
105031 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
105032 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
105033 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
105034 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
105035 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
105036 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
105037 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
105038 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
105039 +print_frame_22769 print_frame 0 22769 NULL
105040 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
105041 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
105042 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
105043 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
105044 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
105045 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
105046 +create_attr_set_22861 create_attr_set 1 22861 NULL
105047 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
105048 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
105049 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
105050 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
105051 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
105052 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
105053 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
105054 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
105055 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
105056 +vme_get_size_22964 vme_get_size 0 22964 NULL
105057 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
105058 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
105059 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
105060 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
105061 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
105062 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
105063 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
105064 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
105065 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
105066 +st_status_23032 st_status 5 23032 NULL
105067 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
105068 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
105069 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
105070 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
105071 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
105072 +filp_close_23071 filp_close 0 23071 NULL
105073 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
105074 +raw_sendmsg_23078 raw_sendmsg 4 23078 NULL
105075 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
105076 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
105077 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
105078 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
105079 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
105080 +fls_long_23096 fls_long 0 23096 NULL
105081 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
105082 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
105083 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
105084 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
105085 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
105086 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
105087 +__clear_user_23118 __clear_user 0-2 23118 NULL
105088 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
105089 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
105090 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
105091 +read_file_ani_23161 read_file_ani 3 23161 NULL
105092 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
105093 +usblp_write_23178 usblp_write 3 23178 NULL
105094 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
105095 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
105096 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
105097 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
105098 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
105099 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
105100 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
105101 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
105102 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
105103 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
105104 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
105105 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
105106 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
105107 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
105108 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
105109 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
105110 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
105111 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
105112 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
105113 +page_readlink_23346 page_readlink 3 23346 NULL
105114 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
105115 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
105116 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
105117 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
105118 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
105119 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
105120 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
105121 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
105122 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
105123 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
105124 +linear_conf_23485 linear_conf 2 23485 NULL
105125 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
105126 +event_filter_read_23494 event_filter_read 3 23494 NULL
105127 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
105128 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
105129 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
105130 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
105131 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
105132 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
105133 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
105134 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
105135 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
105136 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
105137 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
105138 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
105139 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
105140 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
105141 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
105142 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
105143 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
105144 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
105145 +alloc_pte_23642 alloc_pte 3 23642 NULL
105146 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
105147 +sInW_23663 sInW 0 23663 NULL
105148 +SyS_connect_23669 SyS_connect 3 23669 NULL
105149 +cx18_read_23699 cx18_read 3 23699 NULL
105150 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
105151 +at_get_23708 at_get 0 23708 NULL
105152 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
105153 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
105154 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
105155 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
105156 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
105157 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
105158 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
105159 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
105160 +map_write_23795 map_write 3 23795 NULL
105161 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
105162 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
105163 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
105164 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
105165 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
105166 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
105167 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
105168 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
105169 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
105170 +p54_init_common_23850 p54_init_common 1 23850 NULL
105171 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
105172 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
105173 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
105174 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
105175 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
105176 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
105177 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
105178 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
105179 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
105180 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
105181 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
105182 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
105183 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
105184 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
105185 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
105186 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
105187 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
105188 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
105189 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
105190 +vfs_write_23971 vfs_write 0-3 23971 NULL
105191 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
105192 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
105193 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
105194 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
105195 +give_pages_24021 give_pages 3 24021 NULL
105196 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
105197 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
105198 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
105199 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
105200 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
105201 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
105202 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
105203 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
105204 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
105205 +lov_brw_24122 lov_brw 4 24122 NULL
105206 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
105207 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
105208 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
105209 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
105210 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
105211 +set_discard_24162 set_discard 2 24162 NULL
105212 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
105213 +adu_read_24177 adu_read 3 24177 NULL
105214 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
105215 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
105216 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
105217 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
105218 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
105219 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
105220 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
105221 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
105222 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
105223 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
105224 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
105225 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
105226 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
105227 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
105228 +thin_status_24278 thin_status 5 24278 NULL
105229 +msg_size_24288 msg_size 0 24288 NULL
105230 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
105231 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
105232 +map_page_24298 map_page 3-4 24298 NULL
105233 +gserial_connect_24302 gserial_connect 0 24302 NULL
105234 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
105235 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
105236 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
105237 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
105238 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
105239 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
105240 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
105241 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
105242 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
105243 +igetword_24373 igetword 0 24373 NULL
105244 +max_io_len_24384 max_io_len 0-1 24384 NULL
105245 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
105246 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
105247 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
105248 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
105249 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
105250 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
105251 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
105252 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
105253 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
105254 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
105255 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
105256 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
105257 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
105258 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
105259 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
105260 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
105261 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
105262 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
105263 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
105264 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
105265 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
105266 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
105267 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
105268 +pd_video_read_24510 pd_video_read 3 24510 NULL
105269 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
105270 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
105271 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
105272 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
105273 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
105274 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
105275 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
105276 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
105277 +SyS_poll_24620 SyS_poll 2 24620 NULL
105278 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
105279 +context_alloc_24645 context_alloc 3 24645 NULL
105280 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
105281 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
105282 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
105283 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
105284 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
105285 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
105286 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
105287 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
105288 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
105289 +kempld_read8_24756 kempld_read8 0 24756 NULL
105290 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
105291 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
105292 +cache_read_24790 cache_read 3 24790 NULL
105293 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
105294 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
105295 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
105296 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
105297 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
105298 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
105299 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
105300 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
105301 +net2272_read_24825 net2272_read 0 24825 NULL
105302 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
105303 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
105304 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
105305 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
105306 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
105307 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
105308 +setup_buffering_24872 setup_buffering 3 24872 NULL
105309 +queues_read_24877 queues_read 3 24877 NULL
105310 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
105311 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
105312 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
105313 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
105314 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
105315 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
105316 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
105317 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
105318 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
105319 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
105320 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
105321 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
105322 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
105323 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
105324 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
105325 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
105326 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
105327 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
105328 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
105329 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
105330 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
105331 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
105332 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
105333 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
105334 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
105335 +record_new_ref_25154 record_new_ref 0 25154 NULL
105336 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
105337 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
105338 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
105339 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
105340 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
105341 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
105342 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
105343 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
105344 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
105345 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
105346 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
105347 +stripe_status_25259 stripe_status 5 25259 NULL
105348 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
105349 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
105350 +vfs_writev_25278 vfs_writev 3 25278 NULL
105351 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
105352 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
105353 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
105354 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
105355 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
105356 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
105357 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
105358 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
105359 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
105360 +SyS_splice_25390 SyS_splice 5 25390 NULL
105361 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
105362 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
105363 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
105364 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
105365 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
105366 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
105367 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
105368 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
105369 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
105370 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
105371 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
105372 +sb_permission_25523 sb_permission 0 25523 NULL
105373 +down_read_failed_25532 down_read_failed 2 25532 NULL
105374 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
105375 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
105376 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
105377 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
105378 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
105379 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
105380 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
105381 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
105382 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
105383 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
105384 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
105385 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
105386 +__direct_map_25647 __direct_map 6-5 25647 NULL
105387 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
105388 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
105389 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
105390 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
105391 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
105392 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
105393 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
105394 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
105395 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
105396 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
105397 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
105398 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
105399 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
105400 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
105401 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
105402 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
105403 +sg_read_25799 sg_read 3 25799 NULL
105404 +system_enable_read_25815 system_enable_read 3 25815 NULL
105405 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
105406 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
105407 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
105408 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
105409 +parport_read_25855 parport_read 0 25855 NULL
105410 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
105411 +key_attr_size_25865 key_attr_size 0 25865 NULL
105412 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
105413 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
105414 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
105415 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
105416 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
105417 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
105418 +rcname_read_25919 rcname_read 3 25919 NULL
105419 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
105420 +key_flags_read_25931 key_flags_read 3 25931 NULL
105421 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
105422 +flush_25957 flush 2 25957 NULL
105423 +video_register_device_25971 video_register_device 3 25971 NULL
105424 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
105425 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
105426 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
105427 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
105428 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
105429 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
105430 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
105431 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
105432 +tun_do_read_26047 tun_do_read 5 26047 NULL
105433 +make_bfloat_26056 make_bfloat 2 26056 NULL
105434 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
105435 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
105436 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
105437 +dup_ref_26100 dup_ref 0 26100 NULL
105438 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
105439 +read_sb_page_26119 read_sb_page 5 26119 NULL
105440 +__fswab64_26155 __fswab64 0 26155 NULL
105441 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
105442 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
105443 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
105444 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
105445 +disk_devt_26180 disk_devt 0 26180 NULL
105446 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
105447 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
105448 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
105449 +mce_write_26201 mce_write 3 26201 NULL
105450 +SyS_splice_26206 SyS_splice 5 26206 NULL
105451 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
105452 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
105453 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
105454 +bio_split_26235 bio_split 2 26235 NULL
105455 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
105456 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
105457 +do_setxattr_26264 do_setxattr 0 26264 NULL
105458 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
105459 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
105460 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
105461 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
105462 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
105463 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
105464 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
105465 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
105466 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
105467 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
105468 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
105469 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
105470 +ntty_write_26404 ntty_write 3 26404 NULL
105471 +pagemap_read_26441 pagemap_read 3 26441 NULL
105472 +tower_read_26461 tower_read 3 26461 NULL nohasharray
105473 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
105474 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
105475 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
105476 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
105477 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
105478 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
105479 +read_vmcore_26501 read_vmcore 3 26501 NULL
105480 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
105481 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
105482 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
105483 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
105484 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
105485 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
105486 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
105487 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
105488 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
105489 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
105490 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
105491 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
105492 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
105493 +pack_value_26625 pack_value 1 26625 NULL
105494 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
105495 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
105496 +process_extent_26646 process_extent 0 26646 NULL nohasharray
105497 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
105498 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
105499 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
105500 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
105501 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
105502 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
105503 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
105504 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
105505 +bos_desc_26752 bos_desc 0 26752 NULL
105506 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
105507 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
105508 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
105509 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
105510 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
105511 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
105512 +smk_write_load_26829 smk_write_load 3 26829 NULL
105513 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
105514 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
105515 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
105516 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
105517 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
105518 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
105519 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
105520 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
105521 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
105522 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
105523 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
105524 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
105525 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
105526 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
105527 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
105528 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
105529 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
105530 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
105531 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
105532 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
105533 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
105534 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
105535 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
105536 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
105537 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
105538 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
105539 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
105540 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
105541 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
105542 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
105543 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
105544 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
105545 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
105546 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
105547 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
105548 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
105549 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
105550 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
105551 +pms_capture_27142 pms_capture 4 27142 NULL
105552 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
105553 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
105554 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
105555 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
105556 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
105557 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
105558 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
105559 +write_kmem_27225 write_kmem 3 27225 NULL
105560 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
105561 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
105562 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
105563 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
105564 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
105565 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
105566 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
105567 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
105568 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
105569 +write_buf_27316 write_buf 0-3 27316 NULL
105570 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
105571 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
105572 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
105573 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
105574 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
105575 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
105576 +seq_read_27411 seq_read 3 27411 NULL
105577 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
105578 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
105579 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
105580 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
105581 +cypress_write_27423 cypress_write 4 27423 NULL
105582 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
105583 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
105584 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
105585 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
105586 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
105587 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
105588 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
105589 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
105590 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
105591 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
105592 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
105593 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
105594 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
105595 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
105596 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
105597 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
105598 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
105599 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
105600 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
105601 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
105602 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
105603 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
105604 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
105605 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
105606 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
105607 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
105608 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
105609 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
105610 +evm_write_key_27715 evm_write_key 3 27715 NULL
105611 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
105612 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
105613 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
105614 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
105615 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
105616 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
105617 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
105618 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
105619 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
105620 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
105621 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
105622 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
105623 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
105624 +init_header_complete_27833 init_header_complete 0 27833 NULL
105625 +read_profile_27859 read_profile 3 27859 NULL
105626 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
105627 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
105628 +process_all_extents_27879 process_all_extents 0 27879 NULL
105629 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
105630 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
105631 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
105632 +bm_find_next_27929 bm_find_next 2 27929 NULL
105633 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
105634 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
105635 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
105636 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
105637 +device_register_27972 device_register 0 27972 NULL nohasharray
105638 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
105639 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
105640 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
105641 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
105642 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
105643 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
105644 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
105645 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
105646 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
105647 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
105648 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
105649 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
105650 +pool_status_28055 pool_status 5 28055 NULL
105651 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
105652 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
105653 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
105654 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
105655 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
105656 +SyS_brk_28096 SyS_brk 1 28096 NULL
105657 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
105658 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
105659 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
105660 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
105661 +video_read_28148 video_read 3 28148 NULL
105662 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
105663 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
105664 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
105665 +vread_28173 vread 0-3 28173 NULL
105666 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
105667 +counter_free_res_28187 counter_free_res 5 28187 NULL
105668 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
105669 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
105670 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
105671 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
105672 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
105673 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
105674 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
105675 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
105676 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
105677 +usemap_size_28281 usemap_size 0 28281 NULL
105678 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
105679 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
105680 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
105681 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
105682 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
105683 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
105684 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
105685 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
105686 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
105687 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
105688 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
105689 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
105690 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
105691 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
105692 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
105693 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
105694 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
105695 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
105696 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
105697 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
105698 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
105699 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
105700 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
105701 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
105702 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
105703 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
105704 +clear_discard_28494 clear_discard 2 28494 NULL
105705 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
105706 +__next_node_28521 __next_node 1-0 28521 NULL
105707 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
105708 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
105709 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
105710 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
105711 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
105712 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
105713 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
105714 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
105715 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
105716 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
105717 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
105718 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
105719 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
105720 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
105721 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
105722 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
105723 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
105724 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
105725 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
105726 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
105727 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
105728 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
105729 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
105730 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
105731 +balance_level_28707 balance_level 0 28707 NULL
105732 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
105733 +spi_execute_28736 spi_execute 5 28736 NULL
105734 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
105735 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
105736 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
105737 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
105738 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
105739 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
105740 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
105741 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
105742 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
105743 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
105744 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
105745 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
105746 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
105747 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
105748 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
105749 +to_cblock_28899 to_cblock 0-1 28899 NULL
105750 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
105751 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
105752 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
105753 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
105754 +push_rx_28939 push_rx 3 28939 NULL
105755 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
105756 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
105757 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
105758 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
105759 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
105760 +bin_uuid_28999 bin_uuid 3 28999 NULL
105761 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
105762 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
105763 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
105764 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
105765 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
105766 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 NULL nohasharray
105767 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 &ProcessGetHostMibs_29049
105768 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
105769 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
105770 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
105771 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
105772 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
105773 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
105774 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
105775 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
105776 +snprintf_29125 snprintf 0 29125 NULL
105777 +iov_shorten_29130 iov_shorten 0 29130 NULL
105778 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
105779 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0 29152 NULL
105780 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
105781 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
105782 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
105783 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
105784 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
105785 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
105786 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
105787 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
105788 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
105789 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
105790 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
105791 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
105792 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
105793 +block_div_29268 block_div 0-1-2 29268 NULL
105794 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
105795 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
105796 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
105797 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
105798 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
105799 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
105800 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
105801 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
105802 +tun_put_user_29337 tun_put_user 5 29337 NULL
105803 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
105804 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
105805 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
105806 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
105807 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
105808 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
105809 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
105810 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
105811 +mempool_create_29437 mempool_create 1 29437 NULL
105812 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
105813 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
105814 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
105815 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
105816 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
105817 +do_register_entry_29478 do_register_entry 4 29478 NULL
105818 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
105819 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
105820 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
105821 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
105822 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
105823 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
105824 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
105825 +vfs_read_29543 vfs_read 0-3 29543 NULL
105826 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
105827 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
105828 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
105829 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
105830 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
105831 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
105832 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
105833 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
105834 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
105835 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
105836 +slots_per_page_29601 slots_per_page 0 29601 NULL
105837 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
105838 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
105839 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
105840 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
105841 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
105842 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
105843 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
105844 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
105845 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
105846 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
105847 +probes_write_29711 probes_write 3 29711 NULL
105848 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
105849 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
105850 +std_nic_write_29752 std_nic_write 3 29752 NULL
105851 +dbAlloc_29794 dbAlloc 0 29794 NULL
105852 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
105853 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
105854 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
105855 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
105856 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
105857 +count_partial_29850 count_partial 0 29850 NULL
105858 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
105859 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
105860 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
105861 +tlv_put_29872 tlv_put 0 29872 NULL
105862 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
105863 +changed_extent_29881 changed_extent 0 29881 NULL
105864 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
105865 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
105866 +write_file_queue_29922 write_file_queue 3 29922 NULL
105867 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
105868 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
105869 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
105870 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
105871 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
105872 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
105873 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
105874 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
105875 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
105876 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
105877 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
105878 +SyS_write_30059 SyS_write 3 30059 NULL
105879 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
105880 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
105881 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
105882 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
105883 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
105884 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
105885 +recv_stream_30138 recv_stream 4 30138 NULL
105886 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
105887 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
105888 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
105889 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
105890 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
105891 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
105892 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
105893 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
105894 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
105895 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
105896 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
105897 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
105898 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
105899 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
105900 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
105901 +compat_readv_30273 compat_readv 3 30273 NULL
105902 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
105903 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
105904 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
105905 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
105906 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
105907 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
105908 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
105909 +i8254_read_30330 i8254_read 0 30330 NULL
105910 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
105911 +resource_from_user_30341 resource_from_user 3 30341 NULL
105912 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
105913 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
105914 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
105915 +inet_getid_30365 inet_getid 2 30365 NULL
105916 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
105917 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
105918 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
105919 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
105920 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
105921 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
105922 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
105923 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
105924 +mq_create_30425 mq_create 1 30425 NULL nohasharray
105925 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
105926 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
105927 +enable_write_30456 enable_write 3 30456 NULL
105928 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
105929 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
105930 +urandom_read_30462 urandom_read 3 30462 NULL
105931 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
105932 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
105933 +send_rmdir_30470 send_rmdir 0 30470 NULL
105934 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
105935 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
105936 +write_head_30481 write_head 4 30481 NULL
105937 +adu_write_30487 adu_write 3 30487 NULL
105938 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
105939 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
105940 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
105941 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
105942 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
105943 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
105944 +set_le_30581 set_le 4 30581 NULL
105945 +from_cblock_30582 from_cblock 0-1 30582 NULL
105946 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
105947 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
105948 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
105949 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
105950 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
105951 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
105952 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
105953 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
105954 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
105955 +agp_remap_30665 agp_remap 2 30665 NULL
105956 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
105957 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
105958 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
105959 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
105960 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
105961 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
105962 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
105963 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
105964 +snapshot_status_30744 snapshot_status 5 30744 NULL
105965 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
105966 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
105967 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
105968 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
105969 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
105970 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
105971 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
105972 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
105973 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
105974 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
105975 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
105976 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
105977 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
105978 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
105979 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
105980 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
105981 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
105982 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
105983 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
105984 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
105985 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
105986 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
105987 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
105988 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
105989 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
105990 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
105991 +depth_read_31112 depth_read 3 31112 NULL
105992 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
105993 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
105994 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
105995 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
105996 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
105997 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
105998 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
105999 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
106000 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
106001 +__read_reg_31216 __read_reg 0 31216 NULL
106002 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
106003 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
106004 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
106005 +cyy_readb_31240 cyy_readb 0 31240 NULL
106006 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
106007 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
106008 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
106009 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
106010 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
106011 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
106012 +command_file_write_31318 command_file_write 3 31318 NULL
106013 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
106014 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
106015 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
106016 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
106017 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
106018 +outlen_write_31358 outlen_write 3 31358 NULL
106019 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
106020 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
106021 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
106022 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
106023 +inb_31388 inb 0 31388 NULL
106024 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
106025 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
106026 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
106027 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
106028 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
106029 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
106030 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
106031 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
106032 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
106033 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
106034 +do_fcntl_31468 do_fcntl 3 31468 NULL
106035 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
106036 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
106037 +alg_setkey_31485 alg_setkey 3 31485 NULL
106038 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
106039 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
106040 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
106041 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
106042 +hidraw_write_31536 hidraw_write 3 31536 NULL
106043 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
106044 +usbvision_read_31555 usbvision_read 3 31555 NULL
106045 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
106046 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
106047 +osst_write_31581 osst_write 3 31581 NULL
106048 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
106049 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
106050 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
106051 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
106052 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
106053 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
106054 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
106055 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
106056 +__lgread_31668 __lgread 4 31668 NULL
106057 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
106058 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
106059 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
106060 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
106061 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
106062 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
106063 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
106064 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
106065 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
106066 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
106067 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
106068 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
106069 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
106070 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
106071 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
106072 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
106073 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
106074 +data_write_31805 data_write 3 31805 NULL
106075 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
106076 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
106077 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
106078 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
106079 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
106080 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
106081 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
106082 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
106083 +xattr_permission_31907 xattr_permission 0 31907 NULL
106084 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
106085 +new_dir_31919 new_dir 3 31919 NULL
106086 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
106087 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
106088 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
106089 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
106090 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
106091 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
106092 +vb2_write_31948 vb2_write 3 31948 NULL
106093 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
106094 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
106095 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
106096 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
106097 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
106098 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
106099 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
106100 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
106101 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
106102 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
106103 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
106104 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
106105 +calc_hmac_32010 calc_hmac 3 32010 NULL
106106 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
106107 +resource_alignment_32020 resource_alignment 0 32020 NULL
106108 +aead_len_32021 aead_len 0 32021 NULL
106109 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
106110 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
106111 +stk_read_32038 stk_read 3 32038 NULL
106112 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
106113 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
106114 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
106115 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
106116 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
106117 +bio_alloc_32095 bio_alloc 2 32095 NULL
106118 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
106119 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
106120 +disk_status_32120 disk_status 4 32120 NULL
106121 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
106122 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
106123 +venus_link_32165 venus_link 5 32165 NULL
106124 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
106125 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
106126 +load_header_32183 load_header 0 32183 NULL
106127 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
106128 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
106129 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
106130 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
106131 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
106132 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
106133 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
106134 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
106135 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
106136 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
106137 +SyS_select_32319 SyS_select 1 32319 NULL
106138 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
106139 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
106140 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
106141 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
106142 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
106143 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
106144 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
106145 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
106146 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
106147 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
106148 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
106149 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
106150 +local_clock_32385 local_clock 0 32385 NULL
106151 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
106152 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
106153 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
106154 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
106155 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
106156 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
106157 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
106158 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
106159 +cache_status_32462 cache_status 5 32462 NULL
106160 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
106161 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
106162 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
106163 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
106164 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
106165 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
106166 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
106167 +disconnect_32521 disconnect 4 32521 NULL
106168 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
106169 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
106170 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
106171 +ilo_read_32531 ilo_read 3 32531 NULL
106172 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
106173 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
106174 +__first_node_32558 __first_node 0 32558 NULL
106175 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
106176 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
106177 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
106178 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
106179 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
106180 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
106181 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
106182 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
106183 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
106184 +kvmalloc_32646 kvmalloc 1 32646 NULL
106185 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
106186 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
106187 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
106188 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
106189 +apei_res_add_32674 apei_res_add 0 32674 NULL
106190 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
106191 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
106192 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
106193 +get_arg_page_32746 get_arg_page 2 32746 NULL
106194 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
106195 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
106196 +begin_cmd_32766 begin_cmd 0 32766 NULL
106197 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
106198 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
106199 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
106200 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
106201 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
106202 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
106203 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
106204 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
106205 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
106206 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
106207 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
106208 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
106209 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
106210 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
106211 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
106212 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
106213 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
106214 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
106215 +compat_filldir_32999 compat_filldir 3 32999 NULL
106216 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
106217 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
106218 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
106219 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
106220 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
106221 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
106222 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
106223 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
106224 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
106225 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
106226 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
106227 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
106228 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
106229 +alloc_tio_33077 alloc_tio 3 33077 NULL
106230 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
106231 +write_node_33121 write_node 4 33121 NULL
106232 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
106233 +__len_within_target_33132 __len_within_target 0 33132 NULL
106234 +SyS_poll_33152 SyS_poll 2 33152 NULL
106235 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
106236 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
106237 +pp_read_33210 pp_read 3 33210 NULL
106238 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
106239 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
106240 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
106241 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
106242 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
106243 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
106244 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
106245 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
106246 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
106247 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
106248 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
106249 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
106250 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
106251 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
106252 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
106253 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
106254 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
106255 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
106256 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
106257 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
106258 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
106259 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
106260 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
106261 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
106262 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
106263 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
106264 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
106265 +message_stats_list_33440 message_stats_list 5 33440 NULL
106266 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
106267 +create_entry_33479 create_entry 2 33479 NULL
106268 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
106269 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
106270 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
106271 +res_counter_read_33499 res_counter_read 4 33499 NULL
106272 +fb_read_33506 fb_read 3 33506 NULL
106273 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
106274 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
106275 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
106276 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
106277 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
106278 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
106279 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
106280 +read_symlink_33572 read_symlink 0 33572 NULL
106281 +count_subheaders_33591 count_subheaders 0 33591 NULL
106282 +scsi_execute_33596 scsi_execute 5 33596 NULL
106283 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
106284 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
106285 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
106286 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
106287 +do_sync_write_33624 do_sync_write 0 33624 NULL
106288 +stride_page_count_33641 stride_page_count 2 33641 NULL
106289 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
106290 +inw_p_33668 inw_p 0 33668 NULL
106291 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
106292 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
106293 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
106294 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
106295 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
106296 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
106297 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
106298 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
106299 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
106300 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
106301 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
106302 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
106303 +hashtab_create_33769 hashtab_create 3 33769 NULL
106304 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
106305 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
106306 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
106307 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
106308 +filter_write_33819 filter_write 3 33819 NULL
106309 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
106310 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
106311 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
106312 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
106313 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
106314 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
106315 +bin_string_33884 bin_string 3-5 33884 NULL
106316 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
106317 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
106318 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
106319 +atomic64_add_return_33927 atomic64_add_return 0-1 33927 NULL
106320 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
106321 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
106322 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
106323 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
106324 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
106325 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
106326 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
106327 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
106328 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
106329 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
106330 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
106331 +ppp_write_34034 ppp_write 3 34034 NULL
106332 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
106333 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
106334 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
106335 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
106336 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
106337 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
106338 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
106339 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
106340 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
106341 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
106342 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
106343 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
106344 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
106345 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
106346 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
106347 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
106348 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
106349 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
106350 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
106351 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
106352 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
106353 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
106354 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
106355 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
106356 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
106357 +device_private_init_34279 device_private_init 0 34279 NULL
106358 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
106359 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
106360 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
106361 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
106362 +__insert_34349 __insert 2-3 34349 NULL
106363 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
106364 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
106365 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
106366 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
106367 +ea_read_34378 ea_read 0 34378 NULL
106368 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
106369 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
106370 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
106371 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
106372 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
106373 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
106374 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
106375 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
106376 +security_socket_create_34439 security_socket_create 0 34439 NULL
106377 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
106378 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
106379 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
106380 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
106381 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
106382 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
106383 +SyS_pwritev_34494 SyS_pwritev 3 34494 NULL nohasharray
106384 +__ffs64_34494 __ffs64 1-0 34494 &SyS_pwritev_34494
106385 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
106386 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
106387 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
106388 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 NULL nohasharray
106389 +tracing_stats_read_34537 tracing_stats_read 3 34537 &ext4_fallocate_34537
106390 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
106391 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
106392 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
106393 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
106394 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
106395 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
106396 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
106397 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
106398 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
106399 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
106400 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
106401 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
106402 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL nohasharray
106403 +mtd_write_34609 mtd_write 0 34609 &__jffs2_ref_totlen_34609
106404 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
106405 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
106406 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
106407 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
106408 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
106409 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
106410 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
106411 +port_print_34704 port_print 3 34704 NULL
106412 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
106413 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
106414 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
106415 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
106416 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
106417 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
106418 +device_add_34766 device_add 0 34766 NULL
106419 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
106420 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
106421 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
106422 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
106423 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
106424 +file_page_index_34820 file_page_index 0-2 34820 NULL
106425 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
106426 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
106427 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
106428 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
106429 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
106430 +msg_print_text_34889 msg_print_text 0 34889 NULL
106431 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
106432 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
106433 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
106434 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
106435 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
106436 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
106437 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
106438 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
106439 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
106440 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
106441 +mq_lookup_34990 mq_lookup 2 34990 NULL
106442 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
106443 +schedule_erase_34996 schedule_erase 0 34996 NULL
106444 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
106445 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
106446 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
106447 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
106448 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
106449 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
106450 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
106451 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
106452 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
106453 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
106454 +store_ifalias_35088 store_ifalias 4 35088 NULL
106455 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
106456 +capi_write_35104 capi_write 3 35104 NULL nohasharray
106457 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
106458 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
106459 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
106460 +message_stats_print_35158 message_stats_print 6 35158 NULL
106461 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
106462 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
106463 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
106464 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
106465 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
106466 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
106467 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
106468 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
106469 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
106470 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
106471 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
106472 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
106473 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
106474 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
106475 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
106476 +set_fd_set_35249 set_fd_set 1 35249 NULL
106477 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
106478 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
106479 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
106480 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
106481 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
106482 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
106483 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
106484 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
106485 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
106486 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
106487 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
106488 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
106489 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
106490 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
106491 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
106492 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
106493 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
106494 +read_kmem_35372 read_kmem 3 35372 NULL
106495 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
106496 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
106497 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
106498 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
106499 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
106500 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
106501 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
106502 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
106503 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
106504 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
106505 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
106506 +async_setkey_35521 async_setkey 3 35521 NULL
106507 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
106508 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
106509 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
106510 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
106511 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
106512 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
106513 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
106514 +send_update_extent_35556 send_update_extent 0 35556 NULL
106515 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
106516 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
106517 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
106518 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
106519 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
106520 +kernel_readv_35617 kernel_readv 3 35617 NULL
106521 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
106522 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
106523 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
106524 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
106525 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
106526 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
106527 +dm_table_create_35687 dm_table_create 3 35687 NULL
106528 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
106529 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
106530 +md_super_write_35703 md_super_write 4 35703 NULL
106531 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
106532 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
106533 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
106534 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
106535 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
106536 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
106537 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
106538 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
106539 +changed_xattr_35860 changed_xattr 0 35860 NULL
106540 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
106541 +fls64_35862 fls64 0 35862 NULL
106542 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
106543 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
106544 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
106545 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
106546 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
106547 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
106548 +balance_node_right_35920 balance_node_right 0 35920 NULL
106549 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
106550 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
106551 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
106552 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
106553 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
106554 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
106555 +acl_alloc_35979 acl_alloc 1 35979 NULL
106556 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
106557 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
106558 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
106559 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
106560 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
106561 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
106562 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
106563 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
106564 +account_shadowed_36048 account_shadowed 2 36048 NULL
106565 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
106566 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
106567 +did_create_dir_36062 did_create_dir 0 36062 NULL
106568 +write_emulate_36065 write_emulate 2-4 36065 NULL
106569 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
106570 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
106571 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
106572 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
106573 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
106574 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
106575 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
106576 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
106577 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
106578 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
106579 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
106580 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
106581 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
106582 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
106583 +twl_set_36154 twl_set 2 36154 NULL
106584 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
106585 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
106586 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
106587 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
106588 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
106589 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
106590 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
106591 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
106592 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
106593 +is_dirty_36223 is_dirty 2 36223 NULL
106594 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
106595 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
106596 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
106597 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
106598 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
106599 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
106600 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
106601 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
106602 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
106603 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
106604 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
106605 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
106606 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
106607 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
106608 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
106609 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
106610 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
106611 +lc_create_36332 lc_create 4 36332 NULL
106612 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
106613 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
106614 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
106615 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
106616 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
106617 +to_sector_36361 to_sector 0-1 36361 NULL
106618 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
106619 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
106620 +tunables_read_36385 tunables_read 3 36385 NULL
106621 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
106622 +sierra_write_36402 sierra_write 4 36402 NULL
106623 +msb_update_block_36412 msb_update_block 2 36412 NULL
106624 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
106625 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
106626 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
106627 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
106628 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
106629 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
106630 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
106631 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
106632 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
106633 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
106634 +cmd_loop_36491 cmd_loop 0 36491 NULL
106635 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
106636 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
106637 +get_param_l_36518 get_param_l 0 36518 NULL
106638 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
106639 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
106640 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
106641 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
106642 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
106643 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
106644 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
106645 +__erst_read_36579 __erst_read 0 36579 NULL
106646 +put_cmsg_36589 put_cmsg 4 36589 NULL
106647 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
106648 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
106649 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
106650 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
106651 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
106652 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
106653 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
106654 +perf_calculate_period_36662 perf_calculate_period 2-3 36662 NULL
106655 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
106656 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
106657 +xillybus_read_36678 xillybus_read 3 36678 NULL
106658 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
106659 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
106660 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
106661 +sched_clock_36717 sched_clock 0 36717 NULL
106662 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
106663 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
106664 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
106665 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
106666 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
106667 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
106668 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
106669 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
106670 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
106671 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
106672 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
106673 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
106674 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
106675 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
106676 +cm_write_36858 cm_write 3 36858 NULL
106677 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
106678 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
106679 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
106680 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
106681 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
106682 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
106683 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
106684 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
106685 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
106686 +build_key_36931 build_key 1 36931 NULL
106687 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
106688 +div_u64_36951 div_u64 0 36951 NULL
106689 +write_leb_36957 write_leb 0-5 36957 NULL
106690 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
106691 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
106692 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
106693 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
106694 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
106695 +setxattr_37006 setxattr 4 37006 NULL
106696 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
106697 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
106698 +command_file_read_37038 command_file_read 3 37038 NULL
106699 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
106700 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
106701 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
106702 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
106703 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
106704 +parse_command_37079 parse_command 2 37079 NULL
106705 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
106706 +tun_get_user_37094 tun_get_user 5 37094 NULL
106707 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
106708 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
106709 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
106710 +msg_word_37164 msg_word 0 37164 NULL
106711 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
106712 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
106713 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
106714 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
106715 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
106716 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
106717 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
106718 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
106719 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
106720 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
106721 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
106722 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
106723 +__do_replace_37227 __do_replace 5 37227 NULL
106724 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
106725 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
106726 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
106727 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
106728 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
106729 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
106730 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
106731 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
106732 +create_cq_user_37278 create_cq_user 5 37278 NULL
106733 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
106734 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
106735 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
106736 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
106737 +send_msg_37323 send_msg 4 37323 NULL
106738 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
106739 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
106740 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
106741 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
106742 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
106743 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
106744 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
106745 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
106746 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
106747 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
106748 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
106749 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
106750 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
106751 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
106752 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
106753 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
106754 +fru_alloc_37442 fru_alloc 1 37442 NULL
106755 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
106756 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
106757 +__remove_37457 __remove 2 37457 NULL
106758 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
106759 +get_est_timing_37484 get_est_timing 0 37484 NULL
106760 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
106761 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
106762 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
106763 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
106764 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
106765 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
106766 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
106767 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
106768 +hdr_size_37536 hdr_size 0 37536 NULL
106769 +extent_map_end_37550 extent_map_end 0 37550 NULL
106770 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
106771 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
106772 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
106773 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
106774 +alloc_descs_37593 alloc_descs 0-1 37593 NULL
106775 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
106776 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
106777 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
106778 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
106779 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
106780 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
106781 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
106782 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
106783 +alloc_fd_37637 alloc_fd 1 37637 NULL
106784 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
106785 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
106786 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
106787 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
106788 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
106789 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
106790 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
106791 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
106792 +page_chain_free_37697 page_chain_free 0 37697 NULL
106793 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
106794 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
106795 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
106796 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
106797 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
106798 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
106799 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
106800 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
106801 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
106802 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
106803 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
106804 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
106805 +deny_write_access_37813 deny_write_access 0 37813 NULL
106806 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
106807 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
106808 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
106809 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
106810 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
106811 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
106812 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
106813 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
106814 +set_registers_37883 set_registers 4 37883 NULL
106815 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
106816 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
106817 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
106818 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
106819 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
106820 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
106821 +write_file_bool_37957 write_file_bool 3 37957 NULL
106822 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
106823 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
106824 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
106825 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
106826 +vfs_readv_38011 vfs_readv 3 38011 NULL
106827 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
106828 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
106829 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
106830 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
106831 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
106832 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
106833 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
106834 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
106835 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
106836 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
106837 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
106838 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
106839 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
106840 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
106841 +ep0_read_38095 ep0_read 3 38095 NULL
106842 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
106843 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
106844 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
106845 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
106846 +_get_val_38115 _get_val 2 38115 NULL
106847 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
106848 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
106849 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
106850 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
106851 +send_rename_38170 send_rename 0 38170 NULL
106852 +cdev_add_38176 cdev_add 2-3 38176 NULL
106853 +create_srq_user_38191 create_srq_user 5 38191 NULL
106854 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
106855 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
106856 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
106857 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
106858 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
106859 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
106860 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
106861 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
106862 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
106863 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
106864 +from_dblock_38256 from_dblock 0-1 38256 NULL
106865 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
106866 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 NULL nohasharray
106867 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 &SYSC_msgrcv_38268 nohasharray
106868 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
106869 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
106870 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
106871 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
106872 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
106873 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
106874 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
106875 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
106876 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
106877 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
106878 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
106879 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
106880 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
106881 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
106882 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
106883 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
106884 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
106885 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
106886 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
106887 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
106888 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
106889 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
106890 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
106891 +dev_names_read_38509 dev_names_read 3 38509 NULL
106892 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
106893 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
106894 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
106895 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
106896 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
106897 +kuc_len_38557 kuc_len 0-1 38557 NULL
106898 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
106899 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
106900 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
106901 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
106902 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
106903 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
106904 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
106905 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
106906 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
106907 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
106908 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
106909 +cma_create_area_38642 cma_create_area 2 38642 NULL
106910 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
106911 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
106912 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
106913 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
106914 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
106915 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
106916 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
106917 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
106918 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
106919 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
106920 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
106921 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
106922 +udf_readpages_38761 udf_readpages 4 38761 NULL
106923 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
106924 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
106925 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
106926 +slab_order_38794 slab_order 0 38794 NULL
106927 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
106928 +err_decode_38804 err_decode 2 38804 NULL
106929 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
106930 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
106931 +direct_entry_38836 direct_entry 3 38836 NULL
106932 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
106933 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
106934 +interfaces_38859 interfaces 2 38859 NULL
106935 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
106936 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
106937 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
106938 +traverse_38897 traverse 0 38897 NULL
106939 +__fswab16_38898 __fswab16 0 38898 NULL
106940 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
106941 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
106942 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
106943 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
106944 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
106945 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
106946 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
106947 +udf_new_block_38999 udf_new_block 4 38999 NULL
106948 +get_nodes_39012 get_nodes 3 39012 NULL
106949 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
106950 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
106951 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
106952 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
106953 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
106954 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
106955 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
106956 +atomic64_add_negative_39098 atomic64_add_negative 1 39098 NULL
106957 +ReadHFC_39104 ReadHFC 0 39104 NULL
106958 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
106959 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
106960 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
106961 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
106962 +ea_foreach_39133 ea_foreach 0 39133 NULL
106963 +generic_permission_39150 generic_permission 0 39150 NULL
106964 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
106965 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
106966 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
106967 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
106968 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
106969 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
106970 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
106971 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
106972 +drm_order_39244 drm_order 0 39244 NULL
106973 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
106974 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
106975 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
106976 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
106977 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
106978 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
106979 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
106980 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
106981 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
106982 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
106983 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
106984 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
106985 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
106986 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
106987 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
106988 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
106989 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
106990 +__send_to_port_39386 __send_to_port 3 39386 NULL
106991 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
106992 +user_power_read_39414 user_power_read 3 39414 NULL
106993 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
106994 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
106995 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
106996 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
106997 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
106998 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
106999 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
107000 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
107001 +int_proc_write_39542 int_proc_write 3 39542 NULL
107002 +pp_write_39554 pp_write 3 39554 NULL
107003 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
107004 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
107005 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
107006 +ext_depth_39607 ext_depth 0 39607 NULL
107007 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
107008 +sdio_readb_39618 sdio_readb 0 39618 NULL
107009 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
107010 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
107011 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
107012 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
107013 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
107014 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
107015 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
107016 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
107017 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
107018 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
107019 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
107020 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
107021 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
107022 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
107023 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
107024 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
107025 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
107026 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
107027 +can_rmdir_39890 can_rmdir 0 39890 NULL
107028 +pkt_add_39897 pkt_add 3 39897 NULL
107029 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
107030 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
107031 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
107032 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
107033 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
107034 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
107035 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
107036 +__spi_async_39932 __spi_async 0 39932 NULL
107037 +__get_order_39935 __get_order 0 39935 NULL
107038 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
107039 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
107040 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
107041 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
107042 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
107043 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
107044 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
107045 +server_name2svname_39998 server_name2svname 4 39998 NULL
107046 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
107047 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
107048 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
107049 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
107050 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
107051 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
107052 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
107053 +add_tty_40055 add_tty 1 40055 NULL nohasharray
107054 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
107055 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
107056 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
107057 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
107058 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
107059 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
107060 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
107061 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
107062 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
107063 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
107064 +pt_write_40159 pt_write 3 40159 NULL
107065 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
107066 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
107067 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
107068 +allocate_probes_40204 allocate_probes 1 40204 NULL
107069 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
107070 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
107071 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
107072 +osst_read_40237 osst_read 3 40237 NULL
107073 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
107074 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
107075 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
107076 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
107077 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
107078 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
107079 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
107080 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
107081 +SyS_bind_40303 SyS_bind 3 40303 NULL
107082 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
107083 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
107084 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
107085 +mmio_read_40348 mmio_read 4 40348 NULL
107086 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
107087 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
107088 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
107089 +get_chars_40373 get_chars 3 40373 NULL
107090 +submit_page_section_40408 submit_page_section 0 40408 NULL
107091 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
107092 +slab_node_40421 slab_node 0 40421 NULL
107093 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
107094 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
107095 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
107096 +SyS_writev_40467 SyS_writev 3 40467 NULL
107097 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
107098 +SyS_select_40473 SyS_select 1 40473 NULL
107099 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
107100 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
107101 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
107102 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
107103 +sg_phys_40507 sg_phys 0 40507 NULL
107104 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
107105 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
107106 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
107107 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
107108 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
107109 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
107110 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
107111 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
107112 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
107113 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
107114 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
107115 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
107116 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
107117 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
107118 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
107119 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
107120 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
107121 +fops_read_40672 fops_read 3 40672 NULL
107122 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
107123 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
107124 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
107125 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
107126 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
107127 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
107128 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
107129 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
107130 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
107131 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
107132 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
107133 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
107134 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
107135 +card_send_command_40757 card_send_command 3 40757 NULL
107136 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
107137 +pg_write_40766 pg_write 3 40766 NULL
107138 +show_list_40775 show_list 3-0 40775 NULL
107139 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
107140 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
107141 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
107142 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
107143 +add_action_40811 add_action 4 40811 NULL
107144 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
107145 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
107146 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
107147 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
107148 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
107149 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
107150 +read_file_queue_40895 read_file_queue 3 40895 NULL
107151 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
107152 +waiters_read_40902 waiters_read 3 40902 NULL
107153 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
107154 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
107155 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
107156 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
107157 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
107158 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
107159 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
107160 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
107161 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
107162 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
107163 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
107164 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
107165 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
107166 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
107167 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
107168 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
107169 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
107170 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
107171 +calculate_order_41061 calculate_order 0 41061 NULL
107172 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
107173 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
107174 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
107175 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
107176 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
107177 +dma_attach_41094 dma_attach 6-5 41094 NULL
107178 +provide_user_output_41105 provide_user_output 3 41105 NULL
107179 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
107180 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
107181 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
107182 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
107183 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
107184 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
107185 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
107186 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
107187 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
107188 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
107189 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
107190 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
107191 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
107192 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
107193 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
107194 +create_dir_41256 create_dir 0 41256 NULL
107195 +erst_read_41260 erst_read 0 41260 NULL
107196 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
107197 +alloc_context_41283 alloc_context 1 41283 NULL
107198 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
107199 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
107200 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
107201 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
107202 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
107203 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
107204 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
107205 +kmp_init_41373 kmp_init 2 41373 NULL
107206 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
107207 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
107208 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
107209 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
107210 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
107211 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
107212 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
107213 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
107214 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
107215 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
107216 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
107217 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
107218 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
107219 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
107220 +split_item_41483 split_item 0 41483 NULL
107221 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
107222 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
107223 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
107224 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
107225 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
107226 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
107227 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
107228 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
107229 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
107230 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
107231 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
107232 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
107233 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
107234 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
107235 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
107236 +vga_io_r_41609 vga_io_r 0 41609 NULL
107237 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
107238 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
107239 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
107240 +a2mp_send_41615 a2mp_send 4 41615 NULL
107241 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
107242 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
107243 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
107244 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
107245 +get_std_timing_41654 get_std_timing 0 41654 NULL
107246 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
107247 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
107248 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
107249 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
107250 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
107251 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
107252 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
107253 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
107254 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
107255 +fillonedir_41746 fillonedir 3 41746 NULL
107256 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
107257 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
107258 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
107259 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
107260 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
107261 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
107262 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
107263 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
107264 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
107265 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
107266 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
107267 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
107268 +pci_map_single_41869 pci_map_single 0 41869 NULL
107269 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
107270 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
107271 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
107272 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
107273 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
107274 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
107275 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
107276 +read_gssp_41947 read_gssp 3 41947 NULL
107277 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
107278 +portnames_read_41958 portnames_read 3 41958 NULL
107279 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
107280 +dst_mtu_41969 dst_mtu 0 41969 NULL
107281 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
107282 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
107283 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
107284 +pool_allocate_42012 pool_allocate 3 42012 NULL
107285 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
107286 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
107287 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
107288 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
107289 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
107290 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
107291 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
107292 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
107293 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
107294 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
107295 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
107296 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
107297 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
107298 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
107299 +send_truncate_42107 send_truncate 0 42107 NULL
107300 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
107301 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
107302 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
107303 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
107304 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
107305 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
107306 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
107307 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
107308 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
107309 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
107310 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
107311 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
107312 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
107313 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
107314 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
107315 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
107316 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
107317 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
107318 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
107319 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
107320 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
107321 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
107322 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
107323 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
107324 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
107325 +free_cblock_42318 free_cblock 2 42318 NULL
107326 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
107327 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
107328 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
107329 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
107330 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
107331 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
107332 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
107333 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
107334 +krng_get_random_42420 krng_get_random 3 42420 NULL
107335 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
107336 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
107337 +alloc_request_42448 alloc_request 0 42448 NULL
107338 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
107339 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
107340 +kuc_free_42455 kuc_free 2 42455 NULL
107341 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
107342 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
107343 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
107344 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
107345 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
107346 +bypass_write_42498 bypass_write 3 42498 NULL
107347 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
107348 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
107349 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
107350 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
107351 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
107352 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
107353 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
107354 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
107355 +inorder_next_42548 inorder_next 1-0 42548 NULL
107356 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
107357 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
107358 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
107359 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
107360 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
107361 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
107362 +map_state_42602 map_state 1 42602 NULL
107363 +resp_write_42628 resp_write 2 42628 NULL
107364 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
107365 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
107366 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
107367 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
107368 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
107369 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
107370 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
107371 +vb2_read_42703 vb2_read 3 42703 NULL
107372 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
107373 +read_status_42722 read_status 0 42722 NULL
107374 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
107375 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
107376 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
107377 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
107378 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
107379 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
107380 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
107381 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
107382 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
107383 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
107384 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
107385 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
107386 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
107387 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
107388 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
107389 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
107390 +set_arg_42824 set_arg 3 42824 NULL
107391 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
107392 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
107393 +prandom_u32_42853 prandom_u32 0 42853 NULL
107394 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
107395 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
107396 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
107397 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
107398 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
107399 +hd_end_request_42904 hd_end_request 2 42904 NULL
107400 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
107401 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
107402 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
107403 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
107404 +send_link_42948 send_link 0 42948 NULL
107405 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
107406 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
107407 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
107408 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
107409 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
107410 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
107411 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
107412 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
107413 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
107414 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
107415 +send_to_group_43051 send_to_group 0 43051 NULL
107416 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
107417 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
107418 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
107419 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
107420 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
107421 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
107422 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
107423 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
107424 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
107425 +send_cmd_43168 send_cmd 0 43168 NULL
107426 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
107427 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
107428 +uio_write_43202 uio_write 3 43202 NULL
107429 +iso_callback_43208 iso_callback 3 43208 NULL
107430 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
107431 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
107432 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
107433 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
107434 +fixup_leb_43256 fixup_leb 3 43256 NULL
107435 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
107436 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
107437 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
107438 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
107439 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
107440 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
107441 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
107442 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
107443 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
107444 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
107445 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
107446 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
107447 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
107448 +xenfb_write_43412 xenfb_write 3 43412 NULL
107449 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
107450 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
107451 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
107452 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
107453 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
107454 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
107455 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
107456 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
107457 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
107458 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
107459 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
107460 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
107461 +do_readlink_43518 do_readlink 2 43518 NULL
107462 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
107463 +read_events_43534 read_events 3 43534 NULL
107464 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
107465 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
107466 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
107467 +request_resource_43548 request_resource 0 43548 NULL
107468 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
107469 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
107470 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
107471 +proc_read_43614 proc_read 3 43614 NULL
107472 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
107473 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
107474 +random_write_43656 random_write 3 43656 NULL
107475 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
107476 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
107477 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
107478 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
107479 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
107480 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
107481 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
107482 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
107483 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
107484 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
107485 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
107486 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
107487 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
107488 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
107489 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
107490 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
107491 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
107492 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
107493 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
107494 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
107495 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
107496 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
107497 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
107498 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
107499 +read_flush_43851 read_flush 3 43851 NULL
107500 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
107501 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
107502 +SendString_43928 SendString 3 43928 NULL
107503 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
107504 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
107505 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
107506 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
107507 +nla_reserve_43984 nla_reserve 3 43984 NULL
107508 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
107509 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
107510 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
107511 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
107512 +ulist_add_43994 ulist_add 0 43994 NULL
107513 +emit_flags_44006 emit_flags 4-3 44006 NULL
107514 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
107515 +fru_strlen_44046 fru_strlen 0 44046 NULL
107516 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
107517 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
107518 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
107519 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
107520 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
107521 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
107522 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
107523 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
107524 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
107525 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
107526 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
107527 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
107528 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
107529 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
107530 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
107531 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
107532 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
107533 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
107534 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
107535 +__set_free_44211 __set_free 2 44211 NULL
107536 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
107537 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
107538 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
107539 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
107540 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
107541 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
107542 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
107543 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
107544 +device_create_file_44285 device_create_file 0 44285 NULL
107545 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
107546 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
107547 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
107548 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
107549 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
107550 +rs_init_44327 rs_init 1 44327 NULL
107551 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
107552 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
107553 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
107554 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
107555 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
107556 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
107557 +__is_discarded_44359 __is_discarded 2 44359 NULL
107558 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
107559 +alloc_requests_44372 alloc_requests 0 44372 NULL
107560 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
107561 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
107562 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
107563 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
107564 +strlcpy_44400 strlcpy 3 44400 NULL
107565 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
107566 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
107567 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
107568 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
107569 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
107570 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
107571 +write_file_debug_44476 write_file_debug 3 44476 NULL
107572 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
107573 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
107574 +bio_advance_44496 bio_advance 2 44496 NULL
107575 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
107576 +ac_register_board_44504 ac_register_board 3 44504 NULL
107577 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
107578 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
107579 +spidev_write_44510 spidev_write 3 44510 NULL
107580 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
107581 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
107582 +comm_write_44537 comm_write 3 44537 NULL
107583 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
107584 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
107585 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
107586 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
107587 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
107588 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
107589 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
107590 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
107591 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
107592 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
107593 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
107594 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
107595 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
107596 +mpi_resize_44674 mpi_resize 2 44674 NULL
107597 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
107598 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
107599 +ts_read_44687 ts_read 3 44687 NULL
107600 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
107601 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
107602 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
107603 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
107604 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
107605 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
107606 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
107607 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
107608 +SyS_read_44732 SyS_read 3 44732 NULL
107609 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
107610 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
107611 +set_brk_44749 set_brk 1-2 44749 NULL
107612 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
107613 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
107614 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
107615 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
107616 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
107617 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
107618 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
107619 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
107620 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
107621 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
107622 +sisusb_write_44834 sisusb_write 3 44834 NULL
107623 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
107624 +cubic_root_44848 cubic_root 1 44848 NULL
107625 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
107626 +copydesc_user_44855 copydesc_user 3 44855 NULL
107627 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
107628 +init_rs_44873 init_rs 1 44873 NULL
107629 +skb_availroom_44883 skb_availroom 0 44883 NULL
107630 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
107631 +do_tty_write_44896 do_tty_write 5 44896 NULL
107632 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
107633 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
107634 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
107635 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
107636 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
107637 +send_chmod_45011 send_chmod 0 45011 NULL
107638 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
107639 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
107640 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
107641 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
107642 +dm_kvzalloc_45025 dm_kvzalloc 1 45025 NULL
107643 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
107644 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
107645 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
107646 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
107647 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
107648 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
107649 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
107650 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
107651 +usbdev_read_45114 usbdev_read 3 45114 NULL
107652 +send_to_tty_45141 send_to_tty 3 45141 NULL
107653 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
107654 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
107655 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
107656 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
107657 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
107658 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
107659 +SYSC_write_45160 SYSC_write 3 45160 NULL
107660 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
107661 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
107662 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
107663 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
107664 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
107665 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
107666 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
107667 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
107668 +__dirty_45228 __dirty 2 45228 NULL
107669 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
107670 +event_enable_write_45238 event_enable_write 3 45238 NULL
107671 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
107672 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
107673 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
107674 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
107675 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
107676 +pte_val_45313 pte_val 0 45313 NULL
107677 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
107678 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
107679 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
107680 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
107681 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
107682 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
107683 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
107684 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
107685 +__node_remap_45458 __node_remap 4 45458 NULL
107686 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
107687 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
107688 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
107689 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
107690 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
107691 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
107692 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
107693 +copy_macs_45534 copy_macs 4 45534 NULL
107694 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
107695 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
107696 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
107697 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
107698 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
107699 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
107700 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
107701 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
107702 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
107703 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
107704 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
107705 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
107706 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
107707 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
107708 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
107709 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
107710 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
107711 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
107712 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
107713 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
107714 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
107715 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
107716 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
107717 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
107718 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
107719 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
107720 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
107721 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
107722 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
107723 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
107724 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
107725 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
107726 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
107727 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
107728 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
107729 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
107730 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
107731 +task_state_char_45839 task_state_char 1 45839 NULL
107732 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
107733 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
107734 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
107735 +isdn_write_45863 isdn_write 3 45863 NULL
107736 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
107737 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
107738 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
107739 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
107740 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
107741 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
107742 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
107743 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
107744 +alloc_mr_45935 alloc_mr 1 45935 NULL
107745 +copy_to_45969 copy_to 3 45969 NULL
107746 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
107747 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
107748 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
107749 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
107750 +get_free_entries_46030 get_free_entries 1 46030 NULL
107751 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
107752 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
107753 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
107754 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
107755 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
107756 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
107757 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
107758 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
107759 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
107760 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
107761 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
107762 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
107763 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
107764 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
107765 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
107766 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
107767 +alloc_iova_46160 alloc_iova 2 46160 NULL
107768 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
107769 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
107770 +fq_resize_46195 fq_resize 2 46195 NULL
107771 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
107772 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
107773 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
107774 +dsp_write_46218 dsp_write 2 46218 NULL
107775 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
107776 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
107777 +ReadReg_46277 ReadReg 0 46277 NULL
107778 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
107779 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL nohasharray
107780 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 &__hwahc_dev_set_key_46328
107781 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
107782 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
107783 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
107784 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
107785 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
107786 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
107787 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
107788 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
107789 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
107790 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
107791 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
107792 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
107793 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
107794 +filldir64_46469 filldir64 3 46469 NULL
107795 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
107796 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
107797 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
107798 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
107799 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
107800 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
107801 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
107802 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
107803 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
107804 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
107805 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
107806 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
107807 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
107808 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
107809 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
107810 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
107811 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
107812 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
107813 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
107814 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
107815 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
107816 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
107817 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
107818 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
107819 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
107820 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
107821 +ide_read_status_46719 ide_read_status 0 46719 NULL
107822 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
107823 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
107824 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
107825 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
107826 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
107827 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
107828 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
107829 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
107830 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
107831 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
107832 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
107833 +readreg_46845 readreg 0 46845 NULL
107834 +spi_async_46857 spi_async 0 46857 NULL
107835 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
107836 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
107837 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
107838 +rvmalloc_46873 rvmalloc 1 46873 NULL
107839 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
107840 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
107841 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
107842 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
107843 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
107844 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
107845 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
107846 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
107847 +fb_write_46924 fb_write 3 46924 NULL
107848 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
107849 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
107850 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
107851 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
107852 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
107853 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
107854 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
107855 +strlcat_46985 strlcat 3 46985 NULL
107856 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
107857 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
107858 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
107859 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
107860 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
107861 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
107862 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
107863 +fs_path_len_47060 fs_path_len 0 47060 NULL
107864 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
107865 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
107866 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
107867 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
107868 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
107869 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
107870 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
107871 +mousedev_read_47123 mousedev_read 3 47123 NULL
107872 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
107873 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
107874 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
107875 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
107876 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
107877 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
107878 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
107879 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
107880 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
107881 +options_write_47243 options_write 3 47243 NULL
107882 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
107883 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
107884 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
107885 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
107886 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
107887 +vsnprintf_47291 vsnprintf 0 47291 NULL
107888 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
107889 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
107890 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
107891 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
107892 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
107893 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
107894 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
107895 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
107896 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
107897 +nametbl_list_47391 nametbl_list 2 47391 NULL
107898 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
107899 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
107900 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
107901 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
107902 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
107903 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
107904 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
107905 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
107906 +vzalloc_47421 vzalloc 1 47421 NULL
107907 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
107908 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
107909 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
107910 +environ_read_47451 environ_read 3 47451 NULL
107911 +__load_mapping_47460 __load_mapping 2 47460 NULL
107912 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
107913 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
107914 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
107915 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
107916 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
107917 +core_sys_select_47494 core_sys_select 1 47494 NULL
107918 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
107919 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL nohasharray
107920 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
107921 +unlink_simple_47506 unlink_simple 3 47506 NULL
107922 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
107923 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
107924 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
107925 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
107926 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
107927 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
107928 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
107929 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
107930 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
107931 +read_ldt_47570 read_ldt 2 47570 NULL
107932 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
107933 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
107934 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
107935 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
107936 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
107937 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
107938 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
107939 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
107940 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
107941 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
107942 +get_size_47644 get_size 1-2 47644 NULL
107943 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
107944 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
107945 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
107946 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
107947 +save_microcode_47717 save_microcode 3 47717 NULL
107948 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
107949 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
107950 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
107951 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
107952 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
107953 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
107954 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
107955 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
107956 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
107957 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
107958 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
107959 +lov_packmd_47810 lov_packmd 0 47810 NULL
107960 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
107961 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
107962 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
107963 +vhci_read_47878 vhci_read 3 47878 NULL
107964 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
107965 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
107966 +load_mapping_47904 load_mapping 3 47904 NULL
107967 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
107968 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
107969 +comedi_write_47926 comedi_write 3 47926 NULL
107970 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
107971 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
107972 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
107973 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
107974 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
107975 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
107976 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
107977 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
107978 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
107979 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
107980 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
107981 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
107982 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
107983 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
107984 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
107985 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
107986 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
107987 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
107988 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
107989 +disc_write_48070 disc_write 3 48070 NULL
107990 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
107991 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
107992 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
107993 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
107994 +set_discoverable_48141 set_discoverable 4 48141 NULL
107995 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
107996 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
107997 +_add_to_r4w_48152 _add_to_r4w 4 48152 NULL nohasharray
107998 +bitmap_onto_48152 bitmap_onto 4 48152 &_add_to_r4w_48152
107999 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
108000 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
108001 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
108002 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
108003 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
108004 +init_ipath_48187 init_ipath 1 48187 NULL
108005 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
108006 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
108007 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
108008 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
108009 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
108010 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
108011 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
108012 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
108013 +read_file_recv_48232 read_file_recv 3 48232 NULL
108014 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
108015 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
108016 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
108017 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
108018 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
108019 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
108020 +trace_options_write_48275 trace_options_write 3 48275 NULL
108021 +send_set_info_48288 send_set_info 7 48288 NULL
108022 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
108023 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
108024 +hash_setkey_48310 hash_setkey 3 48310 NULL
108025 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
108026 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
108027 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
108028 +skb_add_data_48363 skb_add_data 3 48363 NULL
108029 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
108030 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
108031 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
108032 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
108033 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
108034 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
108035 +print_filtered_48442 print_filtered 2-0 48442 NULL
108036 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
108037 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
108038 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
108039 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
108040 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
108041 +send_control_msg_48498 send_control_msg 6 48498 NULL
108042 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
108043 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
108044 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
108045 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
108046 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
108047 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
108048 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
108049 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
108050 +llog_data_len_48607 llog_data_len 1 48607 NULL
108051 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
108052 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
108053 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
108054 +mtd_read_48655 mtd_read 0 48655 NULL
108055 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
108056 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
108057 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
108058 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
108059 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
108060 +altera_drscan_48698 altera_drscan 2 48698 NULL
108061 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
108062 +recv_msg_48709 recv_msg 4 48709 NULL
108063 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
108064 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
108065 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
108066 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
108067 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
108068 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
108069 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
108070 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
108071 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
108072 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
108073 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
108074 +azx_get_position_48841 azx_get_position 0 48841 NULL
108075 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
108076 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
108077 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
108078 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
108079 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
108080 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
108081 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
108082 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
108083 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
108084 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
108085 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
108086 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
108087 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
108088 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
108089 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
108090 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
108091 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
108092 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
108093 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
108094 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
108095 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
108096 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
108097 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
108098 +aic_inb_49023 aic_inb 0 49023 NULL
108099 +transient_status_49027 transient_status 4 49027 NULL
108100 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
108101 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
108102 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
108103 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
108104 +ubi_read_49061 ubi_read 0 49061 NULL
108105 +scsi_register_49094 scsi_register 2 49094 NULL
108106 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
108107 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
108108 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
108109 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
108110 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
108111 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
108112 +read_file_49137 read_file 4 49137 NULL
108113 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
108114 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
108115 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
108116 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
108117 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
108118 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
108119 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
108120 +print_queue_49191 print_queue 0 49191 NULL
108121 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
108122 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
108123 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
108124 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
108125 +resp_write_same_49217 resp_write_same 2 49217 NULL
108126 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
108127 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
108128 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
108129 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
108130 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
108131 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
108132 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
108133 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
108134 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
108135 +uio_read_49300 uio_read 3 49300 NULL
108136 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
108137 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
108138 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
108139 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
108140 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
108141 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
108142 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
108143 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
108144 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
108145 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
108146 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
108147 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
108148 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
108149 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
108150 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
108151 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
108152 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
108153 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
108154 +get_lru_size_49441 get_lru_size 0 49441 NULL
108155 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
108156 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
108157 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
108158 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
108159 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
108160 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
108161 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
108162 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
108163 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
108164 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
108165 +smk_write_access_49561 smk_write_access 3 49561 NULL
108166 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
108167 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
108168 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
108169 +readfifo_49583 readfifo 1 49583 NULL
108170 +tap_write_49595 tap_write 3 49595 NULL
108171 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
108172 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
108173 +heap_init_49617 heap_init 2 49617 NULL
108174 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
108175 +port_fops_read_49626 port_fops_read 3 49626 NULL
108176 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
108177 +__swab32p_49657 __swab32p 0 49657 NULL
108178 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
108179 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
108180 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
108181 +__setup_irq_49696 __setup_irq 0 49696 NULL
108182 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
108183 +do_splice_to_49714 do_splice_to 4 49714 NULL
108184 +write_pool_49718 write_pool 3 49718 NULL
108185 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
108186 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
108187 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
108188 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
108189 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
108190 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
108191 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
108192 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
108193 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
108194 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
108195 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
108196 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
108197 +add_uuid_49831 add_uuid 4 49831 NULL
108198 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
108199 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
108200 +twl4030_write_49846 twl4030_write 2 49846 NULL
108201 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
108202 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
108203 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
108204 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
108205 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
108206 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
108207 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
108208 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
108209 +osc_brw_49896 osc_brw 4 49896 NULL
108210 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
108211 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
108212 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
108213 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
108214 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
108215 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
108216 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
108217 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
108218 +__module_alloc_50004 __module_alloc 1 50004 NULL
108219 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
108220 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
108221 +isdn_read_50021 isdn_read 3 50021 NULL
108222 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
108223 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
108224 +ioread8_50049 ioread8 0 50049 NULL
108225 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
108226 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
108227 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
108228 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
108229 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
108230 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
108231 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
108232 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
108233 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
108234 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
108235 +read_file_slot_50111 read_file_slot 3 50111 NULL
108236 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
108237 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
108238 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
108239 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
108240 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
108241 +copy_items_50140 copy_items 6 50140 NULL
108242 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
108243 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
108244 +kmalloc_node_50163 kmalloc_node 1 50163 NULL
108245 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
108246 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
108247 +odev_update_50169 odev_update 2 50169 NULL
108248 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
108249 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
108250 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
108251 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
108252 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
108253 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
108254 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
108255 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
108256 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
108257 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
108258 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
108259 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
108260 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
108261 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
108262 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
108263 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
108264 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
108265 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
108266 +do_launder_page_50329 do_launder_page 0 50329 NULL
108267 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
108268 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
108269 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
108270 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
108271 +tpm_read_50344 tpm_read 3 50344 NULL
108272 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
108273 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
108274 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
108275 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
108276 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
108277 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
108278 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
108279 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
108280 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
108281 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
108282 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
108283 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
108284 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
108285 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
108286 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
108287 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
108288 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
108289 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
108290 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
108291 +force_mapping_50464 force_mapping 2 50464 NULL
108292 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
108293 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
108294 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
108295 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
108296 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
108297 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
108298 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
108299 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
108300 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
108301 +fat_readpages_50582 fat_readpages 4 50582 NULL
108302 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
108303 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
108304 +xillybus_write_50605 xillybus_write 3 50605 NULL
108305 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
108306 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
108307 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
108308 +__ffs_50625 __ffs 0-1 50625 NULL
108309 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
108310 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
108311 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
108312 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
108313 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
108314 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
108315 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
108316 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
108317 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
108318 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
108319 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
108320 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
108321 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
108322 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
108323 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
108324 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
108325 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
108326 +tpm_write_50798 tpm_write 3 50798 NULL
108327 +write_flush_50803 write_flush 3 50803 NULL
108328 +dvb_play_50814 dvb_play 3 50814 NULL
108329 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
108330 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
108331 +SetArea_50835 SetArea 4 50835 NULL nohasharray
108332 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835 nohasharray
108333 +mask_from_50835 mask_from 0-1-2 50835 &create_mem_extents_50835
108334 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
108335 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
108336 +self_check_write_50856 self_check_write 0-5 50856 NULL
108337 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
108338 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
108339 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
108340 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
108341 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
108342 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
108343 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
108344 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
108345 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
108346 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
108347 +show_device_status_50947 show_device_status 0 50947 NULL
108348 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
108349 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
108350 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
108351 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
108352 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
108353 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
108354 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
108355 +timeout_write_50991 timeout_write 3 50991 NULL
108356 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
108357 +proc_write_51003 proc_write 3 51003 NULL
108358 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
108359 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
108360 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
108361 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
108362 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
108363 +dump_midi_51040 dump_midi 3 51040 NULL
108364 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
108365 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
108366 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
108367 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
108368 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
108369 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
108370 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
108371 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
108372 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
108373 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
108374 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
108375 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
108376 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
108377 +set_dirty_51144 set_dirty 3 51144 NULL
108378 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
108379 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
108380 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
108381 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
108382 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
108383 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
108384 +tipc_send_51238 tipc_send 4 51238 NULL
108385 +drm_property_create_51239 drm_property_create 4 51239 NULL
108386 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
108387 +st_read_51251 st_read 3 51251 NULL
108388 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
108389 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
108390 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
108391 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
108392 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
108393 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
108394 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
108395 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
108396 +get_cell_51316 get_cell 2 51316 NULL
108397 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
108398 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
108399 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
108400 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
108401 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
108402 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
108403 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
108404 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
108405 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
108406 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
108407 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
108408 +get_first_ref_51413 get_first_ref 0 51413 NULL
108409 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
108410 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
108411 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
108412 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
108413 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
108414 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
108415 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
108416 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
108417 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
108418 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
108419 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
108420 +key_search_51533 key_search 0 51533 NULL
108421 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
108422 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
108423 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
108424 +get_cur_path_51589 get_cur_path 0 51589 NULL nohasharray
108425 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 &get_cur_path_51589
108426 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
108427 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
108428 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
108429 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
108430 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
108431 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
108432 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
108433 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
108434 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
108435 +sel_write_access_51704 sel_write_access 3 51704 NULL
108436 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
108437 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
108438 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
108439 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
108440 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
108441 +cm4040_read_51732 cm4040_read 3 51732 NULL
108442 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
108443 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
108444 +if_write_51756 if_write 3 51756 NULL
108445 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
108446 +__fswab32_51781 __fswab32 0 51781 NULL
108447 +to_ratio_51809 to_ratio 1-2 51809 NULL
108448 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
108449 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
108450 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
108451 +ioread32_51847 ioread32 0 51847 NULL nohasharray
108452 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
108453 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
108454 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
108455 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
108456 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
108457 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
108458 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
108459 +user_read_51881 user_read 3 51881 NULL
108460 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
108461 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 NULL nohasharray
108462 +virt_to_phys_51896 virt_to_phys 0 51896 &SyS_mq_timedsend_51896
108463 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
108464 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
108465 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
108466 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
108467 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
108468 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
108469 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
108470 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
108471 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
108472 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
108473 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
108474 +get_zone_51981 get_zone 0-1 51981 NULL
108475 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
108476 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
108477 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
108478 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
108479 +rdmalt_52022 rdmalt 0 52022 NULL
108480 +override_release_52032 override_release 2 52032 NULL
108481 +end_port_52042 end_port 0 52042 NULL
108482 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
108483 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
108484 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
108485 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
108486 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
108487 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
108488 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
108489 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
108490 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
108491 +retry_count_read_52129 retry_count_read 3 52129 NULL
108492 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
108493 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
108494 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
108495 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
108496 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
108497 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
108498 +htable_size_52148 htable_size 0-1 52148 NULL
108499 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
108500 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
108501 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
108502 +print_prefix_52176 print_prefix 0 52176 NULL
108503 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
108504 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
108505 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
108506 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
108507 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
108508 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
108509 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
108510 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
108511 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
108512 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
108513 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
108514 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
108515 +atomic64_read_52300 atomic64_read 0 52300 NULL
108516 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
108517 +read_file_reset_52310 read_file_reset 3 52310 NULL
108518 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
108519 +hwflags_read_52318 hwflags_read 3 52318 NULL
108520 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
108521 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
108522 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
108523 +hur_len_52339 hur_len 0 52339 NULL
108524 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
108525 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
108526 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
108527 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
108528 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
108529 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
108530 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
108531 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
108532 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
108533 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
108534 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
108535 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
108536 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
108537 +delay_status_52431 delay_status 5 52431 NULL
108538 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
108539 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
108540 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
108541 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
108542 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
108543 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
108544 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
108545 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
108546 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
108547 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
108548 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
108549 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
108550 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
108551 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
108552 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
108553 +from_oblock_52546 from_oblock 0-1 52546 NULL
108554 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
108555 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
108556 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
108557 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
108558 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
108559 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
108560 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
108561 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
108562 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
108563 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
108564 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
108565 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
108566 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
108567 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
108568 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
108569 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
108570 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
108571 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
108572 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
108573 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
108574 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
108575 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
108576 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
108577 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
108578 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
108579 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
108580 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
108581 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
108582 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
108583 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
108584 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
108585 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
108586 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
108587 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
108588 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
108589 +twlreg_write_52880 twlreg_write 3 52880 NULL
108590 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
108591 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
108592 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
108593 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
108594 +create_vtbl_52909 create_vtbl 0 52909 NULL
108595 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
108596 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
108597 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
108598 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
108599 +send_packet_52960 send_packet 4 52960 NULL
108600 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
108601 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
108602 +num_node_state_52989 num_node_state 0 52989 NULL
108603 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
108604 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
108605 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
108606 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
108607 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
108608 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
108609 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
108610 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
108611 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
108612 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
108613 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
108614 +page_to_nid_53085 page_to_nid 0 53085 NULL
108615 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
108616 +insert_new_root_53097 insert_new_root 0 53097 NULL
108617 +verity_status_53120 verity_status 5 53120 NULL
108618 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
108619 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
108620 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
108621 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
108622 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
108623 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
108624 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
108625 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
108626 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
108627 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
108628 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
108629 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
108630 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
108631 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
108632 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
108633 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
108634 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
108635 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
108636 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
108637 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
108638 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
108639 +vm_mmap_53339 vm_mmap 0 53339 NULL
108640 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
108641 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
108642 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
108643 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
108644 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
108645 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
108646 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
108647 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
108648 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
108649 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
108650 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
108651 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
108652 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
108653 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
108654 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
108655 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
108656 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
108657 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
108658 +check_acl_53512 check_acl 0 53512 NULL
108659 +send_utimes_53516 send_utimes 0 53516 NULL
108660 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
108661 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
108662 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
108663 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
108664 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
108665 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
108666 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
108667 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
108668 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
108669 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
108670 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
108671 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
108672 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
108673 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 &bdev_logical_block_size_53690
108674 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
108675 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
108676 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
108677 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
108678 +wdm_write_53735 wdm_write 3 53735 NULL
108679 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
108680 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
108681 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
108682 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
108683 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
108684 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
108685 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
108686 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
108687 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
108688 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
108689 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
108690 +setup_data_read_53822 setup_data_read 3 53822 NULL
108691 +pms_read_53873 pms_read 3 53873 NULL
108692 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
108693 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
108694 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
108695 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
108696 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
108697 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
108698 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
108699 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
108700 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
108701 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
108702 +send_clone_54011 send_clone 0 54011 NULL
108703 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
108704 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
108705 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
108706 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
108707 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
108708 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
108709 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
108710 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
108711 +_malloc_54077 _malloc 1 54077 NULL
108712 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
108713 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
108714 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
108715 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
108716 +strn_len_54122 strn_len 0 54122 NULL
108717 +isku_receive_54130 isku_receive 4 54130 NULL
108718 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
108719 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
108720 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
108721 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
108722 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
108723 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
108724 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
108725 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
108726 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
108727 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
108728 +reada_add_block_54247 reada_add_block 2 54247 NULL
108729 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
108730 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
108731 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
108732 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
108733 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
108734 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
108735 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
108736 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
108737 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
108738 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
108739 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
108740 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
108741 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
108742 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
108743 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
108744 +sprintf_54306 sprintf 0 54306 NULL
108745 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
108746 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
108747 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
108748 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
108749 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
108750 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
108751 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
108752 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
108753 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
108754 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
108755 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
108756 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
108757 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
108758 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
108759 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
108760 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
108761 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
108762 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4 54485 NULL
108763 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
108764 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
108765 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
108766 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
108767 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
108768 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
108769 +viacam_read_54526 viacam_read 3 54526 NULL
108770 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
108771 +setsockopt_54539 setsockopt 5 54539 NULL
108772 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
108773 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
108774 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 NULL
108775 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
108776 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
108777 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
108778 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
108779 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
108780 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
108781 +port_fops_write_54627 port_fops_write 3 54627 NULL
108782 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
108783 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
108784 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
108785 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
108786 +bus_add_device_54665 bus_add_device 0 54665 NULL
108787 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
108788 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
108789 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
108790 +evm_read_key_54674 evm_read_key 3 54674 NULL
108791 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
108792 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
108793 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
108794 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
108795 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
108796 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
108797 +kzalloc_54740 kzalloc 1 54740 NULL
108798 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
108799 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
108800 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
108801 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
108802 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
108803 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
108804 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
108805 +domain_init_54797 domain_init 2 54797 NULL
108806 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
108807 +get_dev_size_54807 get_dev_size 0 54807 NULL
108808 +nfsd_write_54809 nfsd_write 6 54809 NULL
108809 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
108810 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
108811 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
108812 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
108813 +write_rio_54837 write_rio 3 54837 NULL
108814 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
108815 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
108816 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
108817 +printer_read_54851 printer_read 3 54851 NULL
108818 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
108819 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
108820 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
108821 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
108822 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
108823 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
108824 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
108825 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
108826 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
108827 +add_port_54941 add_port 2 54941 NULL
108828 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
108829 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
108830 +c4_add_card_54968 c4_add_card 3 54968 NULL
108831 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
108832 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
108833 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
108834 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
108835 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
108836 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
108837 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
108838 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
108839 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
108840 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
108841 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
108842 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
108843 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
108844 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
108845 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
108846 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
108847 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
108848 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
108849 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
108850 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
108851 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
108852 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
108853 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
108854 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
108855 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
108856 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
108857 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
108858 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
108859 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
108860 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
108861 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
108862 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
108863 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
108864 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
108865 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
108866 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
108867 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
108868 +ptrace_request_55288 ptrace_request 3 55288 NULL
108869 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
108870 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
108871 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
108872 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
108873 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 NULL
108874 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
108875 +do_shmat_55336 do_shmat 5 55336 NULL
108876 +vme_user_read_55338 vme_user_read 3 55338 NULL
108877 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
108878 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
108879 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
108880 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
108881 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
108882 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
108883 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
108884 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
108885 +SyS_read_55449 SyS_read 3 55449 NULL
108886 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
108887 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
108888 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
108889 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
108890 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
108891 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
108892 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
108893 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
108894 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
108895 +ea_get_55522 ea_get 3-0 55522 NULL
108896 +buffer_size_55534 buffer_size 0 55534 NULL
108897 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
108898 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
108899 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
108900 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
108901 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
108902 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
108903 +add_partition_55588 add_partition 2 55588 NULL
108904 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
108905 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
108906 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
108907 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
108908 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
108909 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
108910 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
108911 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
108912 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
108913 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
108914 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
108915 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
108916 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
108917 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
108918 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
108919 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
108920 +get_info_55681 get_info 3 55681 NULL
108921 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
108922 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
108923 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
108924 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
108925 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
108926 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
108927 +set_local_name_55757 set_local_name 4 55757 NULL
108928 +strlen_55778 strlen 0 55778 NULL nohasharray
108929 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
108930 +set_spte_55783 set_spte 4-5 55783 NULL
108931 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
108932 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
108933 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
108934 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
108935 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
108936 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
108937 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
108938 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
108939 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
108940 +hsc_write_55875 hsc_write 3 55875 NULL
108941 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
108942 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
108943 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
108944 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
108945 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
108946 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
108947 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
108948 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
108949 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
108950 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
108951 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
108952 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
108953 +__set_discard_56081 __set_discard 2 56081 NULL
108954 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
108955 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
108956 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
108957 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
108958 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
108959 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
108960 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
108961 +create_irq_nr_56180 create_irq_nr 1-0 56180 NULL
108962 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
108963 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
108964 +update_space_info_56213 update_space_info 0 56213 NULL
108965 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
108966 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
108967 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
108968 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
108969 +fd_copyin_56247 fd_copyin 3 56247 NULL
108970 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
108971 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
108972 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
108973 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
108974 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
108975 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
108976 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
108977 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
108978 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
108979 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
108980 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
108981 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
108982 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
108983 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
108984 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
108985 +dev_read_56369 dev_read 3 56369 NULL
108986 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
108987 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
108988 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
108989 +write_gssp_56404 write_gssp 3 56404 NULL
108990 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
108991 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
108992 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
108993 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
108994 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
108995 +fl_create_56435 fl_create 5 56435 NULL
108996 +gnttab_map_56439 gnttab_map 2 56439 NULL
108997 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
108998 +set_connectable_56458 set_connectable 4 56458 NULL
108999 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
109000 +putused_user_56467 putused_user 3 56467 NULL
109001 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
109002 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
109003 +global_rt_period_56476 global_rt_period 0 56476 NULL
109004 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
109005 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
109006 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
109007 +init_map_ip_56508 init_map_ip 5 56508 NULL
109008 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
109009 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
109010 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
109011 +ip_options_get_56538 ip_options_get 4 56538 NULL
109012 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
109013 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
109014 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
109015 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
109016 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
109017 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
109018 +event_filter_write_56609 event_filter_write 3 56609 NULL
109019 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
109020 +gather_array_56641 gather_array 3 56641 NULL
109021 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
109022 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
109023 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
109024 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
109025 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
109026 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
109027 +build_map_info_56696 build_map_info 2 56696 NULL
109028 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
109029 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
109030 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
109031 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
109032 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
109033 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
109034 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
109035 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
109036 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
109037 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
109038 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
109039 +do_syslog_56807 do_syslog 3 56807 NULL
109040 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
109041 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
109042 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
109043 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
109044 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
109045 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
109046 +wb_lookup_56858 wb_lookup 2 56858 NULL
109047 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
109048 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
109049 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
109050 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
109051 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
109052 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
109053 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
109054 +strcspn_56913 strcspn 0 56913 NULL
109055 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
109056 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 NULL nohasharray
109057 +journal_init_revoke_56933 journal_init_revoke 2 56933 &CopyBufferToControlPacket_56933
109058 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
109059 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
109060 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
109061 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
109062 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
109063 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
109064 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
109065 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
109066 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
109067 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
109068 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
109069 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
109070 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
109071 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
109072 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
109073 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
109074 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
109075 +altera_get_note_57099 altera_get_note 6 57099 NULL
109076 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
109077 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
109078 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
109079 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
109080 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
109081 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
109082 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
109083 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
109084 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
109085 +changed_inode_57156 changed_inode 0 57156 NULL
109086 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
109087 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
109088 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
109089 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
109090 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
109091 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
109092 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
109093 +flush_space_57241 flush_space 3-0 57241 NULL
109094 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
109095 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
109096 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
109097 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
109098 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
109099 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
109100 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
109101 +fw_file_size_57307 fw_file_size 0 57307 NULL
109102 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
109103 +write_file_regval_57313 write_file_regval 3 57313 NULL
109104 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
109105 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
109106 +usblp_read_57342 usblp_read 3 57342 NULL
109107 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
109108 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
109109 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
109110 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
109111 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
109112 +read_file_blob_57406 read_file_blob 3 57406 NULL
109113 +enclosure_register_57412 enclosure_register 3 57412 NULL
109114 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
109115 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
109116 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
109117 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
109118 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
109119 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
109120 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
109121 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
109122 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
109123 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
109124 +skb_headlen_57501 skb_headlen 0 57501 NULL
109125 +copy_in_user_57502 copy_in_user 3 57502 NULL
109126 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
109127 +init_tag_map_57515 init_tag_map 3 57515 NULL
109128 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
109129 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
109130 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
109131 +cmm_read_57520 cmm_read 3 57520 NULL
109132 +inode_permission_57531 inode_permission 0 57531 NULL
109133 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
109134 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
109135 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
109136 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
109137 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
109138 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
109139 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
109140 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
109141 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
109142 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
109143 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
109144 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
109145 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
109146 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
109147 +mem_read_57631 mem_read 3 57631 NULL
109148 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
109149 +r3964_write_57662 r3964_write 4 57662 NULL
109150 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
109151 +__lgwrite_57669 __lgwrite 4 57669 NULL
109152 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
109153 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
109154 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
109155 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
109156 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
109157 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
109158 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
109159 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
109160 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
109161 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
109162 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
109163 +ld2_57794 ld2 0 57794 NULL
109164 +ivtv_read_57796 ivtv_read 3 57796 NULL
109165 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
109166 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
109167 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
109168 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
109169 +flash_read_57843 flash_read 3 57843 NULL
109170 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
109171 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
109172 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
109173 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL nohasharray
109174 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 &iio_read_first_n_kfifo_57910
109175 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
109176 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
109177 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
109178 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
109179 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
109180 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
109181 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
109182 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
109183 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
109184 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
109185 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
109186 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
109187 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
109188 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
109189 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
109190 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
109191 +mce_async_out_58056 mce_async_out 3 58056 NULL
109192 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
109193 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
109194 +cm4040_write_58079 cm4040_write 3 58079 NULL
109195 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
109196 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
109197 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
109198 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
109199 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
109200 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
109201 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
109202 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
109203 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
109204 +read_file_debug_58256 read_file_debug 3 58256 NULL
109205 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
109206 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
109207 +profile_load_58267 profile_load 3 58267 NULL
109208 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
109209 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
109210 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
109211 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
109212 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
109213 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
109214 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
109215 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3 58331 NULL
109216 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
109217 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
109218 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
109219 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
109220 +save_hint_58359 save_hint 2 58359 NULL
109221 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
109222 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
109223 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
109224 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
109225 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
109226 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
109227 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
109228 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
109229 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
109230 +capabilities_read_58457 capabilities_read 3 58457 NULL
109231 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
109232 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
109233 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
109234 +nv_rd08_58472 nv_rd08 0 58472 NULL
109235 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
109236 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
109237 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
109238 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
109239 +__clear_discard_58546 __clear_discard 2 58546 NULL
109240 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
109241 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
109242 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
109243 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
109244 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
109245 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
109246 +xip_file_read_58592 xip_file_read 3 58592 NULL
109247 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
109248 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
109249 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
109250 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
109251 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
109252 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
109253 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
109254 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
109255 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
109256 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
109257 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
109258 +find_zero_58685 find_zero 0-1 58685 NULL
109259 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
109260 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
109261 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
109262 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
109263 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
109264 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
109265 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
109266 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
109267 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
109268 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
109269 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
109270 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
109271 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
109272 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
109273 +write_file_58812 write_file 4 58812 NULL
109274 +ep_read_58813 ep_read 3 58813 NULL
109275 +command_write_58841 command_write 3 58841 NULL
109276 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
109277 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
109278 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
109279 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
109280 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
109281 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
109282 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
109283 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
109284 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
109285 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
109286 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
109287 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
109288 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
109289 +ep_write_59008 ep_write 3 59008 NULL
109290 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
109291 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
109292 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
109293 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
109294 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
109295 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
109296 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
109297 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
109298 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
109299 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
109300 +init_status_page_59124 init_status_page 0 59124 NULL
109301 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
109302 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
109303 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
109304 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
109305 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
109306 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
109307 +ksize_59176 ksize 0 59176 NULL
109308 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
109309 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
109310 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
109311 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
109312 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
109313 +dt3155_read_59226 dt3155_read 3 59226 NULL
109314 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
109315 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
109316 +nla_len_59258 nla_len 0 59258 NULL
109317 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
109318 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
109319 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
109320 +fd_copyout_59323 fd_copyout 3 59323 NULL
109321 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
109322 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
109323 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
109324 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
109325 +__map_request_59350 __map_request 0 59350 NULL
109326 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
109327 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
109328 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
109329 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
109330 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
109331 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
109332 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
109333 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
109334 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
109335 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
109336 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
109337 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
109338 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
109339 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
109340 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
109341 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
109342 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
109343 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
109344 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
109345 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
109346 +tunables_write_59563 tunables_write 3 59563 NULL
109347 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
109348 +write_pbl_59583 write_pbl 4 59583 NULL
109349 +memdup_user_59590 memdup_user 2 59590 NULL
109350 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
109351 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
109352 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
109353 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
109354 +mtrr_write_59622 mtrr_write 3 59622 NULL
109355 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
109356 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
109357 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
109358 +hidraw_read_59650 hidraw_read 3 59650 NULL
109359 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
109360 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
109361 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
109362 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
109363 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
109364 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
109365 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
109366 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
109367 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
109368 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
109369 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
109370 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
109371 +strnlen_59746 strnlen 0 59746 NULL
109372 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
109373 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
109374 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
109375 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
109376 +venus_remove_59781 venus_remove 4 59781 NULL
109377 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
109378 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
109379 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
109380 +ipw_write_59807 ipw_write 3 59807 NULL
109381 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
109382 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
109383 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
109384 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
109385 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
109386 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
109387 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
109388 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
109389 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
109390 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
109391 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
109392 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
109393 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
109394 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
109395 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
109396 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
109397 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
109398 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
109399 +lookup_node_59953 lookup_node 2 59953 NULL
109400 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
109401 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
109402 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
109403 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
109404 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
109405 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
109406 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
109407 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
109408 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
109409 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
109410 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
109411 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
109412 +vcs_size_60050 vcs_size 0 60050 NULL nohasharray
109413 +pin_2_irq_60050 pin_2_irq 0-3 60050 &vcs_size_60050
109414 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
109415 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
109416 +compat_writev_60063 compat_writev 3 60063 NULL
109417 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
109418 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
109419 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
109420 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
109421 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
109422 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
109423 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
109424 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
109425 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
109426 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
109427 +init_state_60165 init_state 2 60165 NULL
109428 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
109429 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
109430 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
109431 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
109432 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
109433 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
109434 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
109435 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
109436 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
109437 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
109438 +printer_write_60276 printer_write 3 60276 NULL
109439 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
109440 +getDataLength_60301 getDataLength 0 60301 NULL
109441 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
109442 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
109443 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
109444 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
109445 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
109446 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
109447 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
109448 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
109449 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
109450 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
109451 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
109452 +driver_names_read_60399 driver_names_read 3 60399 NULL
109453 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
109454 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
109455 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
109456 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
109457 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
109458 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
109459 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
109460 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
109461 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
109462 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
109463 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
109464 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
109465 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
109466 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
109467 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
109468 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
109469 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
109470 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
109471 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
109472 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
109473 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
109474 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
109475 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
109476 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
109477 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
109478 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
109479 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
109480 +init_data_container_60709 init_data_container 1 60709 NULL
109481 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
109482 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
109483 +raid_status_60755 raid_status 5 60755 NULL
109484 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
109485 +opticon_write_60775 opticon_write 4 60775 NULL
109486 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
109487 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
109488 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
109489 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
109490 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
109491 +generic_writepages_60871 generic_writepages 0 60871 NULL
109492 +tipc_createport_60875 tipc_createport 4 60875 NULL
109493 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
109494 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
109495 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
109496 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
109497 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
109498 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
109499 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
109500 +pti_char_write_60960 pti_char_write 3 60960 NULL
109501 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
109502 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
109503 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
109504 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
109505 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
109506 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
109507 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
109508 +symtab_init_61050 symtab_init 2 61050 NULL
109509 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
109510 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
109511 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
109512 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
109513 +journal_stop_61080 journal_stop 0 61080 NULL
109514 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
109515 +get_derived_key_61100 get_derived_key 4 61100 NULL
109516 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
109517 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
109518 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
109519 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
109520 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
109521 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
109522 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
109523 +__vmalloc_61168 __vmalloc 1 61168 NULL
109524 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
109525 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
109526 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
109527 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
109528 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
109529 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
109530 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
109531 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
109532 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
109533 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
109534 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
109535 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
109536 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
109537 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
109538 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
109539 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
109540 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
109541 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
109542 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
109543 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
109544 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
109545 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
109546 +__fls_61340 __fls 0 61340 NULL nohasharray
109547 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
109548 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
109549 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
109550 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
109551 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
109552 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
109553 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
109554 +get_inode_info_61387 get_inode_info 0 61387 NULL
109555 +system_enable_write_61396 system_enable_write 3 61396 NULL
109556 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
109557 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
109558 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
109559 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
109560 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
109561 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
109562 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
109563 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
109564 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
109565 +erst_errno_61526 erst_errno 0 61526 NULL
109566 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
109567 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
109568 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
109569 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
109570 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
109571 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
109572 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
109573 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
109574 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
109575 +seq_open_private_61589 seq_open_private 3 61589 NULL
109576 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
109577 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
109578 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
109579 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
109580 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
109581 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
109582 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
109583 +resize_stripes_61650 resize_stripes 2 61650 NULL
109584 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
109585 +insert_one_name_61668 insert_one_name 7 61668 NULL
109586 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
109587 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
109588 +lock_loop_61681 lock_loop 1 61681 NULL
109589 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
109590 +filter_read_61692 filter_read 3 61692 NULL
109591 +prog_page_61711 prog_page 2 61711 NULL
109592 +iov_length_61716 iov_length 0 61716 NULL
109593 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
109594 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
109595 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
109596 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
109597 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
109598 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
109599 +num_counter_active_61789 num_counter_active 0 61789 NULL
109600 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
109601 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
109602 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
109603 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
109604 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
109605 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
109606 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
109607 +get_fw_name_61874 get_fw_name 3 61874 NULL
109608 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
109609 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
109610 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
109611 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
109612 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
109613 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
109614 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
109615 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
109616 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
109617 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
109618 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
109619 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
109620 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
109621 +fix_read_error_61965 fix_read_error 4 61965 NULL
109622 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
109623 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
109624 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
109625 +cow_file_range_61979 cow_file_range 3 61979 NULL
109626 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
109627 +dequeue_event_62000 dequeue_event 3 62000 NULL
109628 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
109629 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
109630 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
109631 +SYSC_select_62024 SYSC_select 1 62024 NULL
109632 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
109633 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
109634 +do_pselect_62061 do_pselect 1 62061 NULL
109635 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
109636 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
109637 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
109638 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
109639 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
109640 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
109641 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
109642 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
109643 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
109644 +ql_status_62135 ql_status 5 62135 NULL nohasharray
109645 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
109646 +video_usercopy_62151 video_usercopy 2 62151 NULL
109647 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
109648 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
109649 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
109650 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
109651 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
109652 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
109653 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
109654 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
109655 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
109656 +allocate_partition_62245 allocate_partition 4 62245 NULL
109657 +security_file_permission_62278 security_file_permission 0 62278 NULL
109658 +get_random_int_62279 get_random_int 0 62279 NULL
109659 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
109660 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
109661 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
109662 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
109663 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
109664 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
109665 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
109666 +subseq_list_62332 subseq_list 3-0 62332 NULL
109667 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
109668 +flash_write_62354 flash_write 3 62354 NULL
109669 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
109670 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
109671 +altera_irscan_62396 altera_irscan 2 62396 NULL
109672 +set_ssp_62411 set_ssp 4 62411 NULL
109673 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
109674 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
109675 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
109676 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
109677 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
109678 +debugfs_read_62535 debugfs_read 3 62535 NULL
109679 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
109680 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
109681 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
109682 +get_subdir_62581 get_subdir 3 62581 NULL
109683 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
109684 +get_desc_base_62617 get_desc_base 0 62617 NULL
109685 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
109686 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
109687 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
109688 +write_62671 write 3 62671 NULL
109689 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
109690 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
109691 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
109692 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
109693 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
109694 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
109695 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
109696 +rdm_62719 rdm 0 62719 NULL
109697 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
109698 +key_replays_read_62746 key_replays_read 3 62746 NULL
109699 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
109700 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
109701 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
109702 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
109703 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
109704 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
109705 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
109706 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
109707 +is_first_ref_62805 is_first_ref 0 62805 NULL
109708 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
109709 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
109710 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
109711 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
109712 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
109713 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
109714 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
109715 +set_swbp_62853 set_swbp 3 62853 NULL
109716 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
109717 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
109718 +aoechr_write_62883 aoechr_write 3 62883 NULL
109719 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
109720 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
109721 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
109722 +getdqbuf_62908 getdqbuf 1 62908 NULL
109723 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
109724 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
109725 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
109726 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
109727 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
109728 +send_write_62969 send_write 0-3 62969 NULL
109729 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
109730 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
109731 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
109732 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
109733 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
109734 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
109735 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
109736 +unlink1_63059 unlink1 3 63059 NULL
109737 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
109738 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
109739 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
109740 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
109741 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
109742 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
109743 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
109744 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
109745 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
109746 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
109747 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
109748 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
109749 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
109750 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
109751 +vme_master_read_63221 vme_master_read 0 63221 NULL
109752 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
109753 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
109754 +ptp_read_63251 ptp_read 4 63251 NULL
109755 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
109756 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
109757 +raid5_resize_63306 raid5_resize 2 63306 NULL
109758 +proc_info_read_63344 proc_info_read 3 63344 NULL
109759 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
109760 +idmouse_read_63374 idmouse_read 3 63374 NULL
109761 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
109762 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
109763 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
109764 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
109765 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
109766 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
109767 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
109768 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
109769 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
109770 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
109771 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
109772 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
109773 +do_work_63483 do_work 0 63483 NULL
109774 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
109775 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
109776 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
109777 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
109778 +save_hint_63497 save_hint 2 63497 NULL
109779 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
109780 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
109781 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
109782 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
109783 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
109784 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
109785 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
109786 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
109787 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
109788 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
109789 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
109790 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
109791 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
109792 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
109793 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
109794 +write_debug_level_63613 write_debug_level 3 63613 NULL
109795 +module_alloc_63630 module_alloc 1 63630 NULL
109796 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
109797 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
109798 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
109799 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
109800 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
109801 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
109802 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
109803 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
109804 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
109805 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
109806 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
109807 +bin_search_63697 bin_search 0 63697 NULL
109808 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
109809 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
109810 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
109811 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
109812 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
109813 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
109814 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
109815 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
109816 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
109817 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
109818 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
109819 +prepare_copy_63826 prepare_copy 2 63826 NULL
109820 +sel_write_load_63830 sel_write_load 3 63830 NULL
109821 +ll_readlink_63836 ll_readlink 3 63836 NULL
109822 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
109823 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
109824 +divas_write_63901 divas_write 3 63901 NULL
109825 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
109826 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
109827 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
109828 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
109829 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
109830 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
109831 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
109832 +__team_options_register_63941 __team_options_register 3 63941 NULL
109833 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
109834 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
109835 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
109836 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
109837 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
109838 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
109839 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
109840 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
109841 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
109842 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
109843 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
109844 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
109845 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
109846 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
109847 +__sock_create_64069 __sock_create 0 64069 NULL
109848 +get_u8_64076 get_u8 0 64076 NULL
109849 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
109850 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
109851 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
109852 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
109853 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
109854 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
109855 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
109856 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
109857 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
109858 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
109859 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
109860 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
109861 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
109862 +init_bch_64130 init_bch 2-1 64130 NULL
109863 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
109864 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
109865 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
109866 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
109867 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
109868 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
109869 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
109870 +read_pulse_64227 read_pulse 0-3 64227 NULL
109871 +ea_len_64229 ea_len 0 64229 NULL
109872 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
109873 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
109874 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
109875 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
109876 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
109877 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
109878 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
109879 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
109880 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
109881 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
109882 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
109883 +ffz_64324 ffz 0-1 64324 NULL
109884 +map_region_64328 map_region 1 64328 NULL
109885 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
109886 +ts_write_64336 ts_write 3 64336 NULL
109887 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
109888 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
109889 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
109890 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
109891 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
109892 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
109893 +reg_create_64372 reg_create 5 64372 NULL
109894 +ilo_write_64378 ilo_write 3 64378 NULL
109895 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
109896 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
109897 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
109898 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
109899 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
109900 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
109901 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
109902 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
109903 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
109904 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
109905 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
109906 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
109907 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
109908 +single_open_size_64483 single_open_size 4 64483 NULL
109909 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
109910 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
109911 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
109912 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
109913 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
109914 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
109915 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
109916 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
109917 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
109918 +SyS_bind_64544 SyS_bind 3 64544 NULL
109919 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
109920 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
109921 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
109922 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
109923 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
109924 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
109925 +do_erase_64574 do_erase 4 64574 NULL
109926 +fanotify_write_64623 fanotify_write 3 64623 NULL
109927 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
109928 +to_dblock_64655 to_dblock 0-1 64655 NULL
109929 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
109930 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
109931 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
109932 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
109933 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
109934 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
109935 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
109936 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
109937 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
109938 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
109939 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
109940 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
109941 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
109942 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
109943 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
109944 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
109945 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
109946 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
109947 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
109948 +message_for_md_64777 message_for_md 5 64777 NULL
109949 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
109950 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
109951 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
109952 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
109953 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
109954 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
109955 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
109956 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
109957 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
109958 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
109959 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
109960 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
109961 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
109962 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
109963 +mk_pid_64894 mk_pid 0-3 64894 NULL
109964 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
109965 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
109966 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
109967 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
109968 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
109969 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
109970 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
109971 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
109972 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
109973 +insert_dent_65034 insert_dent 7 65034 NULL
109974 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
109975 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
109976 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
109977 +make_idx_node_65068 make_idx_node 0 65068 NULL
109978 +count_run_65072 count_run 0-2-4-5 65072 NULL
109979 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
109980 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
109981 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
109982 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
109983 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
109984 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
109985 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
109986 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
109987 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
109988 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
109989 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
109990 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
109991 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
109992 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
109993 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
109994 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
109995 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
109996 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
109997 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
109998 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
109999 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
110000 +get_var_len_65304 get_var_len 0 65304 NULL
110001 +unpack_array_65318 unpack_array 0 65318 NULL
110002 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
110003 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
110004 +init_list_set_65351 init_list_set 3-2 65351 NULL
110005 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
110006 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
110007 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
110008 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
110009 +SyS_writev_65372 SyS_writev 3 65372 NULL
110010 +mi_set_context_65395 mi_set_context 0 65395 NULL
110011 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
110012 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
110013 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
110014 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
110015 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
110016 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
110017 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
110018 +device_add_groups_65423 device_add_groups 0 65423 NULL
110019 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
110020 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
110021 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
110022 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
110023 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
110024 +clear_user_65470 clear_user 2 65470 NULL
110025 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
110026 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
110027 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
110028 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
110029 new file mode 100644
110030 index 0000000..87dd5e2
110031 --- /dev/null
110032 +++ b/tools/gcc/size_overflow_plugin.c
110033 @@ -0,0 +1,3840 @@
110034 +/*
110035 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
110036 + * Licensed under the GPL v2, or (at your option) v3
110037 + *
110038 + * Homepage:
110039 + * http://www.grsecurity.net/~ephox/overflow_plugin/
110040 + *
110041 + * Documentation:
110042 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
110043 + *
110044 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
110045 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
110046 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
110047 + *
110048 + * Usage:
110049 + * $ 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
110050 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
110051 + */
110052 +
110053 +#include "gcc-plugin.h"
110054 +#include "config.h"
110055 +#include "system.h"
110056 +#include "coretypes.h"
110057 +#include "tree.h"
110058 +#include "tree-pass.h"
110059 +#include "intl.h"
110060 +#include "plugin-version.h"
110061 +#include "tm.h"
110062 +#include "toplev.h"
110063 +#include "function.h"
110064 +#include "tree-flow.h"
110065 +#include "plugin.h"
110066 +#include "gimple.h"
110067 +#include "diagnostic.h"
110068 +#include "cfgloop.h"
110069 +
110070 +#if BUILDING_GCC_VERSION >= 4008
110071 +#define TODO_dump_func 0
110072 +#define TODO_dump_cgraph 0
110073 +#endif
110074 +
110075 +#define __unused __attribute__((__unused__))
110076 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
110077 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110078 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
110079 +#define BEFORE_STMT true
110080 +#define AFTER_STMT false
110081 +#define CREATE_NEW_VAR NULL_TREE
110082 +#define CODES_LIMIT 32
110083 +#define MAX_PARAM 31
110084 +#define VEC_LEN 128
110085 +#define MY_STMT GF_PLF_1
110086 +#define NO_CAST_CHECK GF_PLF_2
110087 +#define RET_CHECK NULL_TREE
110088 +#define CANNOT_FIND_ARG 32
110089 +#define WRONG_NODE 32
110090 +#define NOT_INTENTIONAL_ASM NULL
110091 +#define MIN_CHECK true
110092 +#define MAX_CHECK false
110093 +
110094 +#if BUILDING_GCC_VERSION == 4005
110095 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
110096 +#endif
110097 +
110098 +struct size_overflow_hash {
110099 + const struct size_overflow_hash * const next;
110100 + const char * const name;
110101 + const unsigned int param;
110102 +};
110103 +
110104 +#include "size_overflow_hash.h"
110105 +
110106 +enum mark {
110107 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
110108 +};
110109 +
110110 +static unsigned int call_count;
110111 +
110112 +struct visited {
110113 + struct visited *next;
110114 + const_tree fndecl;
110115 + unsigned int num;
110116 + const_gimple first_stmt;
110117 +};
110118 +
110119 +struct next_cgraph_node {
110120 + struct next_cgraph_node *next;
110121 + struct cgraph_node *current_function;
110122 + tree callee_fndecl;
110123 + unsigned int num;
110124 +};
110125 +
110126 +struct interesting_node {
110127 + struct interesting_node *next;
110128 + gimple first_stmt;
110129 + const_tree fndecl;
110130 + tree node;
110131 +#if BUILDING_GCC_VERSION <= 4007
110132 + VEC(tree, gc) *last_nodes;
110133 +#else
110134 + vec<tree, va_gc> *last_nodes;
110135 +#endif
110136 + unsigned int num;
110137 + enum mark intentional_attr_decl;
110138 + enum mark intentional_attr_cur_fndecl;
110139 + gimple intentional_mark_from_gimple;
110140 +};
110141 +
110142 +int plugin_is_GPL_compatible;
110143 +void debug_gimple_stmt(gimple gs);
110144 +
110145 +static tree report_size_overflow_decl;
110146 +static const_tree const_char_ptr_type_node;
110147 +
110148 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
110149 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
110150 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
110151 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
110152 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
110153 +
110154 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
110155 +static tree get_size_overflow_type(gimple stmt, const_tree node);
110156 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
110157 +
110158 +static struct plugin_info size_overflow_plugin_info = {
110159 + .version = "20131120beta",
110160 + .help = "no-size-overflow\tturn off size overflow checking\n",
110161 +};
110162 +
110163 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110164 +{
110165 + unsigned int arg_count;
110166 + enum tree_code code = TREE_CODE(*node);
110167 +
110168 + switch (code) {
110169 + case FUNCTION_DECL:
110170 + arg_count = type_num_arguments(TREE_TYPE(*node));
110171 + break;
110172 + case FUNCTION_TYPE:
110173 + case METHOD_TYPE:
110174 + arg_count = type_num_arguments(*node);
110175 + break;
110176 + default:
110177 + *no_add_attrs = true;
110178 + error("%s: %qE attribute only applies to functions", __func__, name);
110179 + return NULL_TREE;
110180 + }
110181 +
110182 + for (; args; args = TREE_CHAIN(args)) {
110183 + tree position = TREE_VALUE(args);
110184 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110185 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110186 + *no_add_attrs = true;
110187 + }
110188 + }
110189 + return NULL_TREE;
110190 +}
110191 +
110192 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110193 +{
110194 + unsigned int arg_count;
110195 + enum tree_code code = TREE_CODE(*node);
110196 +
110197 + switch (code) {
110198 + case FUNCTION_DECL:
110199 + arg_count = type_num_arguments(TREE_TYPE(*node));
110200 + break;
110201 + case FUNCTION_TYPE:
110202 + case METHOD_TYPE:
110203 + arg_count = type_num_arguments(*node);
110204 + break;
110205 + case FIELD_DECL:
110206 + return NULL_TREE;
110207 + default:
110208 + *no_add_attrs = true;
110209 + error("%qE attribute only applies to functions", name);
110210 + return NULL_TREE;
110211 + }
110212 +
110213 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
110214 + return NULL_TREE;
110215 +
110216 + for (; args; args = TREE_CHAIN(args)) {
110217 + tree position = TREE_VALUE(args);
110218 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110219 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110220 + *no_add_attrs = true;
110221 + }
110222 + }
110223 + return NULL_TREE;
110224 +}
110225 +
110226 +static struct attribute_spec size_overflow_attr = {
110227 + .name = "size_overflow",
110228 + .min_length = 1,
110229 + .max_length = -1,
110230 + .decl_required = true,
110231 + .type_required = false,
110232 + .function_type_required = false,
110233 + .handler = handle_size_overflow_attribute,
110234 +#if BUILDING_GCC_VERSION >= 4007
110235 + .affects_type_identity = false
110236 +#endif
110237 +};
110238 +
110239 +static struct attribute_spec intentional_overflow_attr = {
110240 + .name = "intentional_overflow",
110241 + .min_length = 1,
110242 + .max_length = -1,
110243 + .decl_required = true,
110244 + .type_required = false,
110245 + .function_type_required = false,
110246 + .handler = handle_intentional_overflow_attribute,
110247 +#if BUILDING_GCC_VERSION >= 4007
110248 + .affects_type_identity = false
110249 +#endif
110250 +};
110251 +
110252 +static void register_attributes(void __unused *event_data, void __unused *data)
110253 +{
110254 + register_attribute(&size_overflow_attr);
110255 + register_attribute(&intentional_overflow_attr);
110256 +}
110257 +
110258 +static bool is_bool(const_tree node)
110259 +{
110260 + const_tree type;
110261 +
110262 + if (node == NULL_TREE)
110263 + return false;
110264 +
110265 + type = TREE_TYPE(node);
110266 + if (!INTEGRAL_TYPE_P(type))
110267 + return false;
110268 + if (TREE_CODE(type) == BOOLEAN_TYPE)
110269 + return true;
110270 + if (TYPE_PRECISION(type) == 1)
110271 + return true;
110272 + return false;
110273 +}
110274 +
110275 +static bool skip_types(const_tree var)
110276 +{
110277 + tree type;
110278 + enum tree_code code;
110279 +
110280 + if (is_gimple_constant(var))
110281 + return true;
110282 +
110283 + switch (TREE_CODE(var)) {
110284 + case ADDR_EXPR:
110285 +#if BUILDING_GCC_VERSION >= 4006
110286 + case MEM_REF:
110287 +#endif
110288 + case ARRAY_REF:
110289 + case BIT_FIELD_REF:
110290 + case INDIRECT_REF:
110291 + case TARGET_MEM_REF:
110292 + case COMPONENT_REF:
110293 + case VAR_DECL:
110294 + case VIEW_CONVERT_EXPR:
110295 + return true;
110296 + default:
110297 + break;
110298 + }
110299 +
110300 + code = TREE_CODE(var);
110301 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
110302 +
110303 + type = TREE_TYPE(var);
110304 + switch (TREE_CODE(type)) {
110305 + case INTEGER_TYPE:
110306 + case ENUMERAL_TYPE:
110307 + return false;
110308 + case BOOLEAN_TYPE:
110309 + return is_bool(var);
110310 + default:
110311 + return true;
110312 + }
110313 +}
110314 +
110315 +static inline gimple get_def_stmt(const_tree node)
110316 +{
110317 + gcc_assert(node != NULL_TREE);
110318 +
110319 + if (skip_types(node))
110320 + return NULL;
110321 +
110322 + if (TREE_CODE(node) != SSA_NAME)
110323 + return NULL;
110324 + return SSA_NAME_DEF_STMT(node);
110325 +}
110326 +
110327 +static unsigned char get_tree_code(const_tree type)
110328 +{
110329 + switch (TREE_CODE(type)) {
110330 + case ARRAY_TYPE:
110331 + return 0;
110332 + case BOOLEAN_TYPE:
110333 + return 1;
110334 + case ENUMERAL_TYPE:
110335 + return 2;
110336 + case FUNCTION_TYPE:
110337 + return 3;
110338 + case INTEGER_TYPE:
110339 + return 4;
110340 + case POINTER_TYPE:
110341 + return 5;
110342 + case RECORD_TYPE:
110343 + return 6;
110344 + case UNION_TYPE:
110345 + return 7;
110346 + case VOID_TYPE:
110347 + return 8;
110348 + case REAL_TYPE:
110349 + return 9;
110350 + case VECTOR_TYPE:
110351 + return 10;
110352 + case REFERENCE_TYPE:
110353 + return 11;
110354 + case OFFSET_TYPE:
110355 + return 12;
110356 + case COMPLEX_TYPE:
110357 + return 13;
110358 + default:
110359 + debug_tree((tree)type);
110360 + gcc_unreachable();
110361 + }
110362 +}
110363 +
110364 +struct function_hash {
110365 + size_t tree_codes_len;
110366 + unsigned char tree_codes[CODES_LIMIT];
110367 + tree fndecl;
110368 + unsigned int hash;
110369 +};
110370 +
110371 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
110372 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
110373 +{
110374 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
110375 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
110376 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
110377 +
110378 + unsigned int m = 0x57559429;
110379 + unsigned int n = 0x5052acdb;
110380 + const unsigned int *key4 = (const unsigned int *)key;
110381 + unsigned int h = len;
110382 + unsigned int k = len + seed + n;
110383 + unsigned long long p;
110384 +
110385 + while (len >= 8) {
110386 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
110387 + len -= 8;
110388 + }
110389 + if (len >= 4) {
110390 + cwmixb(key4[0]) key4 += 1;
110391 + len -= 4;
110392 + }
110393 + if (len)
110394 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
110395 + cwmixb(h ^ (k + n));
110396 + return k ^ h;
110397 +
110398 +#undef cwfold
110399 +#undef cwmixa
110400 +#undef cwmixb
110401 +}
110402 +
110403 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
110404 +{
110405 + unsigned int fn, codes, seed = 0;
110406 +
110407 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
110408 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
110409 +
110410 + fn_hash_data->hash = fn ^ codes;
110411 +}
110412 +
110413 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
110414 +{
110415 + gcc_assert(type != NULL_TREE);
110416 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
110417 +
110418 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
110419 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
110420 + fn_hash_data->tree_codes_len++;
110421 + type = TREE_TYPE(type);
110422 + }
110423 +}
110424 +
110425 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
110426 +{
110427 + const_tree result;
110428 +
110429 + gcc_assert(node != NULL_TREE);
110430 +
110431 + if (DECL_P(node)) {
110432 + result = DECL_RESULT(node);
110433 + if (result != NULL_TREE)
110434 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
110435 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110436 + }
110437 +
110438 + gcc_assert(TYPE_P(node));
110439 +
110440 + if (TREE_CODE(node) == FUNCTION_TYPE)
110441 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110442 +
110443 + return set_node_codes(node, fn_hash_data);
110444 +}
110445 +
110446 +static void set_function_codes(struct function_hash *fn_hash_data)
110447 +{
110448 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
110449 + enum tree_code code = TREE_CODE(type);
110450 +
110451 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
110452 +
110453 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
110454 +
110455 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
110456 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
110457 +}
110458 +
110459 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
110460 +{
110461 + const struct size_overflow_hash *entry;
110462 + struct function_hash fn_hash_data;
110463 + const char *func_name;
110464 +
110465 + // skip builtins __builtin_constant_p
110466 + if (DECL_BUILT_IN(fndecl))
110467 + return NULL;
110468 +
110469 + fn_hash_data.fndecl = fndecl;
110470 + fn_hash_data.tree_codes_len = 0;
110471 +
110472 + set_function_codes(&fn_hash_data);
110473 + gcc_assert(fn_hash_data.tree_codes_len != 0);
110474 +
110475 + func_name = ASM_NAME(fn_hash_data.fndecl);
110476 + set_hash(func_name, &fn_hash_data);
110477 +
110478 + entry = size_overflow_hash[fn_hash_data.hash];
110479 +
110480 + while (entry) {
110481 + if (!strcmp(entry->name, func_name))
110482 + return entry;
110483 + entry = entry->next;
110484 + }
110485 + return NULL;
110486 +}
110487 +
110488 +static void print_missing_msg(tree func, unsigned int argnum)
110489 +{
110490 + location_t loc;
110491 + const char *curfunc;
110492 + struct function_hash fn_hash_data;
110493 +
110494 + fn_hash_data.fndecl = DECL_ORIGIN(func);
110495 + fn_hash_data.tree_codes_len = 0;
110496 +
110497 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
110498 + curfunc = ASM_NAME(fn_hash_data.fndecl);
110499 +
110500 + set_function_codes(&fn_hash_data);
110501 + set_hash(curfunc, &fn_hash_data);
110502 +
110503 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
110504 +}
110505 +
110506 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
110507 +{
110508 + tree var;
110509 + unsigned int argnum = 1;
110510 +
110511 + if (TREE_CODE(arg) == SSA_NAME)
110512 + arg = SSA_NAME_VAR(arg);
110513 +
110514 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
110515 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
110516 + continue;
110517 + if (!skip_types(var))
110518 + return argnum;
110519 + }
110520 +
110521 + return CANNOT_FIND_ARG;
110522 +}
110523 +
110524 +static tree create_new_var(tree type)
110525 +{
110526 + tree new_var = create_tmp_var(type, "cicus");
110527 +
110528 +#if BUILDING_GCC_VERSION <= 4007
110529 + add_referenced_var(new_var);
110530 +#endif
110531 + return new_var;
110532 +}
110533 +
110534 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
110535 +{
110536 + gimple assign;
110537 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110538 + tree type = TREE_TYPE(rhs1);
110539 + tree lhs = create_new_var(type);
110540 +
110541 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
110542 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
110543 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110544 +
110545 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
110546 + update_stmt(assign);
110547 + gimple_set_plf(assign, MY_STMT, true);
110548 + return assign;
110549 +}
110550 +
110551 +static tree cast_a_tree(tree type, tree var)
110552 +{
110553 + gcc_assert(type != NULL_TREE);
110554 + gcc_assert(var != NULL_TREE);
110555 + gcc_assert(fold_convertible_p(type, var));
110556 +
110557 + return fold_convert(type, var);
110558 +}
110559 +
110560 +static tree get_lhs(const_gimple stmt)
110561 +{
110562 + switch (gimple_code(stmt)) {
110563 + case GIMPLE_ASSIGN:
110564 + case GIMPLE_CALL:
110565 + return gimple_get_lhs(stmt);
110566 + case GIMPLE_PHI:
110567 + return gimple_phi_result(stmt);
110568 + default:
110569 + return NULL_TREE;
110570 + }
110571 +}
110572 +
110573 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
110574 +{
110575 + const_gimple def_stmt = get_def_stmt(rhs);
110576 +
110577 + if (force)
110578 + return false;
110579 +
110580 + if (is_gimple_constant(rhs))
110581 + return false;
110582 +
110583 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110584 + return false;
110585 +
110586 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
110587 + return false;
110588 +
110589 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
110590 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110591 + return false;
110592 +
110593 + return true;
110594 +}
110595 +
110596 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
110597 +{
110598 + gimple assign, def_stmt;
110599 +
110600 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
110601 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
110602 + gcc_unreachable();
110603 +
110604 + def_stmt = get_def_stmt(rhs);
110605 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
110606 + return def_stmt;
110607 +
110608 + if (lhs == CREATE_NEW_VAR)
110609 + lhs = create_new_var(dst_type);
110610 +
110611 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
110612 +
110613 + if (!gsi_end_p(*gsi)) {
110614 + location_t loc = gimple_location(gsi_stmt(*gsi));
110615 + gimple_set_location(assign, loc);
110616 + }
110617 +
110618 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110619 +
110620 + if (before)
110621 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
110622 + else
110623 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
110624 + update_stmt(assign);
110625 + return assign;
110626 +}
110627 +
110628 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
110629 +{
110630 + gimple_stmt_iterator gsi;
110631 + tree lhs;
110632 + gimple new_stmt;
110633 +
110634 + if (rhs == NULL_TREE)
110635 + return NULL_TREE;
110636 +
110637 + gsi = gsi_for_stmt(stmt);
110638 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
110639 + gimple_set_plf(new_stmt, MY_STMT, true);
110640 +
110641 + lhs = get_lhs(new_stmt);
110642 + gcc_assert(lhs != NULL_TREE);
110643 + return lhs;
110644 +}
110645 +
110646 +static tree cast_to_TI_type(gimple stmt, tree node)
110647 +{
110648 + gimple_stmt_iterator gsi;
110649 + gimple cast_stmt;
110650 + tree type = TREE_TYPE(node);
110651 +
110652 + if (types_compatible_p(type, intTI_type_node))
110653 + return node;
110654 +
110655 + gsi = gsi_for_stmt(stmt);
110656 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110657 + gimple_set_plf(cast_stmt, MY_STMT, true);
110658 + return gimple_assign_lhs(cast_stmt);
110659 +}
110660 +
110661 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
110662 +{
110663 + tree lhs, new_lhs;
110664 + gimple_stmt_iterator gsi;
110665 +
110666 + if (rhs1 == NULL_TREE) {
110667 + debug_gimple_stmt(oldstmt);
110668 + error("%s: rhs1 is NULL_TREE", __func__);
110669 + gcc_unreachable();
110670 + }
110671 +
110672 + switch (gimple_code(oldstmt)) {
110673 + case GIMPLE_ASM:
110674 + lhs = rhs1;
110675 + break;
110676 + case GIMPLE_CALL:
110677 + case GIMPLE_ASSIGN:
110678 + lhs = gimple_get_lhs(oldstmt);
110679 + break;
110680 + default:
110681 + debug_gimple_stmt(oldstmt);
110682 + gcc_unreachable();
110683 + }
110684 +
110685 + gsi = gsi_for_stmt(oldstmt);
110686 + pointer_set_insert(visited, oldstmt);
110687 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
110688 + basic_block next_bb, cur_bb;
110689 + const_edge e;
110690 +
110691 + gcc_assert(before == false);
110692 + gcc_assert(stmt_can_throw_internal(oldstmt));
110693 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
110694 + gcc_assert(!gsi_end_p(gsi));
110695 +
110696 + cur_bb = gimple_bb(oldstmt);
110697 + next_bb = cur_bb->next_bb;
110698 + e = find_edge(cur_bb, next_bb);
110699 + gcc_assert(e != NULL);
110700 + gcc_assert(e->flags & EDGE_FALLTHRU);
110701 +
110702 + gsi = gsi_after_labels(next_bb);
110703 + gcc_assert(!gsi_end_p(gsi));
110704 +
110705 + before = true;
110706 + oldstmt = gsi_stmt(gsi);
110707 + }
110708 +
110709 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
110710 + return new_lhs;
110711 +}
110712 +
110713 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
110714 +{
110715 + gimple stmt;
110716 + gimple_stmt_iterator gsi;
110717 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
110718 +
110719 + if (gimple_plf(oldstmt, MY_STMT))
110720 + return lhs;
110721 +
110722 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
110723 + rhs1 = gimple_assign_rhs1(oldstmt);
110724 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
110725 + }
110726 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
110727 + rhs2 = gimple_assign_rhs2(oldstmt);
110728 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
110729 + }
110730 +
110731 + stmt = gimple_copy(oldstmt);
110732 + gimple_set_location(stmt, gimple_location(oldstmt));
110733 + gimple_set_plf(stmt, MY_STMT, true);
110734 +
110735 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
110736 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
110737 +
110738 + size_overflow_type = get_size_overflow_type(oldstmt, node);
110739 +
110740 + new_var = create_new_var(size_overflow_type);
110741 + new_var = make_ssa_name(new_var, stmt);
110742 + gimple_assign_set_lhs(stmt, new_var);
110743 +
110744 + if (rhs1 != NULL_TREE)
110745 + gimple_assign_set_rhs1(stmt, rhs1);
110746 +
110747 + if (rhs2 != NULL_TREE)
110748 + gimple_assign_set_rhs2(stmt, rhs2);
110749 +#if BUILDING_GCC_VERSION >= 4007
110750 + if (rhs3 != NULL_TREE)
110751 + gimple_assign_set_rhs3(stmt, rhs3);
110752 +#endif
110753 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
110754 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
110755 +
110756 + gsi = gsi_for_stmt(oldstmt);
110757 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
110758 + update_stmt(stmt);
110759 + pointer_set_insert(visited, oldstmt);
110760 + return gimple_assign_lhs(stmt);
110761 +}
110762 +
110763 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
110764 +{
110765 + gimple assign;
110766 + gimple_stmt_iterator gsi;
110767 + basic_block first_bb;
110768 +
110769 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
110770 +
110771 + if (bb->index == 0) {
110772 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110773 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110774 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
110775 + bb = first_bb;
110776 + }
110777 +
110778 + gsi = gsi_after_labels(bb);
110779 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110780 + gimple_set_plf(assign, MY_STMT, true);
110781 +
110782 + return gimple_assign_lhs(assign);
110783 +}
110784 +
110785 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
110786 +{
110787 + gimple_stmt_iterator gsi;
110788 + gimple assign, def_stmt = get_def_stmt(new_arg);
110789 +
110790 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
110791 + gsi = gsi_after_labels(gimple_bb(def_stmt));
110792 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
110793 + } else {
110794 + gsi = gsi_for_stmt(def_stmt);
110795 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
110796 + }
110797 +
110798 + gimple_set_plf(assign, MY_STMT, true);
110799 + return gimple_assign_lhs(assign);
110800 +}
110801 +
110802 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
110803 +{
110804 + basic_block bb;
110805 + gimple_stmt_iterator gsi;
110806 + const_gimple def_stmt;
110807 + gimple assign;
110808 +
110809 + def_stmt = get_def_stmt(arg);
110810 + bb = gimple_bb(def_stmt);
110811 + gcc_assert(bb->index != 0);
110812 + gsi = gsi_after_labels(bb);
110813 +
110814 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
110815 + gimple_set_plf(assign, MY_STMT, true);
110816 + return gimple_assign_lhs(assign);
110817 +}
110818 +
110819 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
110820 +{
110821 + tree size_overflow_type;
110822 + tree arg;
110823 + const_gimple def_stmt;
110824 +
110825 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
110826 + return new_arg;
110827 +
110828 + arg = gimple_phi_arg_def(oldstmt, i);
110829 + def_stmt = get_def_stmt(arg);
110830 + gcc_assert(def_stmt != NULL);
110831 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
110832 +
110833 + switch (gimple_code(def_stmt)) {
110834 + case GIMPLE_PHI:
110835 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
110836 + case GIMPLE_NOP: {
110837 + basic_block bb;
110838 +
110839 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
110840 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
110841 + }
110842 + case GIMPLE_ASM: {
110843 + gimple_stmt_iterator gsi;
110844 + gimple assign, stmt = get_def_stmt(arg);
110845 +
110846 + gsi = gsi_for_stmt(stmt);
110847 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
110848 + gimple_set_plf(assign, MY_STMT, true);
110849 + return gimple_assign_lhs(assign);
110850 + }
110851 + default:
110852 + gcc_assert(new_arg != NULL_TREE);
110853 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
110854 + return use_phi_ssa_name(ssa_name_var, new_arg);
110855 + }
110856 +}
110857 +
110858 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
110859 +{
110860 + basic_block bb;
110861 + gimple phi;
110862 + gimple_seq seq;
110863 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
110864 +
110865 + bb = gsi_bb(gsi);
110866 +
110867 + if (result == NULL_TREE) {
110868 + tree old_result = gimple_phi_result(oldstmt);
110869 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
110870 +
110871 + result = create_new_var(size_overflow_type);
110872 + }
110873 +
110874 + phi = create_phi_node(result, bb);
110875 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
110876 + seq = phi_nodes(bb);
110877 + gsi = gsi_last(seq);
110878 + gsi_remove(&gsi, false);
110879 +
110880 + gsi = gsi_for_stmt(oldstmt);
110881 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
110882 + gimple_set_bb(phi, bb);
110883 + gimple_set_plf(phi, MY_STMT, true);
110884 + return phi;
110885 +}
110886 +
110887 +#if BUILDING_GCC_VERSION <= 4007
110888 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
110889 +#else
110890 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
110891 +#endif
110892 +{
110893 + gimple new_phi;
110894 + unsigned int i;
110895 + tree arg, result;
110896 + location_t loc = gimple_location(oldstmt);
110897 +
110898 +#if BUILDING_GCC_VERSION <= 4007
110899 + gcc_assert(!VEC_empty(tree, args));
110900 +#else
110901 + gcc_assert(!args->is_empty());
110902 +#endif
110903 +
110904 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
110905 + result = gimple_phi_result(new_phi);
110906 + ssa_name_var = SSA_NAME_VAR(result);
110907 +
110908 +
110909 +#if BUILDING_GCC_VERSION == 4005
110910 + for (i = 0; i < VEC_length(tree, args); i++) {
110911 + arg = VEC_index(tree, args, i);
110912 +#elif BUILDING_GCC_VERSION <= 4007
110913 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
110914 +#else
110915 + FOR_EACH_VEC_ELT(*args, i, arg) {
110916 +#endif
110917 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
110918 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
110919 + }
110920 +
110921 +#if BUILDING_GCC_VERSION <= 4007
110922 + VEC_free(tree, gc, args);
110923 +#else
110924 + vec_free(args);
110925 +#endif
110926 + update_stmt(new_phi);
110927 + return result;
110928 +}
110929 +
110930 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
110931 +{
110932 + tree ssa_name_var = NULL_TREE;
110933 +#if BUILDING_GCC_VERSION <= 4007
110934 + VEC(tree, gc) *args;
110935 +#else
110936 + vec<tree, va_gc> *args;
110937 +#endif
110938 + gimple oldstmt = get_def_stmt(orig_result);
110939 + unsigned int i, len = gimple_phi_num_args(oldstmt);
110940 +
110941 + pointer_set_insert(visited, oldstmt);
110942 +#if BUILDING_GCC_VERSION <= 4007
110943 + args = VEC_alloc(tree, gc, len);
110944 +#else
110945 + vec_alloc(args, len);
110946 +#endif
110947 + for (i = 0; i < len; i++) {
110948 + tree arg, new_arg;
110949 +
110950 + arg = gimple_phi_arg_def(oldstmt, i);
110951 + new_arg = expand(visited, caller_node, arg);
110952 +
110953 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
110954 + ssa_name_var = SSA_NAME_VAR(new_arg);
110955 +
110956 + if (is_gimple_constant(arg)) {
110957 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
110958 +
110959 + new_arg = cast_a_tree(size_overflow_type, arg);
110960 + }
110961 +
110962 +#if BUILDING_GCC_VERSION <= 4007
110963 + VEC_safe_push(tree, gc, args, new_arg);
110964 +#else
110965 + vec_safe_push(args, new_arg);
110966 +#endif
110967 + }
110968 +
110969 + return create_new_phi_node(args, ssa_name_var, oldstmt);
110970 +}
110971 +
110972 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
110973 +{
110974 + gimple assign;
110975 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110976 + tree origtype = TREE_TYPE(orig_rhs);
110977 +
110978 + gcc_assert(is_gimple_assign(stmt));
110979 +
110980 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110981 + gimple_set_plf(assign, MY_STMT, true);
110982 + return gimple_assign_lhs(assign);
110983 +}
110984 +
110985 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
110986 +{
110987 + const_tree rhs1, lhs, rhs1_type, lhs_type;
110988 + enum machine_mode lhs_mode, rhs_mode;
110989 + gimple def_stmt = get_def_stmt(no_const_rhs);
110990 +
110991 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110992 + return false;
110993 +
110994 + rhs1 = gimple_assign_rhs1(def_stmt);
110995 + lhs = gimple_assign_lhs(def_stmt);
110996 + rhs1_type = TREE_TYPE(rhs1);
110997 + lhs_type = TREE_TYPE(lhs);
110998 + rhs_mode = TYPE_MODE(rhs1_type);
110999 + lhs_mode = TYPE_MODE(lhs_type);
111000 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
111001 + return false;
111002 +
111003 + return true;
111004 +}
111005 +
111006 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
111007 +{
111008 + tree rhs1 = gimple_assign_rhs1(stmt);
111009 + tree lhs = gimple_assign_lhs(stmt);
111010 + const_tree rhs1_type = TREE_TYPE(rhs1);
111011 + const_tree lhs_type = TREE_TYPE(lhs);
111012 +
111013 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
111014 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111015 +
111016 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
111017 +}
111018 +
111019 +static bool no_uses(tree node)
111020 +{
111021 + imm_use_iterator imm_iter;
111022 + use_operand_p use_p;
111023 +
111024 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
111025 + const_gimple use_stmt = USE_STMT(use_p);
111026 +
111027 + if (use_stmt == NULL)
111028 + return true;
111029 + if (is_gimple_debug(use_stmt))
111030 + continue;
111031 + return false;
111032 + }
111033 + return true;
111034 +}
111035 +
111036 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
111037 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
111038 +{
111039 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
111040 + gimple def_stmt = get_def_stmt(lhs);
111041 +
111042 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111043 + return false;
111044 +
111045 + rhs1 = gimple_assign_rhs1(def_stmt);
111046 + rhs_type = TREE_TYPE(rhs1);
111047 + lhs_type = TREE_TYPE(lhs);
111048 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
111049 + return false;
111050 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
111051 + return false;
111052 +
111053 + def_stmt = get_def_stmt(rhs1);
111054 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
111055 + return false;
111056 +
111057 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
111058 + return false;
111059 +
111060 + rhs1 = gimple_assign_rhs1(def_stmt);
111061 + rhs2 = gimple_assign_rhs2(def_stmt);
111062 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
111063 + return false;
111064 +
111065 + if (is_gimple_constant(rhs2))
111066 + not_const_rhs = rhs1;
111067 + else
111068 + not_const_rhs = rhs2;
111069 +
111070 + return no_uses(not_const_rhs);
111071 +}
111072 +
111073 +static bool skip_lhs_cast_check(const_gimple stmt)
111074 +{
111075 + const_tree rhs = gimple_assign_rhs1(stmt);
111076 + const_gimple def_stmt = get_def_stmt(rhs);
111077 +
111078 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
111079 + if (gimple_code(def_stmt) == GIMPLE_ASM)
111080 + return true;
111081 +
111082 + if (is_const_plus_unsigned_signed_truncation(rhs))
111083 + return true;
111084 +
111085 + return false;
111086 +}
111087 +
111088 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
111089 +{
111090 + bool cast_lhs, cast_rhs;
111091 + tree lhs = gimple_assign_lhs(stmt);
111092 + tree rhs = gimple_assign_rhs1(stmt);
111093 + const_tree lhs_type = TREE_TYPE(lhs);
111094 + const_tree rhs_type = TREE_TYPE(rhs);
111095 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
111096 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
111097 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
111098 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
111099 +
111100 + static bool check_lhs[3][4] = {
111101 + // ss su us uu
111102 + { false, true, true, false }, // lhs > rhs
111103 + { false, false, false, false }, // lhs = rhs
111104 + { true, true, true, true }, // lhs < rhs
111105 + };
111106 +
111107 + static bool check_rhs[3][4] = {
111108 + // ss su us uu
111109 + { true, false, true, true }, // lhs > rhs
111110 + { true, false, true, true }, // lhs = rhs
111111 + { true, false, true, true }, // lhs < rhs
111112 + };
111113 +
111114 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
111115 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
111116 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111117 +
111118 + if (lhs_size > rhs_size) {
111119 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111120 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111121 + } else if (lhs_size == rhs_size) {
111122 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111123 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111124 + } else {
111125 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111126 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111127 + }
111128 +
111129 + if (!cast_lhs && !cast_rhs)
111130 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111131 +
111132 + if (cast_lhs && !skip_lhs_cast_check(stmt))
111133 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
111134 +
111135 + if (cast_rhs)
111136 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
111137 +
111138 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111139 +}
111140 +
111141 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111142 +{
111143 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
111144 +
111145 + if (gimple_plf(stmt, MY_STMT))
111146 + return lhs;
111147 +
111148 + rhs1 = gimple_assign_rhs1(stmt);
111149 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
111150 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111151 +
111152 + new_rhs1 = expand(visited, caller_node, rhs1);
111153 +
111154 + if (new_rhs1 == NULL_TREE)
111155 + return create_cast_assign(visited, stmt);
111156 +
111157 + if (gimple_plf(stmt, NO_CAST_CHECK))
111158 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111159 +
111160 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
111161 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
111162 +
111163 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
111164 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
111165 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111166 + }
111167 +
111168 + if (!gimple_assign_cast_p(stmt))
111169 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111170 +
111171 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
111172 +}
111173 +
111174 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111175 +{
111176 + tree rhs1, lhs = gimple_assign_lhs(stmt);
111177 + gimple def_stmt = get_def_stmt(lhs);
111178 +
111179 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
111180 + rhs1 = gimple_assign_rhs1(def_stmt);
111181 +
111182 + if (is_gimple_constant(rhs1))
111183 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111184 +
111185 + switch (TREE_CODE(rhs1)) {
111186 + case SSA_NAME:
111187 + return handle_unary_rhs(visited, caller_node, def_stmt);
111188 + case ARRAY_REF:
111189 + case BIT_FIELD_REF:
111190 + case ADDR_EXPR:
111191 + case COMPONENT_REF:
111192 + case INDIRECT_REF:
111193 +#if BUILDING_GCC_VERSION >= 4006
111194 + case MEM_REF:
111195 +#endif
111196 + case TARGET_MEM_REF:
111197 + case VIEW_CONVERT_EXPR:
111198 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111199 + case PARM_DECL:
111200 + case VAR_DECL:
111201 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111202 +
111203 + default:
111204 + debug_gimple_stmt(def_stmt);
111205 + debug_tree(rhs1);
111206 + gcc_unreachable();
111207 + }
111208 +}
111209 +
111210 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
111211 +{
111212 + gimple cond_stmt;
111213 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
111214 +
111215 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
111216 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
111217 + update_stmt(cond_stmt);
111218 +}
111219 +
111220 +static tree create_string_param(tree string)
111221 +{
111222 + tree i_type, a_type;
111223 + const int length = TREE_STRING_LENGTH(string);
111224 +
111225 + gcc_assert(length > 0);
111226 +
111227 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
111228 + a_type = build_array_type(char_type_node, i_type);
111229 +
111230 + TREE_TYPE(string) = a_type;
111231 + TREE_CONSTANT(string) = 1;
111232 + TREE_READONLY(string) = 1;
111233 +
111234 + return build1(ADDR_EXPR, ptr_type_node, string);
111235 +}
111236 +
111237 +#if BUILDING_GCC_VERSION <= 4006
111238 +struct cgraph_node *cgraph_get_create_node(tree decl);
111239 +
111240 +struct cgraph_node *cgraph_get_create_node(tree decl)
111241 +{
111242 + struct cgraph_node *node;
111243 +
111244 + node = cgraph_get_node(decl);
111245 + if (node)
111246 + return node;
111247 + return cgraph_node(decl);
111248 +}
111249 +#endif
111250 +
111251 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
111252 +{
111253 + gimple func_stmt;
111254 + const_gimple def_stmt;
111255 + const_tree loc_line;
111256 + tree loc_file, ssa_name, current_func;
111257 + expanded_location xloc;
111258 + char *ssa_name_buf;
111259 + int len;
111260 + struct cgraph_edge *edge;
111261 + struct cgraph_node *callee_node;
111262 + int frequency;
111263 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
111264 +
111265 + def_stmt = get_def_stmt(arg);
111266 + xloc = expand_location(gimple_location(def_stmt));
111267 +
111268 + if (!gimple_has_location(def_stmt)) {
111269 + xloc = expand_location(gimple_location(stmt));
111270 + if (!gimple_has_location(stmt))
111271 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
111272 + }
111273 +
111274 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
111275 +
111276 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
111277 + loc_file = create_string_param(loc_file);
111278 +
111279 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
111280 + current_func = create_string_param(current_func);
111281 +
111282 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
111283 + call_count++;
111284 + 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);
111285 + gcc_assert(len > 0);
111286 + ssa_name = build_string(len + 1, ssa_name_buf);
111287 + free(ssa_name_buf);
111288 + ssa_name = create_string_param(ssa_name);
111289 +
111290 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
111291 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
111292 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
111293 +
111294 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
111295 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
111296 +
111297 +#if BUILDING_GCC_VERSION <= 4006
111298 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
111299 +#else
111300 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
111301 +#endif
111302 + gcc_assert(edge != NULL);
111303 +}
111304 +
111305 +static void __unused print_the_code_insertions(const_gimple stmt)
111306 +{
111307 + location_t loc = gimple_location(stmt);
111308 +
111309 + inform(loc, "Integer size_overflow check applied here.");
111310 +}
111311 +
111312 +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)
111313 +{
111314 + basic_block cond_bb, join_bb, bb_true;
111315 + edge e;
111316 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111317 +
111318 + cond_bb = gimple_bb(stmt);
111319 + if (before)
111320 + gsi_prev(&gsi);
111321 + if (gsi_end_p(gsi))
111322 + e = split_block_after_labels(cond_bb);
111323 + else
111324 + e = split_block(cond_bb, gsi_stmt(gsi));
111325 + cond_bb = e->src;
111326 + join_bb = e->dest;
111327 + e->flags = EDGE_FALSE_VALUE;
111328 + e->probability = REG_BR_PROB_BASE;
111329 +
111330 + bb_true = create_empty_bb(cond_bb);
111331 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
111332 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
111333 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
111334 +
111335 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111336 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
111337 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
111338 +
111339 + if (current_loops != NULL) {
111340 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
111341 + add_bb_to_loop(bb_true, cond_bb->loop_father);
111342 + }
111343 +
111344 + insert_cond(cond_bb, arg, cond_code, type_value);
111345 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
111346 +
111347 +// print_the_code_insertions(stmt);
111348 +}
111349 +
111350 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
111351 +{
111352 + const_tree rhs_type = TREE_TYPE(rhs);
111353 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
111354 +
111355 + gcc_assert(rhs_type != NULL_TREE);
111356 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
111357 + return;
111358 +
111359 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
111360 +
111361 + if (is_const_plus_unsigned_signed_truncation(rhs))
111362 + return;
111363 +
111364 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
111365 + // typemax (-1) < typemin (0)
111366 + if (TREE_OVERFLOW(type_max))
111367 + return;
111368 +
111369 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
111370 +
111371 + cast_rhs_type = TREE_TYPE(cast_rhs);
111372 + type_max_type = TREE_TYPE(type_max);
111373 + type_min_type = TREE_TYPE(type_min);
111374 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
111375 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
111376 +
111377 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
111378 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
111379 +}
111380 +
111381 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
111382 +{
111383 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
111384 + return false;
111385 + if (!is_gimple_constant(rhs))
111386 + return false;
111387 + return true;
111388 +}
111389 +
111390 +static tree get_def_stmt_rhs(const_tree var)
111391 +{
111392 + tree rhs1, def_stmt_rhs1;
111393 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
111394 +
111395 + def_stmt = get_def_stmt(var);
111396 + if (!gimple_assign_cast_p(def_stmt))
111397 + return NULL_TREE;
111398 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
111399 +
111400 + rhs1 = gimple_assign_rhs1(def_stmt);
111401 + rhs1_def_stmt = get_def_stmt(rhs1);
111402 + if (!gimple_assign_cast_p(rhs1_def_stmt))
111403 + return rhs1;
111404 +
111405 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111406 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
111407 +
111408 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
111409 + case GIMPLE_CALL:
111410 + case GIMPLE_NOP:
111411 + case GIMPLE_ASM:
111412 + case GIMPLE_PHI:
111413 + return def_stmt_rhs1;
111414 + case GIMPLE_ASSIGN:
111415 + return rhs1;
111416 + default:
111417 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
111418 + gcc_unreachable();
111419 + }
111420 +}
111421 +
111422 +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)
111423 +{
111424 + tree new_rhs, orig_rhs;
111425 + void (*gimple_assign_set_rhs)(gimple, tree);
111426 + tree rhs1 = gimple_assign_rhs1(stmt);
111427 + tree rhs2 = gimple_assign_rhs2(stmt);
111428 + tree lhs = gimple_assign_lhs(stmt);
111429 +
111430 + if (!check_overflow)
111431 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111432 +
111433 + if (change_rhs == NULL_TREE)
111434 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111435 +
111436 + if (new_rhs2 == NULL_TREE) {
111437 + orig_rhs = rhs1;
111438 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
111439 + } else {
111440 + orig_rhs = rhs2;
111441 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
111442 + }
111443 +
111444 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
111445 +
111446 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
111447 + gimple_assign_set_rhs(stmt, new_rhs);
111448 + update_stmt(stmt);
111449 +
111450 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111451 +}
111452 +
111453 +static bool is_subtraction_special(const_gimple stmt)
111454 +{
111455 + gimple rhs1_def_stmt, rhs2_def_stmt;
111456 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
111457 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
111458 + const_tree rhs1 = gimple_assign_rhs1(stmt);
111459 + const_tree rhs2 = gimple_assign_rhs2(stmt);
111460 +
111461 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
111462 + return false;
111463 +
111464 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
111465 +
111466 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
111467 + return false;
111468 +
111469 + rhs1_def_stmt = get_def_stmt(rhs1);
111470 + rhs2_def_stmt = get_def_stmt(rhs2);
111471 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
111472 + return false;
111473 +
111474 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111475 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
111476 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
111477 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
111478 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
111479 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
111480 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
111481 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
111482 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
111483 + return false;
111484 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
111485 + return false;
111486 +
111487 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
111488 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
111489 + return true;
111490 +}
111491 +
111492 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
111493 +{
111494 + tree new_rhs1, new_rhs2;
111495 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
111496 + gimple assign, stmt = get_def_stmt(lhs);
111497 + tree rhs1 = gimple_assign_rhs1(stmt);
111498 + tree rhs2 = gimple_assign_rhs2(stmt);
111499 +
111500 + if (!is_subtraction_special(stmt))
111501 + return NULL_TREE;
111502 +
111503 + new_rhs1 = expand(visited, caller_node, rhs1);
111504 + new_rhs2 = expand(visited, caller_node, rhs2);
111505 +
111506 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
111507 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
111508 +
111509 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
111510 + return NULL_TREE;
111511 +
111512 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
111513 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
111514 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
111515 + }
111516 +
111517 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
111518 + new_lhs = gimple_assign_lhs(assign);
111519 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
111520 +
111521 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111522 +}
111523 +
111524 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
111525 +{
111526 + const_gimple def_stmt;
111527 +
111528 + if (TREE_CODE(rhs) != SSA_NAME)
111529 + return false;
111530 +
111531 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
111532 + return false;
111533 +
111534 + def_stmt = get_def_stmt(rhs);
111535 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
111536 + return false;
111537 +
111538 + return true;
111539 +}
111540 +
111541 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111542 +{
111543 + tree rhs1, rhs2, new_lhs;
111544 + gimple def_stmt = get_def_stmt(lhs);
111545 + tree new_rhs1 = NULL_TREE;
111546 + tree new_rhs2 = NULL_TREE;
111547 +
111548 + rhs1 = gimple_assign_rhs1(def_stmt);
111549 + rhs2 = gimple_assign_rhs2(def_stmt);
111550 +
111551 + /* no DImode/TImode division in the 32/64 bit kernel */
111552 + switch (gimple_assign_rhs_code(def_stmt)) {
111553 + case RDIV_EXPR:
111554 + case TRUNC_DIV_EXPR:
111555 + case CEIL_DIV_EXPR:
111556 + case FLOOR_DIV_EXPR:
111557 + case ROUND_DIV_EXPR:
111558 + case TRUNC_MOD_EXPR:
111559 + case CEIL_MOD_EXPR:
111560 + case FLOOR_MOD_EXPR:
111561 + case ROUND_MOD_EXPR:
111562 + case EXACT_DIV_EXPR:
111563 + case POINTER_PLUS_EXPR:
111564 + case BIT_AND_EXPR:
111565 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111566 + default:
111567 + break;
111568 + }
111569 +
111570 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
111571 + if (new_lhs != NULL_TREE)
111572 + return new_lhs;
111573 +
111574 + if (TREE_CODE(rhs1) == SSA_NAME)
111575 + new_rhs1 = expand(visited, caller_node, rhs1);
111576 + if (TREE_CODE(rhs2) == SSA_NAME)
111577 + new_rhs2 = expand(visited, caller_node, rhs2);
111578 +
111579 + if (is_a_neg_overflow(def_stmt, rhs2))
111580 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
111581 + if (is_a_neg_overflow(def_stmt, rhs1))
111582 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
111583 +
111584 +
111585 + if (is_a_constant_overflow(def_stmt, rhs2))
111586 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
111587 + if (is_a_constant_overflow(def_stmt, rhs1))
111588 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
111589 +
111590 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111591 +}
111592 +
111593 +#if BUILDING_GCC_VERSION >= 4007
111594 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
111595 +{
111596 + if (is_gimple_constant(rhs))
111597 + return cast_a_tree(size_overflow_type, rhs);
111598 + if (TREE_CODE(rhs) != SSA_NAME)
111599 + return NULL_TREE;
111600 + return expand(visited, caller_node, rhs);
111601 +}
111602 +
111603 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111604 +{
111605 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
111606 + gimple def_stmt = get_def_stmt(lhs);
111607 +
111608 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
111609 +
111610 + rhs1 = gimple_assign_rhs1(def_stmt);
111611 + rhs2 = gimple_assign_rhs2(def_stmt);
111612 + rhs3 = gimple_assign_rhs3(def_stmt);
111613 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
111614 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
111615 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
111616 +
111617 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
111618 +}
111619 +#endif
111620 +
111621 +static tree get_size_overflow_type(gimple stmt, const_tree node)
111622 +{
111623 + const_tree type;
111624 + tree new_type;
111625 +
111626 + gcc_assert(node != NULL_TREE);
111627 +
111628 + type = TREE_TYPE(node);
111629 +
111630 + if (gimple_plf(stmt, MY_STMT))
111631 + return TREE_TYPE(node);
111632 +
111633 + switch (TYPE_MODE(type)) {
111634 + case QImode:
111635 + new_type = intHI_type_node;
111636 + break;
111637 + case HImode:
111638 + new_type = intSI_type_node;
111639 + break;
111640 + case SImode:
111641 + new_type = intDI_type_node;
111642 + break;
111643 + case DImode:
111644 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111645 + new_type = intDI_type_node;
111646 + else
111647 + new_type = intTI_type_node;
111648 + break;
111649 + case TImode:
111650 + gcc_assert(!TYPE_UNSIGNED(type));
111651 + new_type = intTI_type_node;
111652 + break;
111653 + default:
111654 + debug_tree((tree)node);
111655 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
111656 + gcc_unreachable();
111657 + }
111658 +
111659 + if (TYPE_QUALS(type) != 0)
111660 + return build_qualified_type(new_type, TYPE_QUALS(type));
111661 + return new_type;
111662 +}
111663 +
111664 +static tree expand_visited(gimple def_stmt)
111665 +{
111666 + const_gimple next_stmt;
111667 + gimple_stmt_iterator gsi;
111668 + enum gimple_code code = gimple_code(def_stmt);
111669 +
111670 + if (code == GIMPLE_ASM)
111671 + return NULL_TREE;
111672 +
111673 + gsi = gsi_for_stmt(def_stmt);
111674 + gsi_next(&gsi);
111675 +
111676 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
111677 + return NULL_TREE;
111678 + gcc_assert(!gsi_end_p(gsi));
111679 + next_stmt = gsi_stmt(gsi);
111680 +
111681 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
111682 + return NULL_TREE;
111683 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
111684 +
111685 + return get_lhs(next_stmt);
111686 +}
111687 +
111688 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111689 +{
111690 + gimple def_stmt;
111691 +
111692 + def_stmt = get_def_stmt(lhs);
111693 +
111694 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111695 + return NULL_TREE;
111696 +
111697 + if (gimple_plf(def_stmt, MY_STMT))
111698 + return lhs;
111699 +
111700 + if (pointer_set_contains(visited, def_stmt))
111701 + return expand_visited(def_stmt);
111702 +
111703 + switch (gimple_code(def_stmt)) {
111704 + case GIMPLE_PHI:
111705 + return handle_phi(visited, caller_node, lhs);
111706 + case GIMPLE_CALL:
111707 + case GIMPLE_ASM:
111708 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111709 + case GIMPLE_ASSIGN:
111710 + switch (gimple_num_ops(def_stmt)) {
111711 + case 2:
111712 + return handle_unary_ops(visited, caller_node, def_stmt);
111713 + case 3:
111714 + return handle_binary_ops(visited, caller_node, lhs);
111715 +#if BUILDING_GCC_VERSION >= 4007
111716 + case 4:
111717 + return handle_ternary_ops(visited, caller_node, lhs);
111718 +#endif
111719 + }
111720 + default:
111721 + debug_gimple_stmt(def_stmt);
111722 + error("%s: unknown gimple code", __func__);
111723 + gcc_unreachable();
111724 + }
111725 +}
111726 +
111727 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
111728 +{
111729 + const_gimple assign;
111730 + tree orig_type = TREE_TYPE(orig_node);
111731 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111732 +
111733 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111734 + return gimple_assign_lhs(assign);
111735 +}
111736 +
111737 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
111738 +{
111739 + void (*set_rhs)(gimple, tree);
111740 + gimple stmt = cur_node->first_stmt;
111741 + const_tree orig_node = cur_node->node;
111742 +
111743 + switch (gimple_code(stmt)) {
111744 + case GIMPLE_RETURN:
111745 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111746 + break;
111747 + case GIMPLE_CALL:
111748 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
111749 + break;
111750 + case GIMPLE_ASSIGN:
111751 + switch (cur_node->num) {
111752 + case 1:
111753 + set_rhs = &gimple_assign_set_rhs1;
111754 + break;
111755 + case 2:
111756 + set_rhs = &gimple_assign_set_rhs2;
111757 + break;
111758 +#if BUILDING_GCC_VERSION > 4005
111759 + case 3:
111760 + set_rhs = &gimple_assign_set_rhs3;
111761 + break;
111762 +#endif
111763 + default:
111764 + gcc_unreachable();
111765 + }
111766 +
111767 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111768 + break;
111769 + default:
111770 + debug_gimple_stmt(stmt);
111771 + gcc_unreachable();
111772 + }
111773 +
111774 + update_stmt(stmt);
111775 +}
111776 +
111777 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
111778 +{
111779 + const struct size_overflow_hash *hash;
111780 + unsigned int new_argnum;
111781 + tree arg;
111782 + const_tree origarg;
111783 +
111784 + if (argnum == 0)
111785 + return argnum;
111786 +
111787 + hash = get_function_hash(fndecl);
111788 + if (hash && hash->param & (1U << argnum))
111789 + return argnum;
111790 +
111791 + if (DECL_EXTERNAL(fndecl))
111792 + return argnum;
111793 +
111794 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
111795 + argnum--;
111796 + while (origarg && argnum) {
111797 + origarg = TREE_CHAIN(origarg);
111798 + argnum--;
111799 + }
111800 + gcc_assert(argnum == 0);
111801 + gcc_assert(origarg != NULL_TREE);
111802 +
111803 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
111804 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
111805 + return new_argnum;
111806 +
111807 + return CANNOT_FIND_ARG;
111808 +}
111809 +
111810 +// Don't want to duplicate entries in next_cgraph_node
111811 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
111812 +{
111813 + const_tree new_callee_fndecl;
111814 + struct next_cgraph_node *cur_node;
111815 +
111816 + if (fndecl == RET_CHECK)
111817 +#if BUILDING_GCC_VERSION <= 4007
111818 + new_callee_fndecl = node->decl;
111819 +#else
111820 + new_callee_fndecl = node->symbol.decl;
111821 +#endif
111822 + else
111823 + new_callee_fndecl = fndecl;
111824 +
111825 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
111826 +#if BUILDING_GCC_VERSION <= 4007
111827 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
111828 +#else
111829 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
111830 +#endif
111831 + continue;
111832 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
111833 + continue;
111834 + if (num == cur_node->num)
111835 + return true;
111836 + }
111837 + return false;
111838 +}
111839 +
111840 +/* Add a next_cgraph_node into the list for handle_function().
111841 + * handle_function() iterates over all the next cgraph nodes and
111842 + * starts the overflow check insertion process.
111843 + */
111844 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
111845 +{
111846 + struct next_cgraph_node *new_node;
111847 +
111848 + if (is_in_next_cgraph_node(head, node, fndecl, num))
111849 + return head;
111850 +
111851 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
111852 + new_node->current_function = node;
111853 + new_node->next = NULL;
111854 + new_node->num = num;
111855 + if (fndecl == RET_CHECK)
111856 +#if BUILDING_GCC_VERSION <= 4007
111857 + new_node->callee_fndecl = node->decl;
111858 +#else
111859 + new_node->callee_fndecl = node->symbol.decl;
111860 +#endif
111861 + else
111862 + new_node->callee_fndecl = fndecl;
111863 +
111864 + if (!head)
111865 + return new_node;
111866 +
111867 + new_node->next = head;
111868 + return new_node;
111869 +}
111870 +
111871 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
111872 +{
111873 + struct cgraph_edge *e;
111874 +
111875 + if (num == 0)
111876 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
111877 +
111878 + for (e = node->callers; e; e = e->next_caller) {
111879 + tree fndecl = gimple_call_fndecl(e->call_stmt);
111880 +
111881 + gcc_assert(fndecl != NULL_TREE);
111882 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
111883 + }
111884 +
111885 + return head;
111886 +}
111887 +
111888 +static bool is_a_return_check(const_tree node)
111889 +{
111890 + if (TREE_CODE(node) == FUNCTION_DECL)
111891 + return true;
111892 +
111893 + gcc_assert(TREE_CODE(node) == PARM_DECL);
111894 + return false;
111895 +}
111896 +
111897 +static bool is_in_hash_table(tree fndecl, unsigned int num)
111898 +{
111899 + const struct size_overflow_hash *hash;
111900 +
111901 + hash = get_function_hash(fndecl);
111902 + if (hash && (hash->param & (1U << num)))
111903 + return true;
111904 + return false;
111905 +}
111906 +
111907 +struct missing_functions {
111908 + struct missing_functions *next;
111909 + const_tree node;
111910 + tree fndecl;
111911 +};
111912 +
111913 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
111914 +{
111915 + struct missing_functions *new_function;
111916 +
111917 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
111918 + new_function->node = node;
111919 + new_function->next = NULL;
111920 +
111921 + if (TREE_CODE(node) == FUNCTION_DECL)
111922 + new_function->fndecl = node;
111923 + else
111924 + new_function->fndecl = current_function_decl;
111925 + gcc_assert(new_function->fndecl);
111926 +
111927 + if (!missing_fn_head)
111928 + return new_function;
111929 +
111930 + new_function->next = missing_fn_head;
111931 + return new_function;
111932 +}
111933 +
111934 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
111935 + * If the function is missing everywhere then print the missing message into stderr.
111936 + */
111937 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
111938 +{
111939 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
111940 +#if BUILDING_GCC_VERSION >= 4008
111941 + case BUILT_IN_BSWAP16:
111942 +#endif
111943 + case BUILT_IN_BSWAP32:
111944 + case BUILT_IN_BSWAP64:
111945 + case BUILT_IN_EXPECT:
111946 + case BUILT_IN_MEMCMP:
111947 + return false;
111948 + default:
111949 + break;
111950 + }
111951 +
111952 + // skip test.c
111953 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
111954 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
111955 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
111956 + }
111957 +
111958 + if (is_in_hash_table(orig_fndecl, num))
111959 + return false;
111960 +
111961 + print_missing_msg(orig_fndecl, num);
111962 + return true;
111963 +}
111964 +
111965 +// Get the argnum of a function decl, if node is a return then the argnum is 0
111966 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
111967 +{
111968 + if (is_a_return_check(node))
111969 + return 0;
111970 + else
111971 + return find_arg_number_tree(node, orig_fndecl);
111972 +}
111973 +
111974 +/* If the function is missing from the hash table and it is a static function
111975 + * then create a next_cgraph_node from it for handle_function()
111976 + */
111977 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
111978 +{
111979 + unsigned int num;
111980 + tree orig_fndecl;
111981 + struct cgraph_node *next_node = NULL;
111982 +
111983 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
111984 +
111985 + num = get_function_num(missing_fn_head->node, orig_fndecl);
111986 + if (num == CANNOT_FIND_ARG)
111987 + return cnodes;
111988 +
111989 + if (!is_missing_function(orig_fndecl, num))
111990 + return cnodes;
111991 +
111992 + next_node = cgraph_get_node(missing_fn_head->fndecl);
111993 + if (next_node && next_node->local.local)
111994 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
111995 + return cnodes;
111996 +}
111997 +
111998 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
111999 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
112000 + */
112001 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
112002 +{
112003 + unsigned int i;
112004 + tree node;
112005 + struct missing_functions *cur, *missing_fn_head = NULL;
112006 +
112007 +#if BUILDING_GCC_VERSION == 4005
112008 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112009 + node = VEC_index(tree, cur_node->last_nodes, i);
112010 +#elif BUILDING_GCC_VERSION <= 4007
112011 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
112012 +#else
112013 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
112014 +#endif
112015 + switch (TREE_CODE(node)) {
112016 + case PARM_DECL:
112017 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
112018 + break;
112019 + case FUNCTION_DECL:
112020 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
112021 + break;
112022 + default:
112023 + break;
112024 + }
112025 + }
112026 +
112027 + while (missing_fn_head) {
112028 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
112029 +
112030 + cur = missing_fn_head->next;
112031 + free(missing_fn_head);
112032 + missing_fn_head = cur;
112033 + }
112034 +
112035 + return cnodes;
112036 +}
112037 +
112038 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
112039 +{
112040 + gimple phi = get_def_stmt(result);
112041 + unsigned int i, n = gimple_phi_num_args(phi);
112042 +
112043 + pointer_set_insert(visited, phi);
112044 + for (i = 0; i < n; i++) {
112045 + const_tree arg = gimple_phi_arg_def(phi, i);
112046 +
112047 + set_conditions(visited, interesting_conditions, arg);
112048 + }
112049 +}
112050 +
112051 +enum conditions {
112052 + FROM_CONST, NOT_UNARY, CAST
112053 +};
112054 +
112055 +// Search for constants, cast assignments and binary/ternary assignments
112056 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
112057 +{
112058 + gimple def_stmt = get_def_stmt(lhs);
112059 +
112060 + if (is_gimple_constant(lhs)) {
112061 + interesting_conditions[FROM_CONST] = true;
112062 + return;
112063 + }
112064 +
112065 + if (!def_stmt)
112066 + return;
112067 +
112068 + if (pointer_set_contains(visited, def_stmt))
112069 + return;
112070 +
112071 + switch (gimple_code(def_stmt)) {
112072 + case GIMPLE_NOP:
112073 + case GIMPLE_CALL:
112074 + case GIMPLE_ASM:
112075 + return;
112076 + case GIMPLE_PHI:
112077 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
112078 + case GIMPLE_ASSIGN:
112079 + if (gimple_num_ops(def_stmt) == 2) {
112080 + const_tree rhs = gimple_assign_rhs1(def_stmt);
112081 +
112082 + if (gimple_assign_cast_p(def_stmt))
112083 + interesting_conditions[CAST] = true;
112084 +
112085 + return set_conditions(visited, interesting_conditions, rhs);
112086 + } else {
112087 + interesting_conditions[NOT_UNARY] = true;
112088 + return;
112089 + }
112090 + default:
112091 + debug_gimple_stmt(def_stmt);
112092 + gcc_unreachable();
112093 + }
112094 +}
112095 +
112096 +// determine whether duplication will be necessary or not.
112097 +static void search_interesting_conditions(const_tree arg, bool *interesting_conditions)
112098 +{
112099 + struct pointer_set_t *visited;
112100 +
112101 + visited = pointer_set_create();
112102 + set_conditions(visited, interesting_conditions, arg);
112103 + pointer_set_destroy(visited);
112104 +}
112105 +
112106 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
112107 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
112108 +{
112109 + gimple assign;
112110 + gimple_stmt_iterator gsi;
112111 +
112112 + // already removed
112113 + if (gimple_bb(asm_stmt) == NULL)
112114 + return;
112115 + gsi = gsi_for_stmt(asm_stmt);
112116 +
112117 + assign = gimple_build_assign(lhs, rhs);
112118 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
112119 + SSA_NAME_DEF_STMT(lhs) = assign;
112120 +
112121 + gsi_remove(&gsi, true);
112122 +}
112123 +
112124 +// Get the field decl of a component ref for intentional_overflow checking
112125 +static const_tree search_field_decl(const_tree comp_ref)
112126 +{
112127 + const_tree field = NULL_TREE;
112128 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
112129 +
112130 + for (i = 0; i < len; i++) {
112131 + field = TREE_OPERAND(comp_ref, i);
112132 + if (TREE_CODE(field) == FIELD_DECL)
112133 + break;
112134 + }
112135 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
112136 + return field;
112137 +}
112138 +
112139 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
112140 + * stmt is a return otherwise it is the callee function.
112141 + */
112142 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
112143 +{
112144 + const_tree fndecl;
112145 +
112146 + if (argnum == 0)
112147 + fndecl = current_function_decl;
112148 + else
112149 + fndecl = gimple_call_fndecl(stmt);
112150 +
112151 + if (fndecl == NULL_TREE)
112152 + return NULL_TREE;
112153 +
112154 + return DECL_ORIGIN(fndecl);
112155 +}
112156 +
112157 +/* Get the param of the intentional_overflow attribute.
112158 + * * 0: MARK_NOT_INTENTIONAL
112159 + * * 1..MAX_PARAM: MARK_YES
112160 + * * -1: MARK_TURN_OFF
112161 + */
112162 +static tree get_attribute_param(const_tree decl)
112163 +{
112164 + const_tree attr;
112165 +
112166 + if (decl == NULL_TREE)
112167 + return NULL_TREE;
112168 +
112169 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
112170 + if (!attr || !TREE_VALUE(attr))
112171 + return NULL_TREE;
112172 +
112173 + return TREE_VALUE(attr);
112174 +}
112175 +
112176 +// MARK_TURN_OFF
112177 +static bool is_turn_off_intentional_attr(const_tree decl)
112178 +{
112179 + const_tree param_head;
112180 +
112181 + param_head = get_attribute_param(decl);
112182 + if (param_head == NULL_TREE)
112183 + return false;
112184 +
112185 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
112186 + return true;
112187 + return false;
112188 +}
112189 +
112190 +// MARK_NOT_INTENTIONAL
112191 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
112192 +{
112193 + const_tree param_head;
112194 +
112195 + if (argnum == 0)
112196 + return false;
112197 +
112198 + param_head = get_attribute_param(decl);
112199 + if (param_head == NULL_TREE)
112200 + return false;
112201 +
112202 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
112203 + return true;
112204 + return false;
112205 +}
112206 +
112207 +// MARK_YES
112208 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
112209 +{
112210 + tree param, param_head;
112211 +
112212 + if (argnum == 0)
112213 + return false;
112214 +
112215 + param_head = get_attribute_param(decl);
112216 + for (param = param_head; param; param = TREE_CHAIN(param))
112217 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
112218 + return true;
112219 + return false;
112220 +}
112221 +
112222 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
112223 +{
112224 + const char *str;
112225 +
112226 + if (!stmt)
112227 + return false;
112228 +
112229 + str = gimple_asm_string(stmt);
112230 + return !strcmp(str, "# size_overflow MARK_TURN_OFF\n\t");
112231 +}
112232 +
112233 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
112234 +{
112235 + const char *str;
112236 +
112237 + if (!stmt)
112238 + return false;
112239 +
112240 + str = gimple_asm_string(stmt);
112241 + return !strcmp(str, "# size_overflow MARK_YES\n\t");
112242 +}
112243 +
112244 +static bool is_size_overflow_asm(const_gimple stmt)
112245 +{
112246 + const char *str;
112247 +
112248 + if (!stmt)
112249 + return false;
112250 +
112251 + str = gimple_asm_string(stmt);
112252 + return !strncmp(str, "# size_overflow", 15);
112253 +}
112254 +
112255 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
112256 +{
112257 + location_t loc;
112258 +
112259 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
112260 + return;
112261 +
112262 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
112263 + return;
112264 +
112265 + loc = DECL_SOURCE_LOCATION(decl);
112266 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
112267 +}
112268 +
112269 +/* Get the type of the intentional_overflow attribute of a node
112270 + * * MARK_TURN_OFF
112271 + * * MARK_YES
112272 + * * MARK_NO
112273 + * * MARK_NOT_INTENTIONAL
112274 + */
112275 +static enum mark get_intentional_attr_type(const_tree node)
112276 +{
112277 + const_tree cur_decl;
112278 +
112279 + if (node == NULL_TREE)
112280 + return MARK_NO;
112281 +
112282 + switch (TREE_CODE(node)) {
112283 + case COMPONENT_REF:
112284 + cur_decl = search_field_decl(node);
112285 + if (is_turn_off_intentional_attr(cur_decl))
112286 + return MARK_TURN_OFF;
112287 + if (is_end_intentional_intentional_attr(cur_decl, 1))
112288 + return MARK_YES;
112289 + break;
112290 + case PARM_DECL: {
112291 + unsigned int argnum;
112292 +
112293 + cur_decl = DECL_ORIGIN(current_function_decl);
112294 + argnum = find_arg_number_tree(node, cur_decl);
112295 + if (argnum == CANNOT_FIND_ARG)
112296 + return MARK_NO;
112297 + if (is_yes_intentional_attr(cur_decl, argnum))
112298 + return MARK_YES;
112299 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
112300 + return MARK_NOT_INTENTIONAL;
112301 + break;
112302 + }
112303 + case FUNCTION_DECL:
112304 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
112305 + return MARK_TURN_OFF;
112306 + break;
112307 + default:
112308 + break;
112309 + }
112310 + return MARK_NO;
112311 +}
112312 +
112313 +// Search for the intentional_overflow attribute on the last nodes
112314 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
112315 +{
112316 + unsigned int i;
112317 + tree last_node;
112318 + enum mark mark = MARK_NO;
112319 +
112320 +#if BUILDING_GCC_VERSION == 4005
112321 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112322 + last_node = VEC_index(tree, cur_node->last_nodes, i);
112323 +#elif BUILDING_GCC_VERSION <= 4007
112324 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
112325 +#else
112326 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
112327 +#endif
112328 + mark = get_intentional_attr_type(last_node);
112329 + if (mark != MARK_NO)
112330 + break;
112331 + }
112332 + return mark;
112333 +}
112334 +
112335 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
112336 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
112337 + */
112338 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
112339 +{
112340 + const_tree input, output;
112341 +
112342 + if (!cur_node->intentional_mark_from_gimple)
112343 + return false;
112344 +
112345 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
112346 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
112347 + else
112348 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112349 +
112350 + // skip param decls
112351 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
112352 + return true;
112353 + input = gimple_asm_input_op(cur_node->intentional_mark_from_gimple, 0);
112354 + output = gimple_asm_output_op(cur_node->intentional_mark_from_gimple, 0);
112355 +
112356 + replace_size_overflow_asm_with_assign(cur_node->intentional_mark_from_gimple, TREE_VALUE(output), TREE_VALUE(input));
112357 + return true;
112358 +}
112359 +
112360 +/* Search intentional_overflow attribute on caller and on callee too.
112361 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
112362 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
112363 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
112364 +*/
112365 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
112366 +{
112367 + const_tree fndecl;
112368 +
112369 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
112370 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112371 + return;
112372 + }
112373 +
112374 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
112375 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
112376 + return;
112377 + }
112378 +
112379 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
112380 + return;
112381 +
112382 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
112383 + if (is_turn_off_intentional_attr(fndecl)) {
112384 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
112385 + return;
112386 + }
112387 +
112388 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
112389 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
112390 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
112391 + cur_node->intentional_attr_decl = MARK_YES;
112392 +
112393 + if (is_intentional_attribute_from_gimple(cur_node))
112394 + return;
112395 +
112396 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
112397 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
112398 +}
112399 +
112400 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
112401 +static bool skip_asm(const_tree arg)
112402 +{
112403 + gimple def_stmt = get_def_stmt(arg);
112404 +
112405 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112406 + return false;
112407 +
112408 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
112409 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
112410 +}
112411 +
112412 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
112413 +{
112414 + gimple phi = get_def_stmt(result);
112415 + unsigned int i, n = gimple_phi_num_args(phi);
112416 +
112417 + pointer_set_insert(visited, phi);
112418 + for (i = 0; i < n; i++) {
112419 + tree arg = gimple_phi_arg_def(phi, i);
112420 +
112421 + walk_use_def(visited, cur_node, arg);
112422 + }
112423 +}
112424 +
112425 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112426 +{
112427 + gimple def_stmt = get_def_stmt(lhs);
112428 + tree rhs1, rhs2;
112429 +
112430 + rhs1 = gimple_assign_rhs1(def_stmt);
112431 + rhs2 = gimple_assign_rhs2(def_stmt);
112432 +
112433 + walk_use_def(visited, cur_node, rhs1);
112434 + walk_use_def(visited, cur_node, rhs2);
112435 +}
112436 +
112437 +static void insert_last_node(struct interesting_node *cur_node, tree node)
112438 +{
112439 + unsigned int i;
112440 + tree element;
112441 + enum tree_code code;
112442 +
112443 + gcc_assert(node != NULL_TREE);
112444 +
112445 + if (is_gimple_constant(node))
112446 + return;
112447 +
112448 + code = TREE_CODE(node);
112449 + if (code == VAR_DECL) {
112450 + node = DECL_ORIGIN(node);
112451 + code = TREE_CODE(node);
112452 + }
112453 +
112454 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
112455 + return;
112456 +
112457 +#if BUILDING_GCC_VERSION == 4005
112458 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112459 + element = VEC_index(tree, cur_node->last_nodes, i);
112460 +#elif BUILDING_GCC_VERSION <= 4007
112461 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
112462 +#else
112463 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
112464 +#endif
112465 + if (operand_equal_p(node, element, 0))
112466 + return;
112467 + }
112468 +
112469 +#if BUILDING_GCC_VERSION <= 4007
112470 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
112471 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
112472 +#else
112473 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
112474 + vec_safe_push(cur_node->last_nodes, node);
112475 +#endif
112476 +}
112477 +
112478 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
112479 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
112480 +{
112481 + const_tree asm_lhs;
112482 +
112483 + if (!is_size_overflow_asm(stmt))
112484 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112485 +
112486 + asm_lhs = gimple_asm_input_op(stmt, 0);
112487 + walk_use_def(visited, cur_node, TREE_VALUE(asm_lhs));
112488 +}
112489 +
112490 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
112491 + * and component refs (for checking the intentional_overflow attribute).
112492 + */
112493 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112494 +{
112495 + const_gimple def_stmt;
112496 +
112497 + if (TREE_CODE(lhs) != SSA_NAME) {
112498 + insert_last_node(cur_node, lhs);
112499 + return;
112500 + }
112501 +
112502 + def_stmt = get_def_stmt(lhs);
112503 + if (!def_stmt)
112504 + return;
112505 +
112506 + if (pointer_set_insert(visited, def_stmt))
112507 + return;
112508 +
112509 + switch (gimple_code(def_stmt)) {
112510 + case GIMPLE_NOP:
112511 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112512 + case GIMPLE_ASM:
112513 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
112514 + case GIMPLE_CALL: {
112515 + tree fndecl = gimple_call_fndecl(def_stmt);
112516 +
112517 + if (fndecl == NULL_TREE)
112518 + return;
112519 + insert_last_node(cur_node, fndecl);
112520 + return;
112521 + }
112522 + case GIMPLE_PHI:
112523 + return walk_use_def_phi(visited, cur_node, lhs);
112524 + case GIMPLE_ASSIGN:
112525 + switch (gimple_num_ops(def_stmt)) {
112526 + case 2:
112527 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
112528 + case 3:
112529 + return walk_use_def_binary(visited, cur_node, lhs);
112530 + }
112531 + default:
112532 + debug_gimple_stmt((gimple)def_stmt);
112533 + error("%s: unknown gimple code", __func__);
112534 + gcc_unreachable();
112535 + }
112536 +}
112537 +
112538 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
112539 +static void set_last_nodes(struct interesting_node *cur_node)
112540 +{
112541 + struct pointer_set_t *visited;
112542 +
112543 + visited = pointer_set_create();
112544 + walk_use_def(visited, cur_node, cur_node->node);
112545 + pointer_set_destroy(visited);
112546 +}
112547 +
112548 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
112549 + * 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
112550 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
112551 + * 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.
112552 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
112553 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
112554 + * 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.
112555 + */
112556 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
112557 +{
112558 + struct pointer_set_t *visited;
112559 + bool interesting_conditions[3] = {false, false, false};
112560 + tree new_node, orig_node = cur_node->node;
112561 +
112562 + set_last_nodes(cur_node);
112563 +
112564 + check_intentional_attribute_ipa(cur_node);
112565 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
112566 + return cnodes;
112567 +
112568 + search_interesting_conditions(orig_node, interesting_conditions);
112569 +
112570 + // error code
112571 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
112572 + return cnodes;
112573 +
112574 + cnodes = search_overflow_attribute(cnodes, cur_node);
112575 +
112576 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
112577 + return cnodes;
112578 +
112579 + // unnecessary overflow check
112580 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
112581 + return cnodes;
112582 +
112583 + visited = pointer_set_create();
112584 + new_node = expand(visited, caller_node, orig_node);
112585 + pointer_set_destroy(visited);
112586 +
112587 + if (new_node == NULL_TREE)
112588 + return cnodes;
112589 +
112590 + change_orig_node(cur_node, new_node);
112591 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
112592 +
112593 + return cnodes;
112594 +}
112595 +
112596 +// Check visited interesting nodes.
112597 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
112598 +{
112599 + struct interesting_node *cur;
112600 +
112601 + for (cur = head; cur; cur = cur->next) {
112602 + if (!operand_equal_p(node, cur->node, 0))
112603 + continue;
112604 + if (num != cur->num)
112605 + continue;
112606 + if (first_stmt == cur->first_stmt)
112607 + return true;
112608 + }
112609 + return false;
112610 +}
112611 +
112612 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
112613 + 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
112614 + 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
112615 + the intentional_overflow attribute check. They are collected by set_last_nodes().
112616 + num: arg count of a call stmt or 0 when it is a ret
112617 + node: the recursion starts from here, it is a call arg or a return value
112618 + 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.
112619 + intentional_attr_decl: intentional_overflow attribute of the callee function
112620 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
112621 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
112622 + */
112623 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
112624 +{
112625 + struct interesting_node *new_node;
112626 + tree fndecl;
112627 + enum gimple_code code;
112628 +
112629 + gcc_assert(node != NULL_TREE);
112630 + code = gimple_code(first_stmt);
112631 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
112632 +
112633 + if (num == CANNOT_FIND_ARG)
112634 + return head;
112635 +
112636 + if (skip_types(node))
112637 + return head;
112638 +
112639 + if (skip_asm(node))
112640 + return head;
112641 +
112642 + if (is_gimple_call(first_stmt))
112643 + fndecl = gimple_call_fndecl(first_stmt);
112644 + else
112645 + fndecl = current_function_decl;
112646 +
112647 + if (fndecl == NULL_TREE)
112648 + return head;
112649 +
112650 + if (is_in_interesting_node(head, first_stmt, node, num))
112651 + return head;
112652 +
112653 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
112654 +
112655 + new_node->next = NULL;
112656 + new_node->first_stmt = first_stmt;
112657 +#if BUILDING_GCC_VERSION <= 4007
112658 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
112659 +#else
112660 + vec_alloc(new_node->last_nodes, VEC_LEN);
112661 +#endif
112662 + new_node->num = num;
112663 + new_node->node = node;
112664 + new_node->fndecl = fndecl;
112665 + new_node->intentional_attr_decl = MARK_NO;
112666 + new_node->intentional_attr_cur_fndecl = MARK_NO;
112667 + new_node->intentional_mark_from_gimple = asm_stmt;
112668 +
112669 + if (!head)
112670 + return new_node;
112671 +
112672 + new_node->next = head;
112673 + return new_node;
112674 +}
112675 +
112676 +/* 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).
112677 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
112678 + */
112679 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112680 +{
112681 + struct next_cgraph_node *cur_node;
112682 + tree ret = gimple_return_retval(stmt);
112683 +
112684 + if (ret == NULL_TREE)
112685 + return head;
112686 +
112687 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112688 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
112689 + continue;
112690 + if (cur_node->num == 0)
112691 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
112692 + }
112693 +
112694 + return head;
112695 +}
112696 +
112697 +/* 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).
112698 + * If the call stmt is in the next cgraph node list then it's an interesting call.
112699 + */
112700 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112701 +{
112702 + unsigned int argnum;
112703 + tree fndecl, arg;
112704 + struct next_cgraph_node *cur_node;
112705 +
112706 + fndecl = gimple_call_fndecl(stmt);
112707 + if (fndecl == NULL_TREE)
112708 + return head;
112709 +
112710 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112711 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
112712 + continue;
112713 + argnum = get_correct_arg_count(cur_node->num, fndecl);
112714 + gcc_assert(argnum != CANNOT_FIND_ARG);
112715 + if (argnum == 0)
112716 + continue;
112717 +
112718 + arg = gimple_call_arg(stmt, argnum - 1);
112719 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
112720 + }
112721 +
112722 + return head;
112723 +}
112724 +
112725 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
112726 +{
112727 + if (!operand_equal_p(orig_node, node, 0))
112728 + return WRONG_NODE;
112729 + if (skip_types(node))
112730 + return WRONG_NODE;
112731 + return ret_count;
112732 +}
112733 +
112734 +// Get the index of the rhs node in an assignment
112735 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
112736 +{
112737 + const_tree rhs1, rhs2;
112738 + unsigned int ret;
112739 +
112740 + gcc_assert(stmt);
112741 + gcc_assert(is_gimple_assign(stmt));
112742 +
112743 + rhs1 = gimple_assign_rhs1(stmt);
112744 + gcc_assert(rhs1 != NULL_TREE);
112745 +
112746 + switch (gimple_num_ops(stmt)) {
112747 + case 2:
112748 + return check_ops(node, rhs1, 1);
112749 + case 3:
112750 + ret = check_ops(node, rhs1, 1);
112751 + if (ret != WRONG_NODE)
112752 + return ret;
112753 +
112754 + rhs2 = gimple_assign_rhs2(stmt);
112755 + gcc_assert(rhs2 != NULL_TREE);
112756 + return check_ops(node, rhs2, 2);
112757 + default:
112758 + gcc_unreachable();
112759 + }
112760 +}
112761 +
112762 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
112763 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
112764 +{
112765 + unsigned int i;
112766 +
112767 + if (gimple_call_fndecl(stmt) == NULL_TREE)
112768 + return CANNOT_FIND_ARG;
112769 +
112770 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
112771 + tree node;
112772 +
112773 + node = gimple_call_arg(stmt, i);
112774 + if (!operand_equal_p(arg, node, 0))
112775 + continue;
112776 + if (!skip_types(node))
112777 + return i + 1;
112778 + }
112779 +
112780 + return CANNOT_FIND_ARG;
112781 +}
112782 +
112783 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
112784 + * any of return, call or assignment stmts (because of inlining).
112785 + */
112786 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
112787 +{
112788 + use_operand_p use_p;
112789 + imm_use_iterator imm_iter;
112790 + unsigned int argnum;
112791 +
112792 + if (is_size_overflow_intentional_asm_turn_off(intentional_asm))
112793 + return head;
112794 +
112795 + gcc_assert(TREE_CODE(node) == SSA_NAME);
112796 +
112797 + if (pointer_set_insert(visited, node))
112798 + return head;
112799 +
112800 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112801 + gimple stmt = USE_STMT(use_p);
112802 +
112803 + if (stmt == NULL)
112804 + return head;
112805 + if (is_gimple_debug(stmt))
112806 + continue;
112807 +
112808 + switch (gimple_code(stmt)) {
112809 + case GIMPLE_CALL:
112810 + argnum = find_arg_number_gimple(node, stmt);
112811 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112812 + break;
112813 + case GIMPLE_RETURN:
112814 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
112815 + break;
112816 + case GIMPLE_ASSIGN:
112817 + argnum = get_assign_ops_count(stmt, node);
112818 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112819 + break;
112820 + case GIMPLE_PHI: {
112821 + tree result = gimple_phi_result(stmt);
112822 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
112823 + break;
112824 + }
112825 + case GIMPLE_ASM:
112826 + if (gimple_asm_noutputs(stmt) != 0)
112827 + break;
112828 + if (!is_size_overflow_asm(stmt))
112829 + break;
112830 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
112831 + break;
112832 + case GIMPLE_COND:
112833 + case GIMPLE_SWITCH:
112834 + break;
112835 + default:
112836 + debug_gimple_stmt(stmt);
112837 + gcc_unreachable();
112838 + break;
112839 + }
112840 + }
112841 + return head;
112842 +}
112843 +
112844 +static void remove_size_overflow_asm(gimple stmt)
112845 +{
112846 + gimple_stmt_iterator gsi;
112847 +
112848 + gcc_assert(gimple_code(stmt) == GIMPLE_ASM);
112849 + gsi = gsi_for_stmt(stmt);
112850 + gsi_remove(&gsi, true);
112851 +}
112852 +
112853 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
112854 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
112855 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
112856 + */
112857 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
112858 +{
112859 + const_tree output, input;
112860 + struct pointer_set_t *visited;
112861 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
112862 +
112863 + if (!is_size_overflow_asm(stmt))
112864 + return head;
112865 +
112866 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
112867 + intentional_asm = stmt;
112868 +
112869 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
112870 + input = gimple_asm_input_op(stmt, 0);
112871 +
112872 + if (gimple_asm_noutputs(stmt) == 0) {
112873 + remove_size_overflow_asm(stmt);
112874 + if (is_gimple_constant(TREE_VALUE(input)))
112875 + return head;
112876 +
112877 + visited = pointer_set_create();
112878 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
112879 + pointer_set_destroy(visited);
112880 + return head;
112881 + }
112882 +
112883 + output = gimple_asm_output_op(stmt, 0);
112884 +
112885 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
112886 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
112887 +
112888 + visited = pointer_set_create();
112889 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
112890 + pointer_set_destroy(visited);
112891 + return head;
112892 +}
112893 +
112894 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
112895 + * or a call stmt or a return stmt and store them in the interesting_node list
112896 + */
112897 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
112898 +{
112899 + basic_block bb;
112900 + struct interesting_node *head = NULL;
112901 +
112902 + FOR_ALL_BB(bb) {
112903 + gimple_stmt_iterator gsi;
112904 +
112905 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
112906 + enum gimple_code code;
112907 + gimple stmt = gsi_stmt(gsi);
112908 +
112909 + code = gimple_code(stmt);
112910 +
112911 + if (code == GIMPLE_ASM)
112912 + head = handle_stmt_by_size_overflow_asm(stmt, head);
112913 +
112914 + if (!next_node)
112915 + continue;
112916 + if (code == GIMPLE_CALL)
112917 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
112918 + if (code == GIMPLE_RETURN)
112919 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
112920 + }
112921 + }
112922 + return head;
112923 +}
112924 +
112925 +static void set_current_function_decl(tree fndecl)
112926 +{
112927 + gcc_assert(fndecl != NULL_TREE);
112928 +
112929 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
112930 + calculate_dominance_info(CDI_DOMINATORS);
112931 + current_function_decl = fndecl;
112932 +}
112933 +
112934 +static void unset_current_function_decl(void)
112935 +{
112936 + free_dominance_info(CDI_DOMINATORS);
112937 + pop_cfun();
112938 + current_function_decl = NULL_TREE;
112939 +}
112940 +
112941 +static void free_interesting_node(struct interesting_node *head)
112942 +{
112943 + struct interesting_node *cur;
112944 +
112945 + while (head) {
112946 + cur = head->next;
112947 +#if BUILDING_GCC_VERSION <= 4007
112948 + VEC_free(tree, gc, head->last_nodes);
112949 +#else
112950 + vec_free(head->last_nodes);
112951 +#endif
112952 + free(head);
112953 + head = cur;
112954 + }
112955 +}
112956 +
112957 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
112958 +{
112959 + struct visited *new_visited;
112960 +
112961 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
112962 + new_visited->fndecl = cur_node->fndecl;
112963 + new_visited->num = cur_node->num;
112964 + new_visited->first_stmt = cur_node->first_stmt;
112965 + new_visited->next = NULL;
112966 +
112967 + if (!head)
112968 + return new_visited;
112969 +
112970 + new_visited->next = head;
112971 + return new_visited;
112972 +}
112973 +
112974 +/* 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
112975 + * it is a visited function.
112976 + */
112977 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
112978 +{
112979 + struct visited *cur;
112980 +
112981 + if (!head)
112982 + return false;
112983 +
112984 + for (cur = head; cur; cur = cur->next) {
112985 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
112986 + continue;
112987 + if (cur_node->num != cur->num)
112988 + continue;
112989 + if (cur_node->first_stmt == cur->first_stmt)
112990 + return true;
112991 + }
112992 + return false;
112993 +}
112994 +
112995 +static void free_next_cgraph_node(struct next_cgraph_node *head)
112996 +{
112997 + struct next_cgraph_node *cur;
112998 +
112999 + while (head) {
113000 + cur = head->next;
113001 + free(head);
113002 + head = cur;
113003 + }
113004 +}
113005 +
113006 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
113007 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
113008 + * the newly collected interesting functions (they are interesting if there is control flow between
113009 + * the interesting stmts and them).
113010 + */
113011 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
113012 +{
113013 + struct interesting_node *head, *cur_node;
113014 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
113015 +
113016 +#if BUILDING_GCC_VERSION <= 4007
113017 + set_current_function_decl(node->decl);
113018 +#else
113019 + set_current_function_decl(node->symbol.decl);
113020 +#endif
113021 + call_count = 0;
113022 +
113023 + head = collect_interesting_stmts(next_node);
113024 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
113025 + if (is_visited_function(visited, cur_node))
113026 + continue;
113027 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
113028 + visited = insert_visited_function(visited, cur_node);
113029 + }
113030 +
113031 + free_interesting_node(head);
113032 + unset_current_function_decl();
113033 +
113034 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
113035 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
113036 +
113037 + free_next_cgraph_node(cnodes_head);
113038 + return visited;
113039 +}
113040 +
113041 +static void free_visited(struct visited *head)
113042 +{
113043 + struct visited *cur;
113044 +
113045 + while (head) {
113046 + cur = head->next;
113047 + free(head);
113048 + head = cur;
113049 + }
113050 +}
113051 +
113052 +// erase the local flag
113053 +static void set_plf_false(void)
113054 +{
113055 + basic_block bb;
113056 +
113057 + FOR_ALL_BB(bb) {
113058 + gimple_stmt_iterator si;
113059 +
113060 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113061 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113062 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113063 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113064 + }
113065 +}
113066 +
113067 +#if BUILDING_GCC_VERSION <= 4006
113068 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
113069 +{
113070 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
113071 +}
113072 +
113073 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
113074 +{
113075 + struct cgraph_node *node;
113076 +
113077 + for (node = cgraph_nodes; node; node = node->next) {
113078 + if (cgraph_function_with_gimple_body_p(node))
113079 + return node;
113080 + }
113081 + return NULL;
113082 +}
113083 +
113084 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
113085 +{
113086 + for (node = node->next; node; node = node->next) {
113087 + if (cgraph_function_with_gimple_body_p(node))
113088 + return node;
113089 + }
113090 + return NULL;
113091 +}
113092 +
113093 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
113094 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
113095 + (node) = cgraph_next_function_with_gimple_body (node))
113096 +
113097 +#endif
113098 +
113099 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
113100 +static unsigned int search_function(void)
113101 +{
113102 + struct cgraph_node *node;
113103 + struct visited *visited = NULL;
113104 +
113105 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113106 +#if BUILDING_GCC_VERSION <= 4007
113107 + set_current_function_decl(node->decl);
113108 +#else
113109 + set_current_function_decl(node->symbol.decl);
113110 +#endif
113111 + set_plf_false();
113112 + unset_current_function_decl();
113113 + }
113114 +
113115 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113116 + gcc_assert(cgraph_function_flags_ready);
113117 +#if BUILDING_GCC_VERSION <= 4007
113118 + gcc_assert(node->reachable);
113119 +#endif
113120 +
113121 + visited = handle_function(node, NULL, visited);
113122 + }
113123 +
113124 + free_visited(visited);
113125 + return 0;
113126 +}
113127 +
113128 +static struct ipa_opt_pass_d pass_ipa = {
113129 + .pass = {
113130 + .type = SIMPLE_IPA_PASS,
113131 + .name = "size_overflow",
113132 +#if BUILDING_GCC_VERSION >= 4008
113133 + .optinfo_flags = OPTGROUP_NONE,
113134 +#endif
113135 + .gate = NULL,
113136 + .execute = search_function,
113137 + .sub = NULL,
113138 + .next = NULL,
113139 + .static_pass_number = 0,
113140 + .tv_id = TV_NONE,
113141 + .properties_required = 0,
113142 + .properties_provided = 0,
113143 + .properties_destroyed = 0,
113144 + .todo_flags_start = 0,
113145 + .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,
113146 + },
113147 + .generate_summary = NULL,
113148 + .write_summary = NULL,
113149 + .read_summary = NULL,
113150 +#if BUILDING_GCC_VERSION >= 4006
113151 + .write_optimization_summary = NULL,
113152 + .read_optimization_summary = NULL,
113153 +#endif
113154 + .stmt_fixup = NULL,
113155 + .function_transform_todo_flags_start = 0,
113156 + .function_transform = NULL,
113157 + .variable_transform = NULL,
113158 +};
113159 +
113160 +// data for the size_overflow asm stmt
113161 +struct asm_data {
113162 + gimple def_stmt;
113163 + tree input;
113164 + tree output;
113165 +};
113166 +
113167 +#if BUILDING_GCC_VERSION <= 4007
113168 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
113169 +#else
113170 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
113171 +#endif
113172 +{
113173 + tree list;
113174 +#if BUILDING_GCC_VERSION <= 4007
113175 + VEC(tree, gc) *vec_list = NULL;
113176 +#else
113177 + vec<tree, va_gc> *vec_list = NULL;
113178 +#endif
113179 +
113180 + list = build_tree_list(NULL_TREE, string);
113181 + list = chainon(NULL_TREE, build_tree_list(list, io));
113182 +#if BUILDING_GCC_VERSION <= 4007
113183 + VEC_safe_push(tree, gc, vec_list, list);
113184 +#else
113185 + vec_safe_push(vec_list, list);
113186 +#endif
113187 + return vec_list;
113188 +}
113189 +
113190 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
113191 +{
113192 + gimple asm_stmt;
113193 + gimple_stmt_iterator gsi;
113194 +#if BUILDING_GCC_VERSION <= 4007
113195 + VEC(tree, gc) *input, *output = NULL;
113196 +#else
113197 + vec<tree, va_gc> *input, *output = NULL;
113198 +#endif
113199 +
113200 + input = create_asm_io_list(str_input, asm_data->input);
113201 +
113202 + if (asm_data->output)
113203 + output = create_asm_io_list(str_output, asm_data->output);
113204 +
113205 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
113206 + gsi = gsi_for_stmt(asm_data->def_stmt);
113207 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
113208 +
113209 + if (asm_data->output)
113210 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
113211 +}
113212 +
113213 +static void replace_call_lhs(const struct asm_data *asm_data)
113214 +{
113215 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
113216 + update_stmt(asm_data->def_stmt);
113217 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
113218 +}
113219 +
113220 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
113221 +{
113222 + enum mark cur_fndecl_attr;
113223 + gimple phi = get_def_stmt(result);
113224 + unsigned int i, n = gimple_phi_num_args(phi);
113225 +
113226 + pointer_set_insert(visited, phi);
113227 + for (i = 0; i < n; i++) {
113228 + tree arg = gimple_phi_arg_def(phi, i);
113229 +
113230 + cur_fndecl_attr = search_intentional(visited, arg);
113231 + if (cur_fndecl_attr != MARK_NO)
113232 + return cur_fndecl_attr;
113233 + }
113234 + return MARK_NO;
113235 +}
113236 +
113237 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
113238 +{
113239 + enum mark cur_fndecl_attr;
113240 + const_tree rhs1, rhs2;
113241 + gimple def_stmt = get_def_stmt(lhs);
113242 +
113243 + rhs1 = gimple_assign_rhs1(def_stmt);
113244 + rhs2 = gimple_assign_rhs2(def_stmt);
113245 +
113246 + cur_fndecl_attr = search_intentional(visited, rhs1);
113247 + if (cur_fndecl_attr != MARK_NO)
113248 + return cur_fndecl_attr;
113249 + return search_intentional(visited, rhs2);
113250 +}
113251 +
113252 +// Look up the intentional_overflow attribute on the caller and the callee functions.
113253 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
113254 +{
113255 + const_gimple def_stmt;
113256 +
113257 + if (TREE_CODE(lhs) != SSA_NAME)
113258 + return get_intentional_attr_type(lhs);
113259 +
113260 + def_stmt = get_def_stmt(lhs);
113261 + if (!def_stmt)
113262 + return MARK_NO;
113263 +
113264 + if (pointer_set_contains(visited, def_stmt))
113265 + return MARK_NO;
113266 +
113267 + switch (gimple_code(def_stmt)) {
113268 + case GIMPLE_NOP:
113269 + return search_intentional(visited, SSA_NAME_VAR(lhs));
113270 + case GIMPLE_ASM:
113271 + case GIMPLE_CALL:
113272 + return MARK_NO;
113273 + case GIMPLE_PHI:
113274 + return search_intentional_phi(visited, lhs);
113275 + case GIMPLE_ASSIGN:
113276 + switch (gimple_num_ops(def_stmt)) {
113277 + case 2:
113278 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
113279 + case 3:
113280 + return search_intentional_binary(visited, lhs);
113281 + }
113282 + case GIMPLE_RETURN:
113283 + return MARK_NO;
113284 + default:
113285 + debug_gimple_stmt((gimple)def_stmt);
113286 + error("%s: unknown gimple code", __func__);
113287 + gcc_unreachable();
113288 + }
113289 +}
113290 +
113291 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
113292 +static const char *check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
113293 +{
113294 + const_tree fndecl;
113295 + const char *asm_str;
113296 + struct pointer_set_t *visited;
113297 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
113298 +
113299 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
113300 + if (is_end_intentional_intentional_attr(fndecl, argnum))
113301 + decl_attr = MARK_NOT_INTENTIONAL;
113302 + else if (is_yes_intentional_attr(fndecl, argnum))
113303 + decl_attr = MARK_YES;
113304 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113305 + return "# size_overflow MARK_TURN_OFF\n\t";
113306 + }
113307 +
113308 + visited = pointer_set_create();
113309 + cur_fndecl_attr = search_intentional(visited, arg);
113310 + pointer_set_destroy(visited);
113311 +
113312 + switch (cur_fndecl_attr) {
113313 + case MARK_NO:
113314 + asm_str = "# size_overflow\n\t";
113315 + break;
113316 + case MARK_TURN_OFF:
113317 + asm_str = "# size_overflow MARK_TURN_OFF\n\t";
113318 + break;
113319 + default:
113320 + asm_str = "# size_overflow MARK_YES\n\t";
113321 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
113322 + break;
113323 + }
113324 +
113325 + return asm_str;
113326 +}
113327 +
113328 +static void check_missing_size_overflow_attribute(tree var)
113329 +{
113330 + tree orig_fndecl;
113331 + unsigned int num;
113332 +
113333 + if (is_a_return_check(var))
113334 + orig_fndecl = DECL_ORIGIN(var);
113335 + else
113336 + orig_fndecl = DECL_ORIGIN(current_function_decl);
113337 +
113338 + num = get_function_num(var, orig_fndecl);
113339 + if (num == CANNOT_FIND_ARG)
113340 + return;
113341 +
113342 + is_missing_function(orig_fndecl, num);
113343 +}
113344 +
113345 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
113346 +{
113347 + gimple phi = get_def_stmt(result);
113348 + unsigned int i, n = gimple_phi_num_args(phi);
113349 +
113350 + pointer_set_insert(visited, phi);
113351 + for (i = 0; i < n; i++) {
113352 + tree arg = gimple_phi_arg_def(phi, i);
113353 +
113354 + search_size_overflow_attribute(visited, arg);
113355 + }
113356 +}
113357 +
113358 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
113359 +{
113360 + const_gimple def_stmt = get_def_stmt(lhs);
113361 + tree rhs1, rhs2;
113362 +
113363 + rhs1 = gimple_assign_rhs1(def_stmt);
113364 + rhs2 = gimple_assign_rhs2(def_stmt);
113365 +
113366 + search_size_overflow_attribute(visited, rhs1);
113367 + search_size_overflow_attribute(visited, rhs2);
113368 +}
113369 +
113370 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
113371 +{
113372 + const_gimple def_stmt;
113373 +
113374 + if (TREE_CODE(lhs) == PARM_DECL) {
113375 + check_missing_size_overflow_attribute(lhs);
113376 + return;
113377 + }
113378 +
113379 + def_stmt = get_def_stmt(lhs);
113380 + if (!def_stmt)
113381 + return;
113382 +
113383 + if (pointer_set_insert(visited, def_stmt))
113384 + return;
113385 +
113386 + switch (gimple_code(def_stmt)) {
113387 + case GIMPLE_NOP:
113388 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
113389 + case GIMPLE_ASM:
113390 + return;
113391 + case GIMPLE_CALL: {
113392 + tree fndecl = gimple_call_fndecl(def_stmt);
113393 +
113394 + if (fndecl == NULL_TREE)
113395 + return;
113396 + check_missing_size_overflow_attribute(fndecl);
113397 + return;
113398 + }
113399 + case GIMPLE_PHI:
113400 + return search_size_overflow_attribute_phi(visited, lhs);
113401 + case GIMPLE_ASSIGN:
113402 + switch (gimple_num_ops(def_stmt)) {
113403 + case 2:
113404 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
113405 + case 3:
113406 + return search_size_overflow_attribute_binary(visited, lhs);
113407 + }
113408 + default:
113409 + debug_gimple_stmt((gimple)def_stmt);
113410 + error("%s: unknown gimple code", __func__);
113411 + gcc_unreachable();
113412 + }
113413 +}
113414 +
113415 +// Search missing entries in the hash table (invoked from the gimple pass)
113416 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
113417 +{
113418 + tree fndecl = NULL_TREE;
113419 + tree lhs;
113420 + struct pointer_set_t *visited;
113421 +
113422 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
113423 + return;
113424 +
113425 + if (num == 0) {
113426 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
113427 + lhs = gimple_return_retval(stmt);
113428 + } else {
113429 + gcc_assert(is_gimple_call(stmt));
113430 + lhs = gimple_call_arg(stmt, num - 1);
113431 + fndecl = gimple_call_fndecl(stmt);
113432 + }
113433 +
113434 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
113435 + return;
113436 +
113437 + visited = pointer_set_create();
113438 + search_size_overflow_attribute(visited, lhs);
113439 + pointer_set_destroy(visited);
113440 +}
113441 +
113442 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113443 +{
113444 + gimple_stmt_iterator gsi;
113445 + gimple assign;
113446 +
113447 + assign = gimple_build_assign(asm_data->input, asm_data->output);
113448 + gsi = gsi_for_stmt(stmt);
113449 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
113450 + asm_data->def_stmt = assign;
113451 +
113452 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
113453 + asm_data->output = make_ssa_name(asm_data->output, stmt);
113454 + if (gimple_code(stmt) == GIMPLE_RETURN)
113455 + gimple_return_set_retval(stmt, asm_data->output);
113456 + else
113457 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
113458 + update_stmt(stmt);
113459 +}
113460 +
113461 +/* Create the input of the size_overflow asm stmt.
113462 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
113463 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113464 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
113465 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
113466 + */
113467 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113468 +{
113469 + if (!asm_data->def_stmt) {
113470 + asm_data->input = NULL_TREE;
113471 + return;
113472 + }
113473 +
113474 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
113475 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
113476 +
113477 + switch (gimple_code(asm_data->def_stmt)) {
113478 + case GIMPLE_ASSIGN:
113479 + case GIMPLE_CALL:
113480 + replace_call_lhs(asm_data);
113481 + break;
113482 + case GIMPLE_PHI:
113483 + create_output_from_phi(stmt, argnum, asm_data);
113484 + break;
113485 + case GIMPLE_NOP: {
113486 + const char *str = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
113487 +
113488 + asm_data->input = asm_data->output;
113489 + asm_data->output = NULL;
113490 + asm_data->def_stmt = stmt;
113491 +
113492 + create_asm_stmt(str, build_string(2, "rm"), NULL, asm_data);
113493 + asm_data->input = NULL_TREE;
113494 + break;
113495 + }
113496 + case GIMPLE_ASM:
113497 + if (is_size_overflow_asm(asm_data->def_stmt)) {
113498 + asm_data->input = NULL_TREE;
113499 + break;
113500 + }
113501 + default:
113502 + debug_gimple_stmt(asm_data->def_stmt);
113503 + gcc_unreachable();
113504 + }
113505 +}
113506 +
113507 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
113508 + * is of the right kind create the appropriate size_overflow asm stmts:
113509 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
113510 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113511 + */
113512 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
113513 +{
113514 + struct asm_data asm_data;
113515 + const char *str;
113516 +
113517 + if (is_gimple_constant(output_node))
113518 + return;
113519 +
113520 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
113521 +
113522 + asm_data.output = output_node;
113523 + asm_data.def_stmt = get_def_stmt(asm_data.output);
113524 + create_asm_input(stmt, argnum, &asm_data);
113525 + if (asm_data.input == NULL_TREE)
113526 + return;
113527 +
113528 + str = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
113529 + create_asm_stmt(str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
113530 +}
113531 +
113532 +// Determine the return value and insert the asm stmt to mark the return stmt.
113533 +static void insert_asm_ret(gimple stmt)
113534 +{
113535 + tree ret;
113536 +
113537 + ret = gimple_return_retval(stmt);
113538 + create_size_overflow_asm(stmt, ret, 0);
113539 +}
113540 +
113541 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
113542 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
113543 +{
113544 + tree arg;
113545 + unsigned int argnum;
113546 +
113547 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
113548 + gcc_assert(argnum != 0);
113549 + if (argnum == CANNOT_FIND_ARG)
113550 + return;
113551 +
113552 + arg = gimple_call_arg(stmt, argnum - 1);
113553 + gcc_assert(arg != NULL_TREE);
113554 + create_size_overflow_asm(stmt, arg, argnum);
113555 +}
113556 +
113557 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
113558 +static void set_argnum_attribute(const_tree attr, bool *argnums)
113559 +{
113560 + unsigned int argnum;
113561 + tree attr_value;
113562 +
113563 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
113564 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
113565 + argnums[argnum] = true;
113566 + }
113567 +}
113568 +
113569 +// If a function arg or the return value is in the hash table then set its index in the array.
113570 +static void set_argnum_hash(tree fndecl, bool *argnums)
113571 +{
113572 + unsigned int num;
113573 + const struct size_overflow_hash *hash;
113574 +
113575 + hash = get_function_hash(DECL_ORIGIN(fndecl));
113576 + if (!hash)
113577 + return;
113578 +
113579 + for (num = 0; num <= MAX_PARAM; num++) {
113580 + if (!(hash->param & (1U << num)))
113581 + continue;
113582 +
113583 + argnums[num] = true;
113584 + }
113585 +}
113586 +
113587 +static bool is_all_the_argnums_empty(bool *argnums)
113588 +{
113589 + unsigned int i;
113590 +
113591 + for (i = 0; i <= MAX_PARAM; i++)
113592 + if (argnums[i])
113593 + return false;
113594 + return true;
113595 +}
113596 +
113597 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
113598 +static void search_interesting_args(tree fndecl, bool *argnums)
113599 +{
113600 + const_tree attr;
113601 +
113602 + set_argnum_hash(fndecl, argnums);
113603 + if (!is_all_the_argnums_empty(argnums))
113604 + return;
113605 +
113606 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
113607 + if (attr && TREE_VALUE(attr))
113608 + set_argnum_attribute(attr, argnums);
113609 +}
113610 +
113611 +/*
113612 + * Look up the intentional_overflow attribute that turns off ipa based duplication
113613 + * on the callee function, if found insert an asm stmt with "MARK_TURN_OFF".
113614 + */
113615 +static bool create_mark_turn_off_asm(gimple stmt)
113616 +{
113617 + enum mark mark;
113618 + struct asm_data asm_data;
113619 + const_tree fndecl = gimple_call_fndecl(stmt);
113620 +
113621 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
113622 + if (mark != MARK_TURN_OFF)
113623 + return false;
113624 +
113625 + asm_data.input = gimple_call_lhs(stmt);
113626 + if (asm_data.input == NULL_TREE) {
113627 + asm_data.input = gimple_call_arg(stmt, 0);
113628 + if (is_gimple_constant(asm_data.input))
113629 + return false;
113630 + }
113631 +
113632 + asm_data.output = NULL;
113633 + asm_data.def_stmt = stmt;
113634 + create_asm_stmt("# size_overflow MARK_TURN_OFF\n\t", build_string(2, "rm"), NULL, &asm_data);
113635 + return true;
113636 +}
113637 +
113638 +// 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
113639 +static void handle_interesting_function(gimple stmt)
113640 +{
113641 + unsigned int argnum;
113642 + tree fndecl;
113643 + bool orig_argnums[MAX_PARAM + 1] = {false};
113644 +
113645 + if (gimple_call_num_args(stmt) == 0)
113646 + return;
113647 + fndecl = gimple_call_fndecl(stmt);
113648 + if (fndecl == NULL_TREE)
113649 + return;
113650 + fndecl = DECL_ORIGIN(fndecl);
113651 +
113652 + if (create_mark_turn_off_asm(stmt))
113653 + return;
113654 +
113655 + search_interesting_args(fndecl, orig_argnums);
113656 +
113657 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
113658 + if (orig_argnums[argnum])
113659 + insert_asm_arg(stmt, argnum);
113660 +}
113661 +
113662 +// 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
113663 +static void handle_interesting_ret(gimple stmt)
113664 +{
113665 + bool orig_argnums[MAX_PARAM + 1] = {false};
113666 +
113667 + search_interesting_args(current_function_decl, orig_argnums);
113668 +
113669 + if (orig_argnums[0])
113670 + insert_asm_ret(stmt);
113671 +}
113672 +
113673 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
113674 +static unsigned int search_interesting_functions(void)
113675 +{
113676 + basic_block bb;
113677 +
113678 + FOR_ALL_BB(bb) {
113679 + gimple_stmt_iterator gsi;
113680 +
113681 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
113682 + gimple stmt = gsi_stmt(gsi);
113683 +
113684 + if (is_gimple_call(stmt))
113685 + handle_interesting_function(stmt);
113686 + else if (gimple_code(stmt) == GIMPLE_RETURN)
113687 + handle_interesting_ret(stmt);
113688 + }
113689 + }
113690 + return 0;
113691 +}
113692 +
113693 +/*
113694 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
113695 + * this pass inserts asm stmts to mark the interesting args
113696 + * that the ipa pass will detect and insert the size overflow checks for.
113697 + */
113698 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
113699 + .pass = {
113700 + .type = GIMPLE_PASS,
113701 + .name = "insert_size_overflow_asm",
113702 +#if BUILDING_GCC_VERSION >= 4008
113703 + .optinfo_flags = OPTGROUP_NONE,
113704 +#endif
113705 + .gate = NULL,
113706 + .execute = search_interesting_functions,
113707 + .sub = NULL,
113708 + .next = NULL,
113709 + .static_pass_number = 0,
113710 + .tv_id = TV_NONE,
113711 + .properties_required = PROP_cfg,
113712 + .properties_provided = 0,
113713 + .properties_destroyed = 0,
113714 + .todo_flags_start = 0,
113715 + .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
113716 + }
113717 +};
113718 +
113719 +// Create the noreturn report_size_overflow() function decl.
113720 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
113721 +{
113722 + tree fntype;
113723 +
113724 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
113725 +
113726 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
113727 + fntype = build_function_type_list(void_type_node,
113728 + const_char_ptr_type_node,
113729 + unsigned_type_node,
113730 + const_char_ptr_type_node,
113731 + const_char_ptr_type_node,
113732 + NULL_TREE);
113733 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
113734 +
113735 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
113736 + TREE_PUBLIC(report_size_overflow_decl) = 1;
113737 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
113738 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
113739 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
113740 +}
113741 +
113742 +static unsigned int dump_functions(void)
113743 +{
113744 + struct cgraph_node *node;
113745 +
113746 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113747 + basic_block bb;
113748 +
113749 +#if BUILDING_GCC_VERSION <= 4007
113750 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
113751 + current_function_decl = node->decl;
113752 +#else
113753 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
113754 + current_function_decl = node->symbol.decl;
113755 +#endif
113756 +
113757 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
113758 +
113759 + FOR_ALL_BB(bb) {
113760 + gimple_stmt_iterator si;
113761 +
113762 + fprintf(stderr, "<bb %u>:\n", bb->index);
113763 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113764 + debug_gimple_stmt(gsi_stmt(si));
113765 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113766 + debug_gimple_stmt(gsi_stmt(si));
113767 + fprintf(stderr, "\n");
113768 + }
113769 +
113770 + fprintf(stderr, "-------------------------------------------------------------------------\n");
113771 +
113772 + pop_cfun();
113773 + current_function_decl = NULL_TREE;
113774 + }
113775 +
113776 + fprintf(stderr, "###############################################################################\n");
113777 +
113778 + return 0;
113779 +}
113780 +
113781 +static struct ipa_opt_pass_d pass_dump = {
113782 + .pass = {
113783 + .type = SIMPLE_IPA_PASS,
113784 + .name = "dump",
113785 +#if BUILDING_GCC_VERSION >= 4008
113786 + .optinfo_flags = OPTGROUP_NONE,
113787 +#endif
113788 + .gate = NULL,
113789 + .execute = dump_functions,
113790 + .sub = NULL,
113791 + .next = NULL,
113792 + .static_pass_number = 0,
113793 + .tv_id = TV_NONE,
113794 + .properties_required = 0,
113795 + .properties_provided = 0,
113796 + .properties_destroyed = 0,
113797 + .todo_flags_start = 0,
113798 + .todo_flags_finish = 0,
113799 + },
113800 + .generate_summary = NULL,
113801 + .write_summary = NULL,
113802 + .read_summary = NULL,
113803 +#if BUILDING_GCC_VERSION >= 4006
113804 + .write_optimization_summary = NULL,
113805 + .read_optimization_summary = NULL,
113806 +#endif
113807 + .stmt_fixup = NULL,
113808 + .function_transform_todo_flags_start = 0,
113809 + .function_transform = NULL,
113810 + .variable_transform = NULL,
113811 +};
113812 +
113813 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
113814 +{
113815 + int i;
113816 + const char * const plugin_name = plugin_info->base_name;
113817 + const int argc = plugin_info->argc;
113818 + const struct plugin_argument * const argv = plugin_info->argv;
113819 + bool enable = true;
113820 +
113821 + struct register_pass_info insert_size_overflow_asm_pass_info = {
113822 + .pass = &insert_size_overflow_asm_pass.pass,
113823 + .reference_pass_name = "ssa",
113824 + .ref_pass_instance_number = 1,
113825 + .pos_op = PASS_POS_INSERT_AFTER
113826 + };
113827 +
113828 + struct register_pass_info __unused dump_before_pass_info = {
113829 + .pass = &pass_dump.pass,
113830 + .reference_pass_name = "increase_alignment",
113831 + .ref_pass_instance_number = 1,
113832 + .pos_op = PASS_POS_INSERT_BEFORE
113833 + };
113834 +
113835 + struct register_pass_info ipa_pass_info = {
113836 + .pass = &pass_ipa.pass,
113837 + .reference_pass_name = "increase_alignment",
113838 + .ref_pass_instance_number = 1,
113839 + .pos_op = PASS_POS_INSERT_BEFORE
113840 + };
113841 +
113842 + struct register_pass_info __unused dump_after_pass_info = {
113843 + .pass = &pass_dump.pass,
113844 + .reference_pass_name = "increase_alignment",
113845 + .ref_pass_instance_number = 1,
113846 + .pos_op = PASS_POS_INSERT_BEFORE
113847 + };
113848 +
113849 + if (!plugin_default_version_check(version, &gcc_version)) {
113850 + error(G_("incompatible gcc/plugin versions"));
113851 + return 1;
113852 + }
113853 +
113854 + for (i = 0; i < argc; ++i) {
113855 + if (!strcmp(argv[i].key, "no-size-overflow")) {
113856 + enable = false;
113857 + continue;
113858 + }
113859 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
113860 + }
113861 +
113862 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
113863 + if (enable) {
113864 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
113865 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
113866 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
113867 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
113868 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
113869 + }
113870 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
113871 +
113872 + return 0;
113873 +}
113874 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
113875 new file mode 100644
113876 index 0000000..ac2901e
113877 --- /dev/null
113878 +++ b/tools/gcc/stackleak_plugin.c
113879 @@ -0,0 +1,327 @@
113880 +/*
113881 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
113882 + * Licensed under the GPL v2
113883 + *
113884 + * Note: the choice of the license means that the compilation process is
113885 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
113886 + * but for the kernel it doesn't matter since it doesn't link against
113887 + * any of the gcc libraries
113888 + *
113889 + * gcc plugin to help implement various PaX features
113890 + *
113891 + * - track lowest stack pointer
113892 + *
113893 + * TODO:
113894 + * - initialize all local variables
113895 + *
113896 + * BUGS:
113897 + * - none known
113898 + */
113899 +#include "gcc-plugin.h"
113900 +#include "config.h"
113901 +#include "system.h"
113902 +#include "coretypes.h"
113903 +#include "tree.h"
113904 +#include "tree-pass.h"
113905 +#include "flags.h"
113906 +#include "intl.h"
113907 +#include "toplev.h"
113908 +#include "plugin.h"
113909 +//#include "expr.h" where are you...
113910 +#include "diagnostic.h"
113911 +#include "plugin-version.h"
113912 +#include "tm.h"
113913 +#include "function.h"
113914 +#include "basic-block.h"
113915 +#include "gimple.h"
113916 +#include "rtl.h"
113917 +#include "emit-rtl.h"
113918 +
113919 +#if BUILDING_GCC_VERSION >= 4008
113920 +#define TODO_dump_func 0
113921 +#endif
113922 +
113923 +extern void print_gimple_stmt(FILE *, gimple, int, int);
113924 +
113925 +int plugin_is_GPL_compatible;
113926 +
113927 +static int track_frame_size = -1;
113928 +static const char track_function[] = "pax_track_stack";
113929 +static const char check_function[] = "pax_check_alloca";
113930 +static bool init_locals;
113931 +
113932 +static struct plugin_info stackleak_plugin_info = {
113933 + .version = "201302112000",
113934 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
113935 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
113936 +};
113937 +
113938 +static bool gate_stackleak_track_stack(void);
113939 +static unsigned int execute_stackleak_tree_instrument(void);
113940 +static unsigned int execute_stackleak_final(void);
113941 +
113942 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
113943 + .pass = {
113944 + .type = GIMPLE_PASS,
113945 + .name = "stackleak_tree_instrument",
113946 +#if BUILDING_GCC_VERSION >= 4008
113947 + .optinfo_flags = OPTGROUP_NONE,
113948 +#endif
113949 + .gate = gate_stackleak_track_stack,
113950 + .execute = execute_stackleak_tree_instrument,
113951 + .sub = NULL,
113952 + .next = NULL,
113953 + .static_pass_number = 0,
113954 + .tv_id = TV_NONE,
113955 + .properties_required = PROP_gimple_leh | PROP_cfg,
113956 + .properties_provided = 0,
113957 + .properties_destroyed = 0,
113958 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
113959 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
113960 + }
113961 +};
113962 +
113963 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
113964 + .pass = {
113965 + .type = RTL_PASS,
113966 + .name = "stackleak_final",
113967 +#if BUILDING_GCC_VERSION >= 4008
113968 + .optinfo_flags = OPTGROUP_NONE,
113969 +#endif
113970 + .gate = gate_stackleak_track_stack,
113971 + .execute = execute_stackleak_final,
113972 + .sub = NULL,
113973 + .next = NULL,
113974 + .static_pass_number = 0,
113975 + .tv_id = TV_NONE,
113976 + .properties_required = 0,
113977 + .properties_provided = 0,
113978 + .properties_destroyed = 0,
113979 + .todo_flags_start = 0,
113980 + .todo_flags_finish = TODO_dump_func
113981 + }
113982 +};
113983 +
113984 +static bool gate_stackleak_track_stack(void)
113985 +{
113986 + return track_frame_size >= 0;
113987 +}
113988 +
113989 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
113990 +{
113991 + gimple check_alloca;
113992 + tree fntype, fndecl, alloca_size;
113993 +
113994 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
113995 + fndecl = build_fn_decl(check_function, fntype);
113996 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
113997 +
113998 + // insert call to void pax_check_alloca(unsigned long size)
113999 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
114000 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
114001 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
114002 +}
114003 +
114004 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
114005 +{
114006 + gimple track_stack;
114007 + tree fntype, fndecl;
114008 +
114009 + fntype = build_function_type_list(void_type_node, NULL_TREE);
114010 + fndecl = build_fn_decl(track_function, fntype);
114011 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
114012 +
114013 + // insert call to void pax_track_stack(void)
114014 + track_stack = gimple_build_call(fndecl, 0);
114015 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
114016 +}
114017 +
114018 +#if BUILDING_GCC_VERSION == 4005
114019 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
114020 +{
114021 + tree fndecl;
114022 +
114023 + if (!is_gimple_call(stmt))
114024 + return false;
114025 + fndecl = gimple_call_fndecl(stmt);
114026 + if (!fndecl)
114027 + return false;
114028 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
114029 + return false;
114030 +// print_node(stderr, "pax", fndecl, 4);
114031 + return DECL_FUNCTION_CODE(fndecl) == code;
114032 +}
114033 +#endif
114034 +
114035 +static bool is_alloca(gimple stmt)
114036 +{
114037 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
114038 + return true;
114039 +
114040 +#if BUILDING_GCC_VERSION >= 4007
114041 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
114042 + return true;
114043 +#endif
114044 +
114045 + return false;
114046 +}
114047 +
114048 +static unsigned int execute_stackleak_tree_instrument(void)
114049 +{
114050 + basic_block bb, entry_bb;
114051 + bool prologue_instrumented = false, is_leaf = true;
114052 +
114053 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
114054 +
114055 + // 1. loop through BBs and GIMPLE statements
114056 + FOR_EACH_BB(bb) {
114057 + gimple_stmt_iterator gsi;
114058 +
114059 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114060 + gimple stmt;
114061 +
114062 + stmt = gsi_stmt(gsi);
114063 +
114064 + if (is_gimple_call(stmt))
114065 + is_leaf = false;
114066 +
114067 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
114068 + if (!is_alloca(stmt))
114069 + continue;
114070 +
114071 + // 2. insert stack overflow check before each __builtin_alloca call
114072 + stackleak_check_alloca(&gsi);
114073 +
114074 + // 3. insert track call after each __builtin_alloca call
114075 + stackleak_add_instrumentation(&gsi);
114076 + if (bb == entry_bb)
114077 + prologue_instrumented = true;
114078 + }
114079 + }
114080 +
114081 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
114082 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
114083 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
114084 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
114085 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
114086 + return 0;
114087 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
114088 + return 0;
114089 +
114090 + // 4. insert track call at the beginning
114091 + if (!prologue_instrumented) {
114092 + gimple_stmt_iterator gsi;
114093 +
114094 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114095 + if (dom_info_available_p(CDI_DOMINATORS))
114096 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114097 + gsi = gsi_start_bb(bb);
114098 + stackleak_add_instrumentation(&gsi);
114099 + }
114100 +
114101 + return 0;
114102 +}
114103 +
114104 +static unsigned int execute_stackleak_final(void)
114105 +{
114106 + rtx insn, next;
114107 +
114108 + if (cfun->calls_alloca)
114109 + return 0;
114110 +
114111 + // keep calls only if function frame is big enough
114112 + if (get_frame_size() >= track_frame_size)
114113 + return 0;
114114 +
114115 + // 1. find pax_track_stack calls
114116 + for (insn = get_insns(); insn; insn = next) {
114117 + // 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))
114118 + rtx body;
114119 +
114120 + next = NEXT_INSN(insn);
114121 + if (!CALL_P(insn))
114122 + continue;
114123 + body = PATTERN(insn);
114124 + if (GET_CODE(body) != CALL)
114125 + continue;
114126 + body = XEXP(body, 0);
114127 + if (GET_CODE(body) != MEM)
114128 + continue;
114129 + body = XEXP(body, 0);
114130 + if (GET_CODE(body) != SYMBOL_REF)
114131 + continue;
114132 + if (strcmp(XSTR(body, 0), track_function))
114133 + continue;
114134 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114135 + // 2. delete call
114136 + delete_insn_and_edges(insn);
114137 +#if BUILDING_GCC_VERSION >= 4007
114138 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
114139 + insn = next;
114140 + next = NEXT_INSN(insn);
114141 + delete_insn_and_edges(insn);
114142 + }
114143 +#endif
114144 + }
114145 +
114146 +// print_simple_rtl(stderr, get_insns());
114147 +// print_rtl(stderr, get_insns());
114148 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114149 +
114150 + return 0;
114151 +}
114152 +
114153 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114154 +{
114155 + const char * const plugin_name = plugin_info->base_name;
114156 + const int argc = plugin_info->argc;
114157 + const struct plugin_argument * const argv = plugin_info->argv;
114158 + int i;
114159 + struct register_pass_info stackleak_tree_instrument_pass_info = {
114160 + .pass = &stackleak_tree_instrument_pass.pass,
114161 +// .reference_pass_name = "tree_profile",
114162 + .reference_pass_name = "optimized",
114163 + .ref_pass_instance_number = 1,
114164 + .pos_op = PASS_POS_INSERT_BEFORE
114165 + };
114166 + struct register_pass_info stackleak_final_pass_info = {
114167 + .pass = &stackleak_final_rtl_opt_pass.pass,
114168 + .reference_pass_name = "final",
114169 + .ref_pass_instance_number = 1,
114170 + .pos_op = PASS_POS_INSERT_BEFORE
114171 + };
114172 +
114173 + if (!plugin_default_version_check(version, &gcc_version)) {
114174 + error(G_("incompatible gcc/plugin versions"));
114175 + return 1;
114176 + }
114177 +
114178 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
114179 +
114180 + for (i = 0; i < argc; ++i) {
114181 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
114182 + if (!argv[i].value) {
114183 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114184 + continue;
114185 + }
114186 + track_frame_size = atoi(argv[i].value);
114187 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
114188 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114189 + continue;
114190 + }
114191 + if (!strcmp(argv[i].key, "initialize-locals")) {
114192 + if (argv[i].value) {
114193 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114194 + continue;
114195 + }
114196 + init_locals = true;
114197 + continue;
114198 + }
114199 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114200 + }
114201 +
114202 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
114203 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
114204 +
114205 + return 0;
114206 +}
114207 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
114208 new file mode 100644
114209 index 0000000..4fae911
114210 --- /dev/null
114211 +++ b/tools/gcc/structleak_plugin.c
114212 @@ -0,0 +1,277 @@
114213 +/*
114214 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
114215 + * Licensed under the GPL v2
114216 + *
114217 + * Note: the choice of the license means that the compilation process is
114218 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
114219 + * but for the kernel it doesn't matter since it doesn't link against
114220 + * any of the gcc libraries
114221 + *
114222 + * gcc plugin to forcibly initialize certain local variables that could
114223 + * otherwise leak kernel stack to userland if they aren't properly initialized
114224 + * by later code
114225 + *
114226 + * Homepage: http://pax.grsecurity.net/
114227 + *
114228 + * Usage:
114229 + * $ # for 4.5/4.6/C based 4.7
114230 + * $ 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
114231 + * $ # for C++ based 4.7/4.8+
114232 + * $ 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
114233 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
114234 + *
114235 + * TODO: eliminate redundant initializers
114236 + * increase type coverage
114237 + */
114238 +
114239 +#include "gcc-plugin.h"
114240 +#include "config.h"
114241 +#include "system.h"
114242 +#include "coretypes.h"
114243 +#include "tree.h"
114244 +#include "tree-pass.h"
114245 +#include "intl.h"
114246 +#include "plugin-version.h"
114247 +#include "tm.h"
114248 +#include "toplev.h"
114249 +#include "function.h"
114250 +#include "tree-flow.h"
114251 +#include "plugin.h"
114252 +#include "gimple.h"
114253 +#include "diagnostic.h"
114254 +#include "cfgloop.h"
114255 +#include "langhooks.h"
114256 +
114257 +#if BUILDING_GCC_VERSION >= 4008
114258 +#define TODO_dump_func 0
114259 +#endif
114260 +
114261 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
114262 +
114263 +// unused type flag in all versions 4.5-4.8
114264 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
114265 +
114266 +int plugin_is_GPL_compatible;
114267 +void debug_gimple_stmt(gimple gs);
114268 +
114269 +static struct plugin_info structleak_plugin_info = {
114270 + .version = "201304082245",
114271 + .help = "disable\tdo not activate plugin\n",
114272 +};
114273 +
114274 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
114275 +{
114276 + *no_add_attrs = true;
114277 +
114278 + // check for types? for now accept everything linux has to offer
114279 + if (TREE_CODE(*node) != FIELD_DECL)
114280 + return NULL_TREE;
114281 +
114282 + *no_add_attrs = false;
114283 + return NULL_TREE;
114284 +}
114285 +
114286 +static struct attribute_spec user_attr = {
114287 + .name = "user",
114288 + .min_length = 0,
114289 + .max_length = 0,
114290 + .decl_required = false,
114291 + .type_required = false,
114292 + .function_type_required = false,
114293 + .handler = handle_user_attribute,
114294 +#if BUILDING_GCC_VERSION >= 4007
114295 + .affects_type_identity = true
114296 +#endif
114297 +};
114298 +
114299 +static void register_attributes(void *event_data, void *data)
114300 +{
114301 + register_attribute(&user_attr);
114302 +// register_attribute(&force_attr);
114303 +}
114304 +
114305 +static tree get_field_type(tree field)
114306 +{
114307 + return strip_array_types(TREE_TYPE(field));
114308 +}
114309 +
114310 +static bool is_userspace_type(tree type)
114311 +{
114312 + tree field;
114313 +
114314 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
114315 + tree fieldtype = get_field_type(field);
114316 + enum tree_code code = TREE_CODE(fieldtype);
114317 +
114318 + if (code == RECORD_TYPE || code == UNION_TYPE)
114319 + if (is_userspace_type(fieldtype))
114320 + return true;
114321 +
114322 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
114323 + return true;
114324 + }
114325 + return false;
114326 +}
114327 +
114328 +static void finish_type(void *event_data, void *data)
114329 +{
114330 + tree type = (tree)event_data;
114331 +
114332 + if (TYPE_USERSPACE(type))
114333 + return;
114334 +
114335 + if (is_userspace_type(type))
114336 + TYPE_USERSPACE(type) = 1;
114337 +}
114338 +
114339 +static void initialize(tree var)
114340 +{
114341 + basic_block bb;
114342 + gimple_stmt_iterator gsi;
114343 + tree initializer;
114344 + gimple init_stmt;
114345 +
114346 + // this is the original entry bb before the forced split
114347 + // TODO: check further BBs in case more splits occured before us
114348 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
114349 +
114350 + // first check if the variable is already initialized, warn otherwise
114351 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114352 + gimple stmt = gsi_stmt(gsi);
114353 + tree rhs1;
114354 +
114355 + // we're looking for an assignment of a single rhs...
114356 + if (!gimple_assign_single_p(stmt))
114357 + continue;
114358 + rhs1 = gimple_assign_rhs1(stmt);
114359 +#if BUILDING_GCC_VERSION >= 4007
114360 + // ... of a non-clobbering expression...
114361 + if (TREE_CLOBBER_P(rhs1))
114362 + continue;
114363 +#endif
114364 + // ... to our variable...
114365 + if (gimple_get_lhs(stmt) != var)
114366 + continue;
114367 + // if it's an initializer then we're good
114368 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
114369 + return;
114370 + }
114371 +
114372 + // these aren't the 0days you're looking for
114373 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
114374 +
114375 + // build the initializer expression
114376 + initializer = build_constructor(TREE_TYPE(var), NULL);
114377 +
114378 + // build the initializer stmt
114379 + init_stmt = gimple_build_assign(var, initializer);
114380 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
114381 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
114382 + update_stmt(init_stmt);
114383 +}
114384 +
114385 +static unsigned int handle_function(void)
114386 +{
114387 + basic_block bb;
114388 + unsigned int ret = 0;
114389 + tree var;
114390 +
114391 +#if BUILDING_GCC_VERSION == 4005
114392 + tree vars;
114393 +#else
114394 + unsigned int i;
114395 +#endif
114396 +
114397 + // split the first bb where we can put the forced initializers
114398 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114399 + if (dom_info_available_p(CDI_DOMINATORS))
114400 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114401 +
114402 + // enumarate all local variables and forcibly initialize our targets
114403 +#if BUILDING_GCC_VERSION == 4005
114404 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
114405 + var = TREE_VALUE(vars);
114406 +#else
114407 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
114408 +#endif
114409 + tree type = TREE_TYPE(var);
114410 +
114411 + gcc_assert(DECL_P(var));
114412 + if (!auto_var_in_fn_p(var, current_function_decl))
114413 + continue;
114414 +
114415 + // only care about structure types
114416 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
114417 + continue;
114418 +
114419 + // if the type is of interest, examine the variable
114420 + if (TYPE_USERSPACE(type))
114421 + initialize(var);
114422 + }
114423 +
114424 + return ret;
114425 +}
114426 +
114427 +static struct gimple_opt_pass structleak_pass = {
114428 + .pass = {
114429 + .type = GIMPLE_PASS,
114430 + .name = "structleak",
114431 +#if BUILDING_GCC_VERSION >= 4008
114432 + .optinfo_flags = OPTGROUP_NONE,
114433 +#endif
114434 + .gate = NULL,
114435 + .execute = handle_function,
114436 + .sub = NULL,
114437 + .next = NULL,
114438 + .static_pass_number = 0,
114439 + .tv_id = TV_NONE,
114440 + .properties_required = PROP_cfg,
114441 + .properties_provided = 0,
114442 + .properties_destroyed = 0,
114443 + .todo_flags_start = 0,
114444 + .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
114445 + }
114446 +};
114447 +
114448 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114449 +{
114450 + int i;
114451 + const char * const plugin_name = plugin_info->base_name;
114452 + const int argc = plugin_info->argc;
114453 + const struct plugin_argument * const argv = plugin_info->argv;
114454 + bool enable = true;
114455 +
114456 + struct register_pass_info structleak_pass_info = {
114457 + .pass = &structleak_pass.pass,
114458 + .reference_pass_name = "ssa",
114459 + .ref_pass_instance_number = 1,
114460 + .pos_op = PASS_POS_INSERT_AFTER
114461 + };
114462 +
114463 + if (!plugin_default_version_check(version, &gcc_version)) {
114464 + error(G_("incompatible gcc/plugin versions"));
114465 + return 1;
114466 + }
114467 +
114468 + if (strcmp(lang_hooks.name, "GNU C")) {
114469 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
114470 + enable = false;
114471 + }
114472 +
114473 + for (i = 0; i < argc; ++i) {
114474 + if (!strcmp(argv[i].key, "disable")) {
114475 + enable = false;
114476 + continue;
114477 + }
114478 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114479 + }
114480 +
114481 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
114482 + if (enable) {
114483 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
114484 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
114485 + }
114486 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
114487 +
114488 + return 0;
114489 +}
114490 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
114491 index 3dba0a4..97175dc 100644
114492 --- a/tools/lib/lk/Makefile
114493 +++ b/tools/lib/lk/Makefile
114494 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
114495
114496 LIBFILE = liblk.a
114497
114498 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114499 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114500 EXTLIBS = -lelf -lpthread -lrt -lm
114501 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
114502 ALL_LDFLAGS = $(LDFLAGS)
114503 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
114504 index 6789d78..4afd019e 100644
114505 --- a/tools/perf/util/include/asm/alternative-asm.h
114506 +++ b/tools/perf/util/include/asm/alternative-asm.h
114507 @@ -5,4 +5,7 @@
114508
114509 #define altinstruction_entry #
114510
114511 + .macro pax_force_retaddr rip=0, reload=0
114512 + .endm
114513 +
114514 #endif
114515 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
114516 index 96b919d..c49bb74 100644
114517 --- a/tools/perf/util/include/linux/compiler.h
114518 +++ b/tools/perf/util/include/linux/compiler.h
114519 @@ -18,4 +18,12 @@
114520 #define __force
114521 #endif
114522
114523 +#ifndef __size_overflow
114524 +# define __size_overflow(...)
114525 +#endif
114526 +
114527 +#ifndef __intentional_overflow
114528 +# define __intentional_overflow(...)
114529 +#endif
114530 +
114531 #endif
114532 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
114533 index 1cf9ccb..b9236e2 100644
114534 --- a/virt/kvm/kvm_main.c
114535 +++ b/virt/kvm/kvm_main.c
114536 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
114537
114538 static cpumask_var_t cpus_hardware_enabled;
114539 static int kvm_usage_count = 0;
114540 -static atomic_t hardware_enable_failed;
114541 +static atomic_unchecked_t hardware_enable_failed;
114542
114543 struct kmem_cache *kvm_vcpu_cache;
114544 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
114545
114546 -static __read_mostly struct preempt_ops kvm_preempt_ops;
114547 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
114548 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
114549 +static struct preempt_ops kvm_preempt_ops = {
114550 + .sched_in = kvm_sched_in,
114551 + .sched_out = kvm_sched_out,
114552 +};
114553
114554 struct dentry *kvm_debugfs_dir;
114555
114556 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
114557 /* We can read the guest memory with __xxx_user() later on. */
114558 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
114559 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
114560 - !access_ok(VERIFY_WRITE,
114561 + !__access_ok(VERIFY_WRITE,
114562 (void __user *)(unsigned long)mem->userspace_addr,
114563 mem->memory_size)))
114564 goto out;
114565 @@ -1867,7 +1872,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
114566 return 0;
114567 }
114568
114569 -static struct file_operations kvm_vcpu_fops = {
114570 +static file_operations_no_const kvm_vcpu_fops __read_only = {
114571 .release = kvm_vcpu_release,
114572 .unlocked_ioctl = kvm_vcpu_ioctl,
114573 #ifdef CONFIG_COMPAT
114574 @@ -2550,7 +2555,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
114575 return 0;
114576 }
114577
114578 -static struct file_operations kvm_vm_fops = {
114579 +static file_operations_no_const kvm_vm_fops __read_only = {
114580 .release = kvm_vm_release,
114581 .unlocked_ioctl = kvm_vm_ioctl,
114582 #ifdef CONFIG_COMPAT
114583 @@ -2651,7 +2656,7 @@ out:
114584 return r;
114585 }
114586
114587 -static struct file_operations kvm_chardev_ops = {
114588 +static file_operations_no_const kvm_chardev_ops __read_only = {
114589 .unlocked_ioctl = kvm_dev_ioctl,
114590 .compat_ioctl = kvm_dev_ioctl,
114591 .llseek = noop_llseek,
114592 @@ -2677,7 +2682,7 @@ static void hardware_enable_nolock(void *junk)
114593
114594 if (r) {
114595 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
114596 - atomic_inc(&hardware_enable_failed);
114597 + atomic_inc_unchecked(&hardware_enable_failed);
114598 printk(KERN_INFO "kvm: enabling virtualization on "
114599 "CPU%d failed\n", cpu);
114600 }
114601 @@ -2731,10 +2736,10 @@ static int hardware_enable_all(void)
114602
114603 kvm_usage_count++;
114604 if (kvm_usage_count == 1) {
114605 - atomic_set(&hardware_enable_failed, 0);
114606 + atomic_set_unchecked(&hardware_enable_failed, 0);
114607 on_each_cpu(hardware_enable_nolock, NULL, 1);
114608
114609 - if (atomic_read(&hardware_enable_failed)) {
114610 + if (atomic_read_unchecked(&hardware_enable_failed)) {
114611 hardware_disable_all_nolock();
114612 r = -EBUSY;
114613 }
114614 @@ -3168,7 +3173,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
114615 kvm_arch_vcpu_put(vcpu);
114616 }
114617
114618 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114619 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114620 struct module *module)
114621 {
114622 int r;
114623 @@ -3215,7 +3220,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114624 if (!vcpu_align)
114625 vcpu_align = __alignof__(struct kvm_vcpu);
114626 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
114627 - 0, NULL);
114628 + SLAB_USERCOPY, NULL);
114629 if (!kvm_vcpu_cache) {
114630 r = -ENOMEM;
114631 goto out_free_3;
114632 @@ -3225,9 +3230,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114633 if (r)
114634 goto out_free;
114635
114636 + pax_open_kernel();
114637 kvm_chardev_ops.owner = module;
114638 kvm_vm_fops.owner = module;
114639 kvm_vcpu_fops.owner = module;
114640 + pax_close_kernel();
114641
114642 r = misc_register(&kvm_dev);
114643 if (r) {
114644 @@ -3237,9 +3244,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114645
114646 register_syscore_ops(&kvm_syscore_ops);
114647
114648 - kvm_preempt_ops.sched_in = kvm_sched_in;
114649 - kvm_preempt_ops.sched_out = kvm_sched_out;
114650 -
114651 r = kvm_init_debug();
114652 if (r) {
114653 printk(KERN_ERR "kvm: create debugfs files failed\n");